Boxerman Posted August 13, 2008 Share Posted August 13, 2008 Hi guys! i need help with this script, this is the code: <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = "Job Application" ; $firstname = $_REQUEST['firstname'] ; $lastname = $_REQUEST['lastname'] ; $age = $_REQUEST['age'] ; $reason = $_REQUEST['reason'] ; $timezone = $_REQUEST['timezone'] ; $times = $_REQUEST['times'] ; mail( "[email protected]", "Subject: $subject", $firstname, $lastname, $age, $reason, $timezone, $times, "From: $email" ); echo "Thank you for applying!, please allow upto 24 hours for reply!"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='djapp.php'> First Name: <input name='firstname' type='text' /><br /> Last Name: <input name='lastname' type='text' /><br /> Email: <input name='email' type='text' /><br /> Age: <input name='age' type='text' /><br /> Time Zone: <input name='timezone' type='text' /><br /> Times Can DJ: <input name='times' type='text' /><br /> Reason for applying:<br /> <textarea name='message' rows='10' cols='40' /> </textarea><br /> <input type='submit' /> </form>"; } ?> when sending i get this Warning: mail() expects at most 5 parameters, 9 given in /home/nonstopr/public_html/djapp.php on line 245 line 245 is in th e script above but to help the line is $firstname, $lastname, $age, $reason, $timezone, $times, "From: $email" ); thanks guys! Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/ Share on other sites More sharing options...
!jazz Posted August 13, 2008 Share Posted August 13, 2008 mail( "[email protected]", "Subject: $subject", $firstname, $lastname, $age, $reason, $timezone, $times, "From: $email" ); I think you're using the mail() function not correctly. PHP.NET <?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); ?> JaZz Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615367 Share on other sites More sharing options...
Boxerman Posted August 13, 2008 Author Share Posted August 13, 2008 ok im confused, do i need to declare $message then add the $firstname $lastname etc? Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615373 Share on other sites More sharing options...
void Posted August 13, 2008 Share Posted August 13, 2008 $message variable must include all the data you got there. e.g. $message = $name."\n".$lastname."\n".$age; .... !jazz showed you the proper use of mail() function. Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615380 Share on other sites More sharing options...
!jazz Posted August 13, 2008 Share Posted August 13, 2008 ok im confused, do i need to declare $message then add the $firstname $lastname etc? Like: <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = "Job Application" ; $firstname = $_REQUEST['firstname'] ; $lastname = $_REQUEST['lastname'] ; $age = $_REQUEST['age'] ; $reason = $_REQUEST['reason'] ; $timezone = $_REQUEST['timezone'] ; $times = $_REQUEST['times'] ; $to = $email; $subject = $subject; $message = $firstname."\n"; $message .= $lastname."\n"; $message .= $reason."\n"; $message .= $timezone."\n"; $message .= $times."\n"; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); echo "Thank you for applying!, please allow upto 24 hours for reply!"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='djapp.php'> First Name: <input name='firstname' type='text' /><br /> Last Name: <input name='lastname' type='text' /><br /> Email: <input name='email' type='text' /><br /> Age: <input name='age' type='text' /><br /> Time Zone: <input name='timezone' type='text' /><br /> Times Can DJ: <input name='times' type='text' /><br /> Reason for applying:<br /> <textarea name='message' rows='10' cols='40' /> </textarea><br /> <input type='submit' /> </form>"; } ?> JaZz Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615382 Share on other sites More sharing options...
Boxerman Posted August 13, 2008 Author Share Posted August 13, 2008 thanks, but i need it to send me a email at [email protected] Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615383 Share on other sites More sharing options...
Boxerman Posted August 13, 2008 Author Share Posted August 13, 2008 Ok that emails me but doesnt show all of the fields? <?php if (isset($_REQUEST['email'])) //if "email" is filled out, send email { //send email $email = $_REQUEST['email'] ; $subject = "Job Application" ; $firstname = $_REQUEST['firstname'] ; $lastname = $_REQUEST['lastname'] ; $email = $_REQUEST['email'] ; $age = $_REQUEST['age'] ; $reason = $_REQUEST['reason'] ; $timezone = $_REQUEST['timezone'] ; $times = $_REQUEST['times'] ; $to = "[email protected]"; $subject = $subject; $message = $firstname."\n"; $message .= $lastname."\n"; $message .= $email."\n"; $message .= $reason."\n"; $message .= $timezone."\n"; $message .= $times."\n"; $headers = 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); echo "Thank you for applying!, please allow upto 24 hours for reply!"; } else //if "email" is not filled out, display the form { echo "<form method='post' action='djapp.php'> First Name: <input name='firstname' type='text' /><br /> Last Name: <input name='lastname' type='text' /><br /> Email: <input name='email' type='text' /><br /> Age: <input name='age' type='text' /><br /> Time Zone: <input name='timezone' type='text' /><br /> Times Can DJ: <input name='times' type='text' /><br /> Reason for applying:<br /> <textarea name='message' rows='10' cols='40' /> </textarea><br /> <input type='submit' /> </form>"; } ?> Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615386 Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 try using $_POST instead of $_REQUEST i've attached an interesting email/form script maybe it will be of some kind of help. Let me know if you have any questions about it Cheers. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615390 Share on other sites More sharing options...
Boxerman Posted August 13, 2008 Author Share Posted August 13, 2008 that isnt a form i need, and when i try to change it all, theres errors everywhere? can any help with the last script i posted? thanks Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615405 Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 <?php if ($_POST['submit']==true) //if "email" is filled out, send email { //send email $email = $_POST['email'] ; $subject = "Job Application" ; $firstname = $_POST['firstname'] ; $lastname = $_POST['lastname'] ; $email = $_POST['email'] ; $age = $_POST['age'] ; $reason = $_POST['reason'] ; $timezone = $_POST['timezone'] ; $times = $_POST['times'] ; $to = "[email protected]"; $subject = $subject; $message .="\n"; $message .= $firstname."\n"; $message .= $lastname."\n"; $message .= $email."\n"; $message .= $reason."\n"; $message .= $timezone."\n"; $message .= $times."\n"; $headers ='From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); echo "Thank you for applying!, please allow upto 24 hours for reply!"; } else //if "email" is not filled out, display the form { echo "<form method='post' action=''djapp.php'> First Name: <input name='firstname' type='text' /><br /> Last Name: <input name='lastname' type='text' /><br /> Email: <input name='email' type='text' /><br /> Age: <input name='age' type='text' /><br /> Time Zone: <input name='timezone' type='text' /><br /> Times Can DJ: <input name='times' type='text' /><br /> Reason for applying:<br /> <textarea name='message' rows='10' cols='40' /> </textarea><br /> <input type='hidden' name='submit' value='true' /> <input type='submit' value='Submit' /> </form>"; } ?> I've tested it on my server and it works fine. HERE You needed to have a form (hidden value) that let the form know when to start sending... Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615419 Share on other sites More sharing options...
Boxerman Posted August 13, 2008 Author Share Posted August 13, 2008 the sending i havnt a problem with, its the fact that once its sent, 2 feilds are missing :S Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615471 Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 include this $message .= $age."\n"; $message .= $message."\n"; Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615473 Share on other sites More sharing options...
Boxerman Posted August 13, 2008 Author Share Posted August 13, 2008 Brill Thanks! can i echo anything? like $message .= "Age"$age."\n"; or somehting? so i can tell which field is which? Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615508 Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 sure! $message .= "Age: $age\n"; or keep the next line inticator separate to have a cleaner code: $message .= "\n"; \n is equivalent to br (just so you know) Happy Coding! LE: I'd really advise to take a look at the script i attached in the earlyer post... it will explane allot Link to comment https://forums.phpfreaks.com/topic/119458-php-form-error/#findComment-615691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.