binarygirl Posted April 17, 2008 Share Posted April 17, 2008 hi there.. I have a very basic form that is not working.. can someone please help. I have both the thankyou.html and the error.html files on the server so they are not missing. Basic form.. name, phone, email and message. here is the HTML: <form method="post" action="sendmail.php"> <p> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">name*</font><br> <input name="name" type="text" id="name"> <br> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">phone*</font><br> <input name="phone" type="text" id="phone"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"> <br> email*</font> <br> <input name="email" type="text" id="email"> <br> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">questions/comments</font><br> <textarea name="message" cols="35" rows="7" id="message"></textarea> <br> <input type="submit" name="Submit" value="send"></form> </p> and here is the sendmail.php <? if (empty($email) || empty($name) || empty($phone)) { header( "Location: error.html" ); } else { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_REQUEST['name']) ; $message = stripslashes($_REQUEST['message']) ; $email = stripslashes($_REQUEST['email']) ; $phone = stripslashes($_REQUEST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); header( "Location: thankyou.html" ); } ?> It should send me an email, them and email and give an error if they dont fill out name, phone & email fields... What am I doing wrong?? ((( soooooooo frustrating - can someone please help? Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/ Share on other sites More sharing options...
benphp Posted April 17, 2008 Share Posted April 17, 2008 Where are your $_POST's? To be more specific, you need to define your $email, $name, etc: if (empty($_POST['email']l) || empty($_POST['name']) || empty($_POST['phone']) or <?php if (isset($_POST['Submit'])) { $email = $_POST['email']); $name = $_POST['name']); $phone = $_POST['phone']); } --then run your code. Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519171 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 try this: <?php if (empty($email) ||empty($name)||empty($phone)||!isset($phone)||!isset($name)||!isset($email)) { header( "Location: error.html" ); } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); header( "Location: thankyou.html" ); } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519172 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 wow... thanks for the incredibly FAST responses.. will try it Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519174 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 progress... if I leave a field blank I get my error page... but when I fill them all in I still get my error page and submit. Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519175 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 I tried darkfreak's and I couldn't get past the error page.. just saw your's ben.. maybe I copied it wrong or missed something in the paste... but I get a blank page again... this is my first form.. can ya tell ? I copied it from another source and have just been trying to alter it to fit what I need. Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519179 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 mine is correct. i think it is because you are using multiple headers Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519180 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 Not working... all I get is a blank page. Fields filled in or not. <?php if (isset($_POST['Submit'])) { $email = $_POST['email']); $name = $_POST['name']); $phone = $_POST['phone']); } if (empty($email) || empty($name) || empty($phone)) { header( "Location: error.html" ); } else { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_REQUEST['name']) ; $message = stripslashes($_REQUEST['message']) ; $email = stripslashes($_REQUEST['email']) ; $phone = stripslashes($_REQUEST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); header( "Location: thankyou.html" ); } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519184 Share on other sites More sharing options...
benphp Posted April 17, 2008 Share Posted April 17, 2008 I don't have a server to test it, but try: <form method="post" action="sendmail.php"> <p> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">name*</font> <input name="name" type="text" id="name"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">phone*</font> <input name="phone" type="text" id="phone"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">email*</font> <input name="email" type="text" id="email"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">questions/comments</font> <textarea name="message" cols="35" rows="7" id="message"></textarea> <input type="submit" name="btnSubmit" value="send"></form> </p> <?php if (isset($_POST['btnSubmit'])) { $name = stripslashes($_POST['name'])); $phone = stripslashes($_POST['phone'])); $email = stripslashes($_POST['email'])); $message = stripslashes($_POST['message'])); } if (empty($name) || empty($phone) || empty($email) || empty($message)) { header( "Location: error.html" ); } else { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); header( "Location: thankyou.html" ); } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519188 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 Try now: <?php if (empty($email) ||empty($name)||empty($phone)||!isset($phone)||!isset($name)||!isset($email)) { header( "Location: error.html" ); exit; } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); header( "Location: thankyou.html" ); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519189 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 ahh I see the exit... but the same thing darkfreaks... i fill in all fields and the error page is still up. error.html is the same as the form html. just added the text, please complete required fields. Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519191 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 thank you so much for helping by the way... so appreciate it. Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519192 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 try echoing the thank you message instead of having it redirect to another page <?php if (empty($email) ||empty($name)||empty($phone)||!isset($phone)||!isset($name)||!isset($email)) { header( "Location: error.html" ); } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); echo " Thank You for signing up!"; } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519194 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 boo. ??? :'( Tried it .. Nope, my error page still comes up.. even if all fields are entered Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519196 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 you are using post data instead of request you said it worked earlier? try taking out the exit Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519197 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 I am just copying and pasting your code DFs... you took out the exits... I don't get past the error.html never have. I would rather use the thankyou.html that a blank page with thank you. Sorry.. I thought it was an easy question :-\ (I tried yours too Ben.. just saw that post .. it didnt work either I got the blank (sendmail.php) page again thanls though appreciate your time ) Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519200 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 if it were up to me id get rid of the headers and echo everything Try: <?php if (empty($email) ||empty($name)||empty($phone)||!isset($phone)||!isset($name)||!isset($email)) { echo "Please Fill in the form!"; } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); echo " Thank You for signing up!"; } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519202 Share on other sites More sharing options...
benphp Posted April 17, 2008 Share Posted April 17, 2008 Try starting simple, get it to work, then add the rest of your code: oh and don't forget to change the name of your form submit button to btnSubmit <?php if (isset($_POST['btnSubmit'])) { $name = stripslashes($_POST['name'])); $phone = stripslashes($_POST['phone'])); $email = stripslashes($_POST['email'])); $message = stripslashes($_POST['message'])); if (empty($name)) { print "error"; //header( "Location: error.html" ); } else { print "thank you"; //header( "Location: thankyou.html" ); } //if empty } //if isset ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519204 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 ^ bingo Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519206 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 same thing DFs... the form is not submitting... i am stuck at the echo now "please fill in the form" instead of the error.html header Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519207 Share on other sites More sharing options...
darkfreaks Posted April 17, 2008 Share Posted April 17, 2008 then your post data is either empty ot not submitted Modified: <?php if (empty($email) ||empty($name)||empty($phone)) { echo "Please Fill in the form!"; } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); echo " Thank You for signing up!"; } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519208 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 its not working guys.. I am lost. All I wanted was name, phone, email and message to be sent to me... error.html if name, phone and email were blank.. and thank you when they click submit... I found a script that was name, subject, email and message.. and changed subject to phone... I think this is over my head. this is my HTML which I think is fine... <form method="post" action="sendmail.php"> <p> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">name*</font><br> <input name="name" type="text" id="name"> <br> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">phone*</font><br> <input name="phone" type="text" id="phone"> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2"><br> email*</font> <br> <input name="email" type="text" id="email"> <br> <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" size="2">questions/comments</font><br> <textarea name="message" cols="35" rows="7" id="message"></textarea> <br> <input type="submit" name="Submit" value="send"></form> and this is my php from DKs.. which I like.. because it does display the error.html if I leave a field blank.. but it will not pull the trigger and submit to me when I fill it all in... waaaa <?php if (empty($email) ||empty($name)||empty($phone)||!isset($phone)||!isset($name)||!isset($email)) { header( "Location: error.html" ); exit; } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); header( "Location: thankyou.html" ); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519212 Share on other sites More sharing options...
benphp Posted April 17, 2008 Share Posted April 17, 2008 You need to declare you variables before DF's code: put this in above his: $name = stripslashes($_POST['name'])); $phone = stripslashes($_POST['phone'])); $email = stripslashes($_POST['email'])); $message = stripslashes($_POST['message'])); Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519213 Share on other sites More sharing options...
moon 111 Posted April 17, 2008 Share Posted April 17, 2008 OK, I see an obvious mistake. You need to set $email, $name etc. at the beginning: <?php $name = stripslashes($_POST['name']) ; $message = stripslashes($_POST['message']) ; $email = stripslashes($_POST['email']) ; $phone = stripslashes($_POST['phone']) ; if (empty($email) ||empty($name)||empty($phone)) { echo "Please Fill in the form!"; } else if(!empty($name)||!empty($email)||!empty($phone)||isset($name)||isset($phone)||isset($email)) { //mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] ) $admin = '[email protected]' ; mail( $admin, "Feedback: $name", "Name: $name\nPhone: $phone\nEmail: $email\n\n$message", "From: $name <$email>" ); $subject = 'Online Inquiry'; $replymsg = 'Thank you for your email inquiry. One of our staff will respond shortly.' ; mail( $email, $subject, $replymsg , "From: $admin" ); echo " Thank You for signing up!"; } ?> Aww, ben, you beat me to it! Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519215 Share on other sites More sharing options...
binarygirl Posted April 17, 2008 Author Share Posted April 17, 2008 YAY.. thanks moon... I am so excited.. it worked. I put the html headers back in too.. thank you thank you thank you now.. haha.. is there anything else I should consider.. security... email checking.. or is it ok as is? Thank you all. Link to comment https://forums.phpfreaks.com/topic/101500-solved-super-easy-question-please-help/#findComment-519225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.