tkowebworks Posted November 9, 2010 Share Posted November 9, 2010 Hello, I am writing my first php script (of course) and it works except it only shows 4 variables. Example I have it to send me: mail($myemail, $fullname, $email, $message, $phone); But it will only send me the first four no matter what order they are in. It's driving me crazy. I can't think or find any reason why it would do this. If I change it to mail($myemail, $fullname, $email, $phone, $message); It will send me everything but $message if I change it to mail($myemail, $fullname, $message, $email, $phone ); It will send me everything but $phone Does anyone know why or what I need to change? I apologize if this sounds like a dumb question. I am very very new to php. Thank you for any guidance you can give. Here is the code: HTML: <form action="Contact.php" method="post" id="contact" name="contact" style="margin:0px";> <h2>Contact Form:</h2> <p>Fields marked (<span style="color:#F00;">*</span>) are required.</p> <p> <label for="text_fullname">Full Name<span style="color:#F00;">*</span>:</label> <input name="fullname" type="text" class="input" id="fullname" tabindex="1" /> <label for="text_email">Email<span style="color:#F00;">*</span>:</label> <input name="email" type="text" class="input" id="email" tabindex="2" /> <label for="text_phone">Phone:</label> <input name="phone" type="text" class="input" id="phone" tabindex="3" /> <label for="text_comments">Message/Comment:</label> <textarea name="message" cols="23" rows="3" class="input" id="message" tabindex="4"></textarea> <br> <div style="padding-left:200px;"> <button type="submit" id="send" name="send">Send!</button> <button type="reset">Reset</button> </div> </form> --------------------------------------- PHP: <?php /* Set e-mail recipient */ $myemail = "[email protected]"; $fullname = $_POST['fullname'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; mail($myemail, $fullname, $email, $message, $phone); header( "Location: http://www.ppm-oc.com/thankyou.html" ); ?> ---------------------------------- Thank you Link to comment https://forums.phpfreaks.com/topic/218155-email-will-only-show-4-variable-and-no-more/ Share on other sites More sharing options...
fortnox007 Posted November 9, 2010 Share Posted November 9, 2010 http://php.net/manual/en/function.mail.php You cant have a phone as a parameter. There is To Subject Message and (additional )headers Phone stuff and other variables are likely put in the message var Its should like this: <?php $to = '[email protected]'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/218155-email-will-only-show-4-variable-and-no-more/#findComment-1132032 Share on other sites More sharing options...
tkowebworks Posted November 9, 2010 Author Share Posted November 9, 2010 Thank you so much! I'll try that and let you know. I followed a couple of tutorials that I found and they were not very helpful. I appreciate your help! Link to comment https://forums.phpfreaks.com/topic/218155-email-will-only-show-4-variable-and-no-more/#findComment-1132098 Share on other sites More sharing options...
tkowebworks Posted November 9, 2010 Author Share Posted November 9, 2010 I tried it that way, but I couldn't get it to work. I changed my code to the below and it finally works, but I'm afraid I'm still doing it incorrectly. Here is what worked for me: I don't think I'm understanding the $headers . <?php $myemail = "[email protected]"; $fullname = $_POST['fullname'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; $msg = 'Name: '.$fullname."\n"; $msg .= 'Email: '.$email."\n"; $msg .= 'Phone: '.$phone."\n\n"; $msg .= 'Message: '.$message."\n"; mail($myemail, 'New message from contact form', $msg); header( "Location: http://www.ppm-oc.com/thankyou.html" ); ?> Link to comment https://forums.phpfreaks.com/topic/218155-email-will-only-show-4-variable-and-no-more/#findComment-1132117 Share on other sites More sharing options...
tkowebworks Posted November 9, 2010 Author Share Posted November 9, 2010 Hello, I am writing my first php script (of course) and it works except it only shows 4 variables. Example I have it to send me: mail($myemail, $fullname, $email, $message, $phone); But it will only send me the first four no matter what order they are in. It's driving me crazy. I can't think or find any reason why it would do this. If I change it to mail($myemail, $fullname, $email, $phone, $message); It will send me everything but $message if I change it to mail($myemail, $fullname, $message, $email, $phone ); It will send me everything but $phone Does anyone know why or what I need to change? I apologize if this sounds like a dumb question. I am very very new to php. Thank you for any guidance you can give. Here is the code: HTML: <form action="Contact.php" method="post" id="contact" name="contact" style="margin:0px";> <h2>Contact Form:</h2> <p>Fields marked (<span style="color:#F00;">*</span>) are required.</p> <p> <label for="text_fullname">Full Name<span style="color:#F00;">*</span>:</label> <input name="fullname" type="text" class="input" id="fullname" tabindex="1" /> <label for="text_email">Email<span style="color:#F00;">*</span>:</label> <input name="email" type="text" class="input" id="email" tabindex="2" /> <label for="text_phone">Phone:</label> <input name="phone" type="text" class="input" id="phone" tabindex="3" /> <label for="text_comments">Message/Comment:</label> <textarea name="message" cols="23" rows="3" class="input" id="message" tabindex="4"></textarea> <br> <div style="padding-left:200px;"> <button type="submit" id="send" name="send">Send!</button> <button type="reset">Reset</button> </div> </form> --------------------------------------- PHP: <?php /* Set e-mail recipient */ $myemail = "[email protected]"; $fullname = $_POST['fullname'] ; $email = $_POST['email'] ; $phone = $_POST['phone'] ; $message = $_POST['message'] ; mail($myemail, $fullname, $email, $message, $phone); header( "Location: http://www.ppm-oc.com/thankyou.html" ); ?> ---------------------------------- Thank you Link to comment https://forums.phpfreaks.com/topic/218155-email-will-only-show-4-variable-and-no-more/#findComment-1132130 Share on other sites More sharing options...
BlueSkyIS Posted November 9, 2010 Share Posted November 9, 2010 mail($to, $subject, $message, optional $headers); to: the email address to send the email to subject: the subject of the email message: the content of the email headers: optional content Link to comment https://forums.phpfreaks.com/topic/218155-email-will-only-show-4-variable-and-no-more/#findComment-1132133 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.