carter90 Posted June 19, 2013 Share Posted June 19, 2013 Hi, I am having a problem with this simple form and I can't see why the email is not showing the name and email fields. The email goes through fine and is recieved but just does not show the name and email field. Any thoughts? Thanks <?php $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; $mail_to = ''; $subject = 'Email List Subscription from Toycraft visitor - '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$field_email."\n"; $headers = 'From: '.$field_name."\r\n"; $headers .= 'Reply-To: '.$field_email."\r\n"; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for your subscription.'); window.location = 'index.php'; </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('Message failed. Please, send an email to studio@'); window.location = 'index.php'; </script> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/279348-email-subscription-not-showing-name-and-email/ Share on other sites More sharing options...
cyberRobot Posted June 19, 2013 Share Posted June 19, 2013 Have you tried dumping the POST variables to see if they contain what you expect? For example: <?php $field_name = $_POST['cf_name']; $field_email = $_POST['cf_email']; var_dump($_POST['cf_name']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/279348-email-subscription-not-showing-name-and-email/#findComment-1436820 Share on other sites More sharing options...
carter90 Posted June 19, 2013 Author Share Posted June 19, 2013 Thanks for the reply, I have just tried this and it has come back with NULL so i'm assuming I have definitely gone wrong somewhere? Quote Link to comment https://forums.phpfreaks.com/topic/279348-email-subscription-not-showing-name-and-email/#findComment-1436827 Share on other sites More sharing options...
cyberRobot Posted June 19, 2013 Share Posted June 19, 2013 Hmm...that means the POST variable isn't even being set. Is the form being submitted to the script mentioned in the original post? If so, you should at least get an empty string. string(0) "" What does your form code look like? Quote Link to comment https://forums.phpfreaks.com/topic/279348-email-subscription-not-showing-name-and-email/#findComment-1436848 Share on other sites More sharing options...
carter90 Posted June 25, 2013 Author Share Posted June 25, 2013 Sorry for the late reply. Yes that is what I thought. My form code looks ok as far as I know though: <form action="http:///contact.php" method="post"> <div align="left"> <p><span class="style3">Your name</span>:<span style="text-align: right"></span><br> <input name="cf_name" type="text" style="width:160px" value="" size="25"> <br> <span class="style3">Your e-mail</span>:<br> <input name="cf_email" type="text" style="width:160px" size="25"> </p> <p><br><input name="submit" type="submit" value="Send"> <span style="text-align: right"></span></p> </div> </form> The contact.php is in the correct place as well otherwise I wouldn't get the emails coming through just no values which is very annoying. Quote Link to comment https://forums.phpfreaks.com/topic/279348-email-subscription-not-showing-name-and-email/#findComment-1437754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.