madox Posted October 1, 2008 Share Posted October 1, 2008 Guys, The below code works, but I tried to add a phone number to the code and it doesn't work. Here is the form code <form method="post" action="sendeail.php"> <!-- DO NOT change ANY of the php sections --> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> Your Name: <br /> <input type="text" name="visitor" size="35" /> <br /> Your Email:<br /> <input type="text" name="visitormail" size="35" /> <br /> <br /> <br /> Attention:<br /> <select name="attn" size="1"> <option value=" Sales n Billing ">Sales n Billing </option> <option value=" General Support ">General Support </option> <option value=" Technical Support ">Technical Support </option> <option value=" Webmaster ">Webmaster </option> </select> <br /><br /> Mail Message: <br /> <textarea name="notes" rows="4" cols="40"></textarea> <br /> <input type="submit" value="Send Mail" /> <br /> </form> Here is the php code. to send on the email <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sendemail Script</title> </head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "<h2>Use Back - fill in all fields</h2>\n"; die ("Use back! ! "); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; mail("my e-mail address", $subject, $message, $from); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br /> Attention: <?php echo $attn ?> <br /> Message:<br /> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?> <br /> <?php echo $ip ?> <br /><br /> <a href="index.html"> Next Page </a> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/ Share on other sites More sharing options...
DeanWhitehouse Posted October 1, 2008 Share Posted October 1, 2008 where are you trying to add the number? Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-654993 Share on other sites More sharing options...
AV1611 Posted October 1, 2008 Share Posted October 1, 2008 your question doesn't seem to be in the code. post the revised code with the phone number part you added Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-654994 Share on other sites More sharing options...
madox Posted October 1, 2008 Author Share Posted October 1, 2008 Here is the code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Email Form </title> </head> <body> <form method="post" action="sendeail.php"> <!-- DO NOT change ANY of the php sections --> <?php $ipi = getenv("REMOTE_ADDR"); $httprefi = getenv ("HTTP_REFERER"); $httpagenti = getenv ("HTTP_USER_AGENT"); ?> <input type="hidden" name="ip" value="<?php echo $ipi ?>" /> <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" /> <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" /> Your Name: <br /> <input type="text" name="visitor" size="35" /> <br /> Your Email:<br /> <input type="text" name="visitormail" size="35" /> <br /> Your phone number:<br /> <input type="text" name="phone" size="35" /> <br /> <br /> Attention:<br /> <select name="attn" size="1"> <option value=" Sales n Billing ">Sales n Billing </option> <option value=" General Support ">General Support </option> <option value=" Technical Support ">Technical Support </option> <option value=" Webmaster ">Webmaster </option> </select> <br /><br /> Mail Message: <br /> <textarea name="notes" rows="4" cols="40"></textarea> <br /> <input type="submit" value="Send Mail" /> <br /> </form> </body> </html> my php code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sendemail Script</title> </head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; $phone = $_POST['phone']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "<h2>Use Back - fill in all fields</h2>\n"; die ("Use back! ! "); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n "; $from = "From: $visitormail\r\n"; mail("email address", $subject, $message, $from, $phone); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br /> Attention: <?php echo $attn ?> <br /> Message:<br /> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?> <br /> <?php echo $ip ?> <br /><br /> <a href="index.html"> Next Page </a> </p> </body> </html> It will not send out all the information Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-654998 Share on other sites More sharing options...
madox Posted October 1, 2008 Author Share Posted October 1, 2008 Yes. I wanted the phone number to also be sent. Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655000 Share on other sites More sharing options...
dropfaith Posted October 1, 2008 Share Posted October 1, 2008 also this may only be my personal preference but using <br> to seperate form fields isnt your best bet use labels and wrap them in <p></p> tags what is it sending? any errors? Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655003 Share on other sites More sharing options...
dropfaith Posted October 1, 2008 Share Posted October 1, 2008 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sendemail Script</title> </head> <body> <!-- Reminder: Add the link for the 'next page' (at the bottom) --> <!-- Reminder: Change 'YourEmail' to Your real email --> <?php $ip = $_POST['ip']; $httpref = $_POST['httpref']; $httpagent = $_POST['httpagent']; $visitor = $_POST['visitor']; $visitormail = $_POST['visitormail']; $notes = $_POST['notes']; $attn = $_POST['attn']; $phone = $_POST['phone']; if (eregi('http:', $notes)) { die ("Do NOT try that! ! "); } if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) { echo "<h2>Use Back - Enter valid e-mail</h2>\n"; $badinput = "<h2>Feedback was NOT submitted</h2>\n"; echo $badinput; die ("Go back! ! "); } if(empty($visitor) || empty($visitormail) || empty($notes )) { echo "<h2>Use Back - fill in all fields</h2>\n"; die ("Use back! ! "); } $todayis = date("l, F j, Y, g:i a") ; $attn = $attn ; $subject = $attn; $notes = stripcslashes($notes); $message = " $todayis [EST] \n Attention: $attn \n Message: $notes \n From: $visitor ($visitormail)\n Additional Info : IP = $ip \n Browser Info: $httpagent \n Referral : $httpref \n Phone: $phone \n "; $from = "From: $visitormail\r\n"; mail("email address", $subject, $message, $from); ?> <p align="center"> Date: <?php echo $todayis ?> <br /> Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) <br /> Attention: <?php echo $attn ?> <br /> Message:<br /> <?php $notesout = str_replace("\r", "<br/>", $notes); echo $notesout; ?> <br /> <?php echo $ip ?> <br /><br /> <a href="index.html"> Next Page </a> </p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655007 Share on other sites More sharing options...
DeanWhitehouse Posted October 1, 2008 Share Posted October 1, 2008 wtf? mail("email address", $subject, $message, $from, $phone); mail(To,Subject,Message,Additional Headers); Nothing else allowed, try putting the $phone in the $message Edit: Beat me to it, but use code tags This will help http://uk2.php.net/function.mail Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655009 Share on other sites More sharing options...
KevinM1 Posted October 1, 2008 Share Posted October 1, 2008 You need to add the phone number to the mail message rather than as an extra parameter to the mail() function. In otherwords: $message .= "Phone number: $phone"; mail("email_address", $subject, $message); Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655010 Share on other sites More sharing options...
dropfaith Posted October 1, 2008 Share Posted October 1, 2008 yea i messed them up cause i needed to recopy my code and forgot to re add the tags edited now Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655016 Share on other sites More sharing options...
madox Posted October 1, 2008 Author Share Posted October 1, 2008 Thanks it worked. Quote Link to comment https://forums.phpfreaks.com/topic/126657-solved-help-please-add-phone-number-to-the-code-to-work/#findComment-655032 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.