thescientist Posted January 21, 2011 Share Posted January 21, 2011 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 Link to comment Share on other sites More sharing options...
Dark Knight Posted January 21, 2011 Author Share Posted January 21, 2011 I give up. I just wanted my 'first' and 'last' names be seen in my E-mail. All this work for nothing. Link to comment Share on other sites More sharing options...
ShadowMage Posted January 21, 2011 Share Posted January 21, 2011 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 comment Share on other sites More sharing options...
Dark Knight Posted January 21, 2011 Author Share Posted January 21, 2011 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 comment Share on other sites More sharing options...
jeffman Posted January 21, 2011 Share Posted January 21, 2011 We have all been in that situation, usually hundreds of times. It is frustrating, but the more you try, the more you learn, and the easier things will become. Really. Link to comment Share on other sites More sharing options...
chokk Posted January 21, 2011 Share Posted January 21, 2011 Can you provide a link to your host? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.