SitePoint Sponsor

User Tag List

Page 4 of 4 FirstFirst 1234
Results 76 to 91 of 91
  1. #76
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kigoobe View Post
    It's still there ...
    I removed it right after posting. Check again.
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  2. #77
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I was going to speak about that. porocess.php was getting called twice. You can modify this second one further as (same thing with ob_start() and ob_end_flush()) -

    PHP Code:
    <?php 
    ob_start
    ();
    session_start(); 

    require_once(
    'process.php'); 

    $s_error_message verify(); 
    print(
    "|" $s_error_message "|"); 
    if ((
    strlen($s_error_message) == 0
        && (isset(
    $_POST['submit']))) 

        
    $to="email@site.com"
        
    $message $name ' just filled in your contact form. They said:\n' $comments '\n\nTheir e-mail address was: ' $email
        
    $subject ucfirst($category); 
                 
    //    if (mail($to, $subject, $message, 'From: ' . $email)) {header('Location: index1.php');} 
    //    else {print('There was a problem sending the mail. Please check that you filled in the form correctly.');} 

    ?> 
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
        <head> 
            <title>mysite.com</title> 
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
            <link href="structure1.css" rel="stylesheet" type="text/css"> 
            <link href="appearance1.css" rel="stylesheet" type="text/css"> 
        </head> 
        <body> 
            <br /> 
            <br /> 
            <div id="wrapper"> 
                <img src="images/logo.gif"> 
                <div id="banner"> 
                    <h1>&nbsp;</h1> 
                </div> 
                <div id="l"> 
    <?php 
    //    include ('includes/navigation.inc.html'); 
    ?> 
                </div> 
                <div id="m"> 
                    <p>&nbsp;</p> 
                    <h1> 
                        site<br /> 
                        <span class="grey">contact</span> 
                    </h1> 
                    <h1>&nbsp;</h1> 
                    <div id="leftlist"> 
                        <h2>Please fill in all the text fields, if you don'tleave your name or a valid email no information can reach us.</h2> 
                        <p>&nbsp;</p> 
                        <p>kind regards</p> 
                    </div> 
                    <div id="rightlist"> 
    <?php 
        
    if (strlen($s_error_message) > 0) {print($s_error_message);} 
    ?> 
                        <form name="contact" method="post" action="form.php"> 
                            <table> 
                                <tr> 
                                    <td>Name:</td> 
                                    <td><input name="name" type="text" id="name" value="<?php print($name); ?>" /></td> 
                                </tr> 
                                <tr> 
                                    <td>Email:</td> 
                                    <td><input name="email" type="text" id="email" value="<?php print($email); ?>" /></td> 
                                </tr> 
                                <tr> 
                                    <td>Category:</td> 
                                    <td> 
                                        <select name="category" id="category"> 
                                            <option value="">Please Select</option> 
    <?php 
    if ($category == 'enquires') {$s_selected " selected='selected'";}   
    else {
    $s_selected '';}   
    ?> 
                                            <option value="enquires"<?php print($s_selected); ?>>Enquries</option> 
    <?php 
    if ($category == 'clubs') {$s_selected " selected='selected'";}   
    else {
    $s_selected '';}   
    ?> 
                                            <option value="clubs"<?php print($s_selected); ?>>Clubs</option> 
    <?php 
    if ($category == 'pictures') {$s_selected " selected='selected'";}   
    else {
    $s_selected '';}   
    ?> 
                                            <option value="pictures"<?php print($s_selected); ?>>Pictures</option> 
    <?php 
    if ($category == 'advertise') {$s_selected " selected='selected'";}   
    else {
    $s_selected '';}   
    ?> 
                                            <option value="advertise"<?php print($s_selected); ?>>Advertise</option> 
    <?php 
    if ($category == 'other') {$s_selected " selected='selected'";}   
    else {
    $s_selected '';}   
    ?> 
                                            <option value="other"<?php print($s_selected); ?>>Other</option> 
                                        </select> 
                                    </td> 
                                </tr> 
                                <tr> 
                                    <td>Comments:</td> 
                                    <td><textarea name="comment" id="comment"><?php print($comments); ?></textarea></td> 
                                </tr> 
                                <tr> 
                                    <td colspan="2"><input type="submit" name="submit" value="Submit" /></td> 
                                </tr> 
                            </table> 
                        </form> 
                    </div> 
                </div> 
                <div id="r"> 
    <?php 
    //    include('includes/sub_navigation.inc.html'); 
    ?> 
                </div> 
    <?php 
    //    include ('includes/footer.inc.html'); 
    ?> 
            </div> 
        </body> 
    </html> 
    <?
    ob_end_flush
    ();    
    ?>

  3. #78
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by miggl View Post
    I removed it right after posting. Check again.
    Yeah, this is better now

  4. #79
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I was going to speak about that. porocess.php was getting called twice. You can modify this second one further as (same thing with ob_start() and ob_end_flush()) -
    That was an error on my part - 'dirty' code left over from debugging that I forgot to remove, wasn't supposed to be there. :|
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  5. #80
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just updated my end instead of showing an error it's replaced with
    PHP Code:
    print("|" $s_error_message "|"); // | | 
    The form errors are still showing twice and when I submit that famous error comes back again, plus my text fields dont stay updated with the previous input?

    thanks

  6. #81
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check my code post a few posts up. I updated it. The line you referenced was for debugging.
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  7. #82
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok now where getting some where. My Problem now. Thanks.

    1. When conatct.php loads it has | | at the top left of the page outside of my <html>
    2. Still showing double form errors, one at the top of the page and one within the form
    3. when filling out the form if i leave a field blank then submit the errors shows twice like above but the fields are blank and dont store the previous data

    thanks again guys

  8. #83
    Always learning kigoobe's Avatar
    Join Date
    May 2004
    Location
    Paris
    Posts
    1,565
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well barry, when u will be a bit used to php, try swiftmailer http://www.swiftmailer.org/ a great email software that I use in complex situations, much better than php mail function.

  9. #84
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    Ok now where getting some where. My Problem now. Thanks.

    1. When conatct.php loads it has | | at the top left of the page outside of my <html>
    2. Still showing double form errors, one at the top of the page and one within the form
    3. when filling out the form if i leave a field blank then submit the errors shows twice like above but the fields are blank and dont store the previous data

    thanks again guys
    Barry, copy my code from a few posts up. There are some other changes in there that should fix the things you are seeing (I'm assuming you modified your code, instead of copying my posted code).

    Glad to see we're getting somewhere.
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  10. #85
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok. getting closer and thanks for the link kigoobe

    Thanks anyway before we begin.

    The page loads as it should showing no errors.

    PROBLEMS:

    1. When It returns an error saying you forgot your email or name the fields i filled in previous are lost, so you have to fill in the form again in full.
    2. I get conformation saying I have mail but no propertys meaning no message is shown and no name etc in my client.

    Whats the diffrence between these then?:

    Code:
    <form name="contact" method="post" action="<?php $_POST['PHP-SELF'];?>">
    <form name="contact" method="post" action="contact.php">
    The page is working when i submit and going to the correct header - index1.php my home page.

    thanks

  11. #86
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    Whats the diffrence between these then?:
    Code:
    <form name="contact" method="post" action="<?php $_POST['PHP-SELF'];?>">
    <form name="contact" method="post" action="contact.php">
    There are no differences. In fact, the following are all the same, given that the form is in the contact.php page:
    Code:
    <form name="contact" method="post" action="<?php $_POST['PHP-SELF'];?>">
    <form name="contact" method="post" action="contact.php">
    <form name="contact" method="post" action="">
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  12. #87
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks mike just cleared that up for me, so

    PROBLEMS:

    1. When It returns an error saying you forgot your email or name the fields i filled in previous are lost, so you have to fill in the form again in full.
    2. I get conformation saying I have mail but no propertys meaning no message is shown and no name etc in my client.


    Cheers nearly there now got to get this rapped up..

    Thanks

  13. #88
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    PROBLEMS:

    1. When It returns an error saying you forgot your email or name the fields i filled in previous are lost, so you have to fill in the form again in full.
    2. I get conformation saying I have mail but no propertys meaning no message is shown and no name etc in my client.
    Since the validation of the page and the form are so closely tied, it doesn't make sense to separate the process.php out anymore (the way it has been coded). I have integrated everything into one php file, which should address the issues you mention (keeping them seperate would require that we duplicate alot of the code in process.php, so no gain there).
    PHP Code:
    <?php
    session_start
    ();

    $name                '';
    $email                '';
    $category            '';
    $comments            '';
    $s_error_message    '';

    if (isset(
    $_POST['submit'])) //check for name of your submit button
    {
        if (isset(
    $_POST['name'])) {$name trim(stripslashes($_POST['name']));}
        if (isset(
    $_POST['email'])) {$email trim(stripslashes($_POST['email']));}
        if (isset(
    $_POST['category'])) {$category trim(stripslashes($_POST['category']));}
        if (isset(
    $_POST['comment'])) {$comments trim(stripslashes($_POST['comment']));}
        if (
    strlen($name) == 0) {$s_error_message .= '<p>You forgot to enter your name!</p>';}
        if (
    strlen($category) == 0) {$s_error_message .= '<p>Please select a category!</p>';}
        if (
    strlen($comments) == 0) {$s_error_message .= '<p>You forgot your comments!</p>';}
        if (
    strlen($email) == 0) {$s_error_message .= "<p>You forgot your email address!</p>";}
        elseif(!
    eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$"$email)) {$s_error_message .= "<p>Not a valid email address</p>";}

        if (
    strlen($s_error_message) == 0)
        {
            
    $to="email@site.com";
            
    $message $name ' just filled in your contact form. They said:\n' $comments '\n\nTheir e-mail address was: ' $email;
            
    $subject ucfirst($category);
                    
            if (
    mail($to$subject$message'From: ' $email)) {header('Location: index1.php');}
            else {print(
    'There was a problem sending the mail. Please check that you filled in the form correctly.');}
        }
    }

    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <title>mysite.com</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <link href="structure1.css" rel="stylesheet" type="text/css">
            <link href="appearance1.css" rel="stylesheet" type="text/css">
        </head>
        <body>
            <br />
            <br />
            <div id="wrapper">
                <img src="images/logo.gif">
                <div id="banner">
                    <h1>&nbsp;</h1>
                </div>
                <div id="l">
    <?php
        
    include ('includes/navigation.inc.html');
    ?>
                </div>
                <div id="m">
                    <p>&nbsp;</p>
                    <h1>
                        site<br />
                        <span class="grey">contact</span>
                    </h1>
                    <h1>&nbsp;</h1>
                    <div id="leftlist">
                        <h2>Please fill in all the text fields, if you don'tleave your name or a valid email no information can reach us.</h2>
                        <p>&nbsp;</p>
                        <p>kind regards</p>
                    </div>
                    <div id="rightlist">
    <?php
        
    if (strlen($s_error_message) > 0) {print($s_error_message);}
    ?>
                        <form name="contact" method="post" action="form.php">
                            <table>
                                <tr>
                                    <td>Name:</td>
                                    <td><input name="name" type="text" id="name" value="<?php print($name); ?>" /></td>
                                </tr>
                                <tr>
                                    <td>Email:</td>
                                    <td><input name="email" type="text" id="email" value="<?php print($email); ?>" /></td>
                                </tr>
                                <tr>
                                    <td>Category:</td>
                                    <td>
                                        <select name="category" id="category">
                                            <option value="">Please Select</option>
    <?php
    if ($category == 'enquires') {$s_selected " selected='selected'";}  
    else {
    $s_selected '';}  
    ?>
                                            <option value="enquires"<?php print($s_selected); ?>>Enquries</option>
    <?php
    if ($category == 'clubs') {$s_selected " selected='selected'";}  
    else {
    $s_selected '';}  
    ?>
                                            <option value="clubs"<?php print($s_selected); ?>>Clubs</option>
    <?php
    if ($category == 'pictures') {$s_selected " selected='selected'";}  
    else {
    $s_selected '';}  
    ?>
                                            <option value="pictures"<?php print($s_selected); ?>>Pictures</option>
    <?php
    if ($category == 'advertise') {$s_selected " selected='selected'";}  
    else {
    $s_selected '';}  
    ?>
                                            <option value="advertise"<?php print($s_selected); ?>>Advertise</option>
    <?php
    if ($category == 'other') {$s_selected " selected='selected'";}  
    else {
    $s_selected '';}  
    ?>
                                            <option value="other"<?php print($s_selected); ?>>Other</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>Comments:</td>
                                    <td><textarea name="comment" id="comment"><?php print($comments); ?></textarea></td>
                                </tr>
                                <tr>
                                    <td colspan="2"><input type="submit" name="submit" value="Submit" /></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <div id="r">
    <?php
        
    include('includes/sub_navigation.inc.html');
    ?>
                </div>
    <?php
        
    include ('includes/footer.inc.html');
    ?>
            </div>
        </body>
    </html>
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  14. #89
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what your saying is have 1 file contact.php with all the above code?

    Thanks

  15. #90
    SitePoint Addict miggl's Avatar
    Join Date
    Feb 2007
    Location
    Los Angeles, CA
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by computerbarry View Post
    So what your saying is have 1 file contact.php with all the above code?

    Thanks
    Exactly. That and the includes that you have made for navigation and footer.
    Celebrate Liberty, Freedom, and Rights at The Constitutionalist.

  16. #91
    SitePoint Wizard
    Join Date
    Dec 2005
    Posts
    1,711
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THANK YOU! lol.. 3 nights hard work lol thanks - working great, well kind of.

    If you dont mind?

    QUESTIONS:

    1. In IE if i submit the form then get deirected back to index1.php, when i click back it shows (The page cannot be displayed). Is that right?
    2. in FF if i dont complete the form in full then click a diffrent link then try and click back it says send post data again. Is that right?
    3. In my mail client my messages are full of /n ?
    4. How secure is this form from spam or hackers?
    5. Could you please leave some comments in the code so i can get a proper understanding?
    6. why a session?
    7. didnt use ob_start(); or ob_end_flush(); what would that achived?

    BIG THANKS & Thanks for your time


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •