pehlavoon Posted February 9, 2011 Share Posted February 9, 2011 Here is my sendmail.php code: <?php //capture form data in name/value structure //ie. fName = "Pouya" $fNameVar = $_POST['fName']; $lNameVar = $_POST['lName']; $emailVar = $_POST['email']; $commentVar = $_POST['comment']; $telVar = $_POST['tel']; //echo "First Name is {$fNameVar}, last name is {$lNameVar}, email is {$emailVar} and comment is {$commentVar}"; // The e-mail function requires 3 types of info // A. Destination e-mail // B. Subject line // C. Body of your message // D. E-mail of sender mail("puya.turkiyan@gmail.com", "Message from my New Media Sources", $commentVar, "From:$emailVar"); //echo "Thank you $fNameVar" header("Location:thankyou.php"); ?> In the mail section I can only send 2 variables. As soon as I add the third it doesn't even send anything to my e-mail. Please help, its driving me crazy. Here is my table page: <?php include "header.html"; ?> <div id="templatemo_menu"> <ul> <li><a href="index.php">Home</a></li> <li><a href="about.php">About Us</a></li> <li><a href="services.php">Services</a></li> <li><a href="gallery.php">Gallery</a></li> <li><a href="#">Blog</a></li> <li><a href="contact.php" class="current">Contact Us</a></li> </ul> </div> <!-- end of templatemo_menu --> <?php include "socialmedia.html"; ?> <div class="cleaner"></div> </div> <div class="cleaner"></div> </div> <!-- end of header --> </div> <!-- end of header_wrapper --> <div id="templatemo_content_wrapper"> <div id="templatemo_content"> <h1>Contact Information</h1> <p>Here are a few ways to get a hold of us. The best way would be e-mail or phone but you can also use other methods such as <a href="http://www.twitter.com/pehlavoon"><img src="images/twitter-1.png" alt="twitter" width="30" height="30"/> </a> or <a href="http://www.facebook.com/puya.turkiyan"><img src="images/facebook-1.png" alt="facebook" width="30" height="30"/></a> to contact us.</p> <div class="cleaner_h50"></div> <div class="two_column float_l"> <div id="contact_form"> <h2>Contact Form</h2> <fieldset> <legend>Contact me</legend> <form action="sendmail.php" method="post"> <ul> <li><label for="fName">First Name: </label> <input type="text" name="fName" value="" id="fName" /></li> <li><label for="lName">Last Name: </label> <input type="text" name="lName" value="" id="lName" /></li> <li><label for="email">E-mail: </label> <input type="text" name="email" value="" id="email" /></li> <li><label for="tel">Phone number: </label> <input type="text" name="tel" value="" id="tel" /></li> <li><label for="comment">comment: </label> <textarea cols="5" rows="5" name="comment" id="comment"></textarea></li> <li><input type="submit" value="Send" /></li> </ul> </form> </fieldset> </div> </div> <div class="two_column float_r"> <h6>Contact our development team:</h6> Located in Vancouver Canada<br /> <strong>Email:</strong> <a href="mailto:puya.turkiyan@gmail.com">puya.turkiyan@gmail.com</a> <p><strong>Phone:</strong> 1+778-991-7892</p> <div class="cleaner_h60"></div> <h6>Contact our Account manager</h6> Located in Downtown Vancouver Canada<br /> <strong>Email:</strong> <a href="mailto:richardboulier@gmail.com">richardboulier@gmail.com</a> <p><strong>Phone:</strong> 1+778-230-1084</p> </div> <div class="cleaner"></div> </div> <!-- end of content --> </div> <!-- end of content_wrapper --> <?php include "footer.html"; ?> Take a look and see if you can help me. Quote Link to comment https://forums.phpfreaks.com/topic/227209-my-sendmailphp-only-sends-2-variables/ Share on other sites More sharing options...
Maq Posted February 9, 2011 Share Posted February 9, 2011 Show us the troubled code where you are trying to send more than 2 variables. Quote Link to comment https://forums.phpfreaks.com/topic/227209-my-sendmailphp-only-sends-2-variables/#findComment-1172013 Share on other sites More sharing options...
pehlavoon Posted February 9, 2011 Author Share Posted February 9, 2011 The code below works. mail("puya.turkiyan@gmail.com", "Message from my New Media Sources", $commentVar, $lNameVar, "From:$emailVar"); The code below does not. You can mix and match the variables after "Message from my New Media Sources". It won't work. mail("puya.turkiyan@gmail.com", "Message from my New Media Sources", $commentVar, $lNamevar, $fNamVar, "From:$emailVar"); Quote Link to comment https://forums.phpfreaks.com/topic/227209-my-sendmailphp-only-sends-2-variables/#findComment-1172016 Share on other sites More sharing options...
pehlavoon Posted February 9, 2011 Author Share Posted February 9, 2011 Show us the troubles code where you are trying to send more than 2 variables. I wrote the issue above this message Quote Link to comment https://forums.phpfreaks.com/topic/227209-my-sendmailphp-only-sends-2-variables/#findComment-1172019 Share on other sites More sharing options...
kenrbnsn Posted February 9, 2011 Share Posted February 9, 2011 The format of the mail function is <?php mail($to,$subject,$body,$headers,$optional_headers); ?> You should be putting all your variables values into the body of the email message. Something like: <?php $body = ''; $body .= "$commentVar\n"; $body .= "$INameVar\n"; $body .= "$fNameVar\n"; mail("puya.turkiyan@gmail.com", "Message from my New Media Sources",$body,"From:$emailVar"); ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/227209-my-sendmailphp-only-sends-2-variables/#findComment-1172020 Share on other sites More sharing options...
pehlavoon Posted February 9, 2011 Author Share Posted February 9, 2011 The format of the mail function is <?php mail($to,$subject,$body,$headers,$optional_headers); ?> You should be putting all your variables values into the body of the email message. Something like: <?php $body = ''; $body .= "$commentVar\n"; $body .= "$INameVar\n"; $body .= "$fNameVar\n"; mail("puya.turkiyan@gmail.com", "Message from my New Media Sources",$body,"From:$emailVar"); ?> Ken Thank you Ken, I am actually really new to PHP. I tried your way but couldn't seem to figure it out. Could you please tell how to go about this in detail. Thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/227209-my-sendmailphp-only-sends-2-variables/#findComment-1172031 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.