+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Simple PHP Email Sending Form

  1. #1
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Question Simple PHP Email Sending Form

    So I am reading a PHP book that gives me lessons and teaches me how to code it and I am currently trying to create a simple form that lets you enter your name email and a message and then that sends it to the email address. The problem is when i click the submit form it just seems to refresh the page, the data I input disappears, and the page stays the same, and I checked my email and it wasn't sent. However the coding is supposed to redirect to a page saying your email was sent blah, anyways here is the code, please tell me the typo I made, I would like to keep the coding the same, as this is the way the book is teaching me, I am sure I just made a simple error.

    Heres the HTML Form Page
    <HTML>
    <HEAD>
    <TITLE>Simple Feedback Form</TITLE>
    </HEAD>
    <BODY>

    <FORM METHOD="POST" ACTION="send_simpleform.php">

    <P><strong>Your Name:</strong><br>
    <INPUT type="text" NAME="sender_name" SIZE=30></P>

    <P><strong>Your E-Mail Address:</strong><br>
    <INPUT type="text" NAME="sender_name" SIZE=30></P>

    <P><strong>Message:</strong><br>
    <TEXTAREA NAME="message" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></P>

    <P><INPUT TYPE="submit" NAME="submit" VALUE="Send This Form"></P>

    </FORM>
    </BODY>
    </HTML>
    And Here Is The PHP Part
    PHP Code:
    <?

    if (($_POST[sender_name] == "") ||
        (
    $_POST[sender_email] == "") ||
        (
    $_POST[message] == "")) {
        
    header("Location: simple_form.html");
        exit;
    }

    $msg "E-MAIL SENT FROM WWW SITE\n";
    $msg .= "Sender's Name:\t$_POST[sender_name]\n";
    $msg .= "Sender's E-Mail:\t$_POST[sender_email]\n";
    $msg .= "Message:\t$_POST[message]\n";
    $to "dquigley@dollarstoriches.com";
    $subject "Web Site Feedback";
    $mailheaders "From: My Web Site <dquigley@dollarstoriches.com>\n";
    $mailheaders .= "Reply-To: $_POST[sender_email]\n";
    mail($to$subject$msg$mailheaders);

    ?>

    <HTML>
    <HEAD>
    <TITLE>Simple Feedback Form Sent</TITLE>
    </HEAD>
    <BODY>

    <H1>The following e-mail has been sent:</H1>

    <P><strong>Your Name:</strong><br>
    <? echo "$_POST[sender_name]"?>
    <P><strong>Your E-Mail Address:</strong><br>
    <? echo "$_POST[sender_email]"?>
    <P><strong>Message:</strong><br>
    <? echo "$_POST[message]"?>

    </BODY>
    </HTML>

  2. #2
    tttony's Avatar
    tttony is offline x10 Sophmore tttony is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    ~ 10°10'27.10''' N 67°59'59'.59''' O elev. 457m
    Posts
    147

    Thumbs up Re: Simple PHP Email Sending Form

    problem solved...
    Last edited by tttony; 12-12-2008 at 10:07 PM. Reason: problem solved...
    PHP & MySQL Web Developer
    Free Domain co.cc

  3. #3
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: Simple PHP Email Sending Form

    The <?PHP doesnt make a difference and I made a point of saying I dont want to redo the script I just want to find the error, so me copying your whole script wouldnt be me creating it. So thanks but I only need to find the error not redo my script.

  4. #4
    tttony's Avatar
    tttony is offline x10 Sophmore tttony is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    ~ 10°10'27.10''' N 67°59'59'.59''' O elev. 457m
    Posts
    147

    Re: Simple PHP Email Sending Form

    Ok I just show the correct way, try with my code because I fixed the error.. just try and tell me...
    PHP & MySQL Web Developer
    Free Domain co.cc

  5. #5
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: Simple PHP Email Sending Form

    ok well what was the error u fixed? just tell me what to fix, I dont want to just copy and paste that wont help me learn. Also the <?php doesnt matter.

  6. #6
    gomarc's Avatar
    gomarc is offline x10 Elder gomarc is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    USA
    Posts
    511

    Re: Simple PHP Email Sending Form

    In your HTML code change line 13 to

    <INPUT type="text" NAME="sender_email" SIZE=30></P>

  7. #7
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: Simple PHP Email Sending Form

    BATMAN SAVES THE DAY AGAIN! TY Gomarc! You are THEMAN THEBATMAN!

  8. #8
    tttony's Avatar
    tttony is offline x10 Sophmore tttony is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    ~ 10°10'27.10''' N 67°59'59'.59''' O elev. 457m
    Posts
    147

    Re: Simple PHP Email Sending Form

    problem solved... sorry I dont saw HTML code..

    ok I just say one thing dquigley I like help people because at the same time I learn from other errors I like give advice about that errors and get good practices
    PHP & MySQL Web Developer
    Free Domain co.cc

  9. #9
    dquigley's Avatar
    dquigley is offline x10 Sophmore dquigley is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Fresno, CA
    Posts
    249

    Re: Simple PHP Email Sending Form

    Hey thx tony im glad ur here to help, it seems like I make a mistake in these every day so im sure ill need ur help again! THANKS GUYS!

  10. #10
    brunoais is offline x10 Sophmore brunoais is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    111

    Re: Simple PHP Email Sending Form

    serch for:
    <P><strong>Your E-Mail Address:</strong><br>
    at next line change:
    <INPUT type="text" NAME="sender_name" SIZE=30></P>
    to:
    <INPUT type="text" NAME="
    sender_email" SIZE=30></P>

    When the page reloaded the $_Post['
    sender_email'] was empty so it was returning to the form ;)

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  2. Can I make a PHP email form?
    By AnimaVex in forum Free Hosting
    Replies: 1
    Last Post: 04-25-2008, 04:15 PM
  3. Replies: 3
    Last Post: 03-10-2008, 12:22 PM
  4. Two very simple php file upload scripts-Free
    By Symbian.Ankit in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 02-20-2008, 09:55 AM
  5. PHP Form
    By trev in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 05-24-2005, 01:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers