www.webdeveloper.com
Results 1 to 6 of 6

Thread: can't received form info

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    120

    can't received form info

    HI

    I am very new at learning php, but i did this form tutorail a few days ago. The form appears to be working properly but i do not get any e-mails. The mail function is there and i do not get any errors when i click submit, just no e-mails. Can someone please point out where the error is. Thank you in advance.

    <?php
    // Function to display form

    function showForm($errorName=false,$errorEmail=false){

    if ($errorName) $errorTextName = "Please enter your name!";

    if ($errorEmail) $errorTextEmail = "Please enter a valid email address!";

    echo '<form action="form.php" method="POST"><table>';

    // Display name field an error if needed

    echo '<tr><td>Name:</td><td><input type="text" name="name"></td></tr>';

    if ($errorName) echo "<tr><td colspan='2'>$errorTextName</td></tr>";

    // Display email field an error if needed

    echo '<tr><td>Email:</td><td><input type="text" name="email"></td></tr>';

    if ($errorEmail) echo "<tr><td colspan='2'>$errorTextEmail</td></tr>";

    echo '<tr><td><input type="submit" name="SubmitForm" value="Send"></td></tr>';

    echo '<form>';

    }

    if(isset($_POST['submit'])) {
    $to = "justinnealryan@gmail.com";
    mail($to, $subject, $body);

    } else {

    //Init error variables

    $errorName = false;

    $errorEmail = false;

    $name = isset($_POST['name']) ? trim($_POST['name']) : '';

    $email = isset($_POST['email']) ? trim($_POST['email']) : '';

    if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $errorEmail = true;

    if (strlen($name)<3) $errorName = true;

    // Display the form again as there was an error

    if ($errorName || $errorEmail) {
    showForm($errorName,$errorEmail);
    } else {

    echo 'Submission was success!';
    echo "<meta http-equiv='refresh' content='0;url=http://www.iheartvacation.com'>";
    }
    }

    ?>

  2. #2
    Join Date
    Feb 2007
    Location
    New Zealand
    Posts
    190
    your script is searching for a post field with the name of 'submit'. replace that with a valid field name and you should be flying

    eg:
    $_POST['FieldName']
    <input name="FieldName" />
    Last edited by toenailsin; 09-08-2008 at 06:40 PM.

  3. #3
    Join Date
    Oct 2006
    Posts
    120
    Hi

    This might sound a bit dumb and i apologize but is that where i put my e-mail address.

  4. #4
    Join Date
    Oct 2006
    Posts
    120
    Hi

    I still get no e-mails after i added what was missing. I am in desperate need of some help to correct this error. I have listed the script below. Next time i will just pay someone to write the script.

    <?php

    $to = "justinnealryan@gmail.com";
    $name = $_POST['name'] ;
    $email = $_POST['email'] ;




    // Function to display form

    function showForm($errorName=false,$errorEmail=false){

    if ($errorName) $errorTextName = "Please enter your name!";

    if ($errorEmail) $errorTextEmail = "Please enter a valid email address!";


    echo '<form action="form.php" method="POST"><table>';



    // Display name field an error if needed

    echo '<tr><td>Name:</td><td><input type="text" name="name"></td></tr>';

    if ($errorName) echo "<tr><td colspan='2'>$errorTextName</td></tr>";



    // Display email field an error if needed

    echo '<tr><td>Email:</td><td><input type="text" name="email"></td></tr>';

    if ($errorEmail) echo "<tr><td colspan='2'>$errorTextEmail</td></tr>";




    echo '<tr><td><input type="submit" name="SubmitForm" value="Send"></td></tr>';

    echo '<form>';

    }





    if(isset($_POST['submit'])) {
    mail( "$email", "Sign Up",
    $message, "$to, $subject, $body" );


    } else {

    //Init error variables

    $errorName = false;

    $errorEmail = false;



    $name = isset($_POST['name']) ? trim($_POST['name']) : '';

    $email = isset($_POST['email']) ? trim($_POST['email']) : '';



    if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) $errorEmail = true;

    if (strlen($name)<3) $errorName = true;




    // Display the form again as there was an error

    if ($errorName || $errorEmail) {

    showForm($errorName,$errorEmail);

    } else {


    echo 'Submission was success!';
    echo "<meta http-equiv='refresh' content='0;url=http://www.iheartvacation.com'>";
    }


    }

    ?>

  5. #5
    Join Date
    Feb 2007
    Location
    New Zealand
    Posts
    190
    I was meaning that these two fields don't match up. Change one to match the other.

    Code:
    echo '<tr><td><input type="submit" name="SubmitForm" value="Send"></td></tr>';
    
    ///////////////
    
    if(isset($_POST['submit'])) {
      $to = "justinnealryan@gmail.com";
      mail($to, $subject, $body);
    } else {
    also, its alot easier to read the code when they're in &#91;CODE]&#91;/CODE] tags

  6. #6
    Join Date
    Oct 2006
    Posts
    120
    Hi

    I tried what you suggested but unfortunately no e-mails. This is a tricky one

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles