kcotter Posted May 12, 2009 Share Posted May 12, 2009 I'm trying to make a simple email form... 7 fields... name, email, etc... I want it to send an email to me.. Which it does... but I want that email to be readable.. and normal.. as in, 7 lines... Name: my name Email: my email Address: 123 nowhere etc.... Apparently this is impossible for me to figure out.. I know these files are messed up... I joined this forum so I can learn more about PHP. this is my first question... don't have time to read a book tonight.. please help!!!!!!!!!!!!! thanks! Oh.. and my next problem (that I gave up on hours ago) is making at least the name, and email fields required... couldn't get that to work either... the simple files I'm working with are attached... thanks for any help!!!! thanks, kal [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/ Share on other sites More sharing options...
Ken2k7 Posted May 12, 2009 Share Posted May 12, 2009 Welcome to PHP Freaks! Rather than attaching the files, which no one will bother downloading and then viewing, just post them via tags. To add new line breaks in email, I believe you can use "\n". Have you tried that? Of course I haven't viewed your scripts. And to make the fields required, just check for them and if they are empty, then display an error message. Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832181 Share on other sites More sharing options...
kcotter Posted May 12, 2009 Author Share Posted May 12, 2009 I've tried the "/n" , and checking if they were empty.. I just can't figure it out, I've download multiple codes and tried them.. Here's the code in question: form.php __________________________ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <form method="Post" action="send.php"> <table border="0" cellpadding="0" cellspacing="5" width="377"> <tr> <td width="74">Name*</td> <td width="299"><input type="text" name="name" size="20"></td> </tr> <tr> <td width="74">Email*</td> <td width="299"><input type="text" name="email" size="20"></td> </tr> <tr> <td width="74">Address</td> <td width="299"><input type="text" name="address" size="40"></td> </tr> <tr> <td width="74">City</td> <td width="299"><input type="text" name="city" cols="20"></td> </tr> <tr> <td width="74">State</td> <td width="299"><input type="text" name="state" cols="20"></td> </tr> <tr> <td width="74">Zip Code</td> <td width="299"><input type="text" name="zip" cols="10"></td> </tr> <tr> <td width="74">How did you hear about us?</td> <td width="299"><input type="text" name="hear" cols="10"></td> </tr> <tr> <td width="74"></td> <td width="299"><input type=submit value="Submit"></td> </tr> </table> </form> </body> </html> _______________________ send.php -------------------------- <? PRINT "Thank you $name for registering to win!"; $name = "Name: ".$_REQUEST['name']. $name = "Email: ".$_REQUEST['email']. $name = "Address: ".$_REQUEST['address']. $name = "City: ".$_REQUEST['city']. $name = "State: ".$_REQUEST['state']. $name = "zip: ".$_REQUEST['zip']. $name = "How they heard about us: ".$_REQUEST['hear']; mail("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832300 Share on other sites More sharing options...
jackpf Posted May 12, 2009 Share Posted May 12, 2009 It's "\n" not "/n". Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832301 Share on other sites More sharing options...
kcotter Posted May 12, 2009 Author Share Posted May 12, 2009 When I tried it, I actually cut and pasted it from online I think... so I think I had it right... but I'll try again... where exactly does it go... are all those dots (.) necessary? I'm sure I have this messed up... Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832302 Share on other sites More sharing options...
Adam Posted May 12, 2009 Share Posted May 12, 2009 Try this: $name = "Name: ".$_REQUEST['name']."\n" ."Email: ".$_REQUEST['email']."\n" ."Address: ".$_REQUEST['address']."\n" ."City: ".$_REQUEST['city']."\n" ."State: ".$_REQUEST['state']."\n" ."Zip: ".$_REQUEST['zip']."\n" ."How they heard about us: ".$_REQUEST['hear']; Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832306 Share on other sites More sharing options...
kcotter Posted May 12, 2009 Author Share Posted May 12, 2009 Holy cow!!! you made that too easy!!! Thank you soooo much for your help!!! any chance making the first two (name, email) required is that easy??? Email doesn't have to validate... just check if it's empty... I had an if statement I was playing with, but it kept stopping at the first print (or echo) no matter what the text box had in it.... Thanks for your help.. this forum rocks! Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832313 Share on other sites More sharing options...
Adam Posted May 12, 2009 Share Posted May 12, 2009 Add something like: if (empty($_REQUEST['name']) || empty($_REQUEST['email'])) { die('Enter name and email...'); } Before creating the $name var. .... or better yet: <?php print "Thank you $name for registering to win!"; if (empty($_REQUEST['name']) || empty($_REQUEST['email'])) { print 'Enter name and email...'; } else { $name = "Name: ".$_REQUEST['name']."\n" ."Email: ".$_REQUEST['email']."\n" ."Address: ".$_REQUEST['address']."\n" ."City: ".$_REQUEST['city']."\n" ."State: ".$_REQUEST['state']."\n" ."Zip: ".$_REQUEST['zip']."\n" ."How they heard about us: ".$_REQUEST['hear']; mail("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832315 Share on other sites More sharing options...
kcotter Posted May 12, 2009 Author Share Posted May 12, 2009 This is perfect. Thanks a lot for your help, I really appreciate it!!! One more questions... this might be harder I'm not sure.. in my email, when I get the email that says someone signed up, and here's their info... the "from" email is this... BuyWithoutDebt@p3slh142.shr.phx3.secureserver.net is it possible to make that smaller... or just make it say, BuyWithoutDebt? Just curious... Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832320 Share on other sites More sharing options...
Adam Posted May 12, 2009 Share Posted May 12, 2009 Looking at your mail function: mail("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt"); It's probably safer in that respect to use an email for the "From:" header, and also add a reply-to email address (even if it's noreply@...) - this may stop the long ugly email address showing. Something like: mail("kalcotter1@yahoo.com", "Someone Registered at BuyWithoutDebt", $name, "From: BuyWithoutDebt@example.com\r\nReply-To: noreply@example.com\r\n"); Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832323 Share on other sites More sharing options...
kcotter Posted May 12, 2009 Author Share Posted May 12, 2009 that works great. Thanks a lot for all your help!!!! this would've taken me hours... Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832339 Share on other sites More sharing options...
Adam Posted May 12, 2009 Share Posted May 12, 2009 Any time, just mark the topic as solved if all your issues have been... solved. Quote Link to comment https://forums.phpfreaks.com/topic/157775-solved-simple-4-u-im-new-going-to-scream/#findComment-832346 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.