Jump to content

Recommended Posts

Yes, I've forget a semicolon. I've added and the array(0) is again displayed above the form. Still, no email received.
for the third time....THAT WILL HAPPEN THE FIRST TIME!the $_POST array will NOT GET FILLED TILL YOU SUBMIT THE FORM.when a form get's submitted, the field names and their values will fill the array THEN. Then that's when you see the data. PLEASE PROVIDE THIS. Please try and understand this concept. If you do not see anything in the $_POST array AFTER you submit, then that's when you have a problem.My only suggestion, which I suggested before, was to try and re-write the email creation part like this (added lot's of comments that won't get filled out until you submit):
<?phpvar_dump($_POST);if (isset($_POST['Submit'])){  echo '<br>';  $to = 'mymail@yahoo.com';  $email = $_POST['email'];  $subject = "Subject: " . $_POST['subject'];  $message = 'Name: ' . $_POST['first'] . '   ' . $_POST['last'];  $message .= $_POST['message'];  $header = 'From: ' . $email;  echo $to . '<br>';  echo $subject . '<br/>';  echo $message . '<br/>';  echo $header . '<br/>';  mail($to, $subject, $message, $header);  echo "Thank you for using our mail form";}else{  //if "email" is not filled out, display the form  echo "<form method='post' action='index.php'>  First Name: <input name='first' type='text' /><br />    Last Name: <input name='last' type='text' /><br/>  Email: <input name='email' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='15' cols='40'>  </textarea><br />  <input type='submit' />  </form>";}?>

edit: fixed a couple syntax errors

Edited by thescientist
Link to post
Share on other sites
  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I give up. I just wanted my 'first' and 'last' names be seen in my E-mail. All this work for nothing.
Don't give up. We're trying to help you.Let's start over with your original code:
<?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email  {  //send email  $to = $_REQUEST['mymailaddress@yahoo.com']  $email = $_REQUEST['email'];  $subject = $_REQUEST['subject'];  $message = $_REQUEST['message'];  mail( $to, "Subject: $subject", $message, "From: $email");  echo "Thank you for using our mail form";  }else//if "email" is not filled out, display the form  {  echo "<form method='post' action='index.php'>  First Name: <input name='first' type='text' /><br />  Last Name: <input name='last' type='text' /><br/>  Email: <input name='email' type='text' /><br />  Subject: <input name='subject' type='text' /><br />  Message:<br />  <textarea name='message' rows='15' cols='40'>  </textarea><br />  <input type='submit' />  </form>";  }?>

That worked didn't it? Ok so lets go back over the things suggested to you.1. Change this $to = $_REQUEST['mymailaddress@yahoo.com'] to just $to = 'mymailaddress@yahoo.com'2. Replace $_REQUEST with $_POST3. Add the first and last names to the message: $message = "Name: ".$_POST['first']." ".$_POST['last']."<br />".$_POST['message'];So your code should now look like this:

<?phpif (isset($_REQUEST['email']))//if "email" is filled out, send email  {  //send email  $to = 'mymailaddress@yahoo.com';  $email = $_POST['email'];  $subject = $_POST['subject'];  $message = "Name: ".$_POST['first']." ".$_POST['last']."<br />".$_POST['message'];  mail( $to, "Subject: $subject", $message, "From: $email");  echo "Thank you for using our mail form";  }else//if "email" is not filled out, display the form  {  //form here  }?>

Link to post
Share on other sites

Have you tried yourself? I tried myself on my server, but no result. I still don't receive any email. Believe me, it's frustrating to re-write the code, again, again and again. I think I've uploaded the page on the sever, at least 50 times since yesterday.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...