websime Posted January 29, 2008 Share Posted January 29, 2008 Hey guys, The curious thing about this situation is that I am using virtually the same code (html, css, and php) on a contact form for another site and it works perfectly. For some reason, I can't seem to get it to work on this site: http://www.namastenutrition.net/form.htm The form loads fine and it is accessing the php file, but everytime I fill it out and click submit, it loads the error2.html page and does not email me the information. Any help would be most appreciated!!! HTML: <form id="myform" class="cssform" method="POST" action="php/contact.php"> <fieldset> <legend>To contact me, simply fill out this form!</legend> <p> <label for="user">Name</label> <input type="text" id="user" name="Name" value="" /> </p> <p> <label for="phonenumber">Phone Number:</label> <input type="text" id="phonenumber" name="Phonenumber" value="" /> </p> <p> <label for="emailaddress">Email Address:</label> <input type="text" id="emailaddress" name="Email" value="" /> </p> <p> <label for="regarding">Regarding:</label> <input type="text" id="regarding" name="Regarding" value="" /> </p> <p> <label for="comments">Questions or Comments:</label> <textarea id="comments" name="Comments" rows="5" cols="25"></textarea> </p> <div style="margin-left: 150px;"> <input type="submit" name="submit" value="Submit" class="submit"> <input type="reset" name="clear" value="Clear" class="clear"> </div> </fieldset> </form> PHP: <?php // get posted data into local variables $Email = Trim(stripslashes($_POST['Email'])); $EmailTo = "bentsime@gmail.com"; $Subject = "User Contact - Contact Page"; $Name = Trim(stripslashes($_POST['Name'])); $Phonenumber = Trim(stripslashes($_POST['Phonenumber'])); $Regarding = Trim(stripslashes($_POST['Regarding'])); $Comments = Trim(stripslashes($_POST['Comments'])); // validation $validationOK=true; if (Trim($Email)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Comments)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../error2.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Phonenumber: "; $Body .= $Phonenumber; $Body .= "\n"; $Body .= "Regarding: "; $Body .= $Regarding; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../thanks2.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../error2.html\">"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/ Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 Have you tried echoing all 3 of the variables to make sure they are not empty? Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-452470 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 repalce $success = mail($EmailTo, $Subject, $Body, "From: <$Email>"); with $success = mail($EmailTo, $Subject, $Body, "From: <".$Email.">"); php will think its $email> instead of $email had that problem once lool Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-452471 Share on other sites More sharing options...
revraz Posted January 29, 2008 Share Posted January 29, 2008 Since you call error2 in two different places, first identify which one is triggering it. Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-452476 Share on other sites More sharing options...
websime Posted January 29, 2008 Author Share Posted January 29, 2008 Thanks to all 3 of you for your quick replies! I replaced that $success = mail($EmailTo, $Subject, $Body, "From: <".$Email.">"); and I changed the first error to error1.html... result: error2.html is triggered. as for echo'ing the 3 variables to make sure they are not empty...unfortunately I have no clue what that means! Care to enlighten me? html code is the same here is the new php <?php // get posted data into local variables $Email = Trim(stripslashes($_POST['Email'])); $EmailTo = "bentsime@gmail.com"; $Subject = "User Contact - Contact Page"; $Name = Trim(stripslashes($_POST['Name'])); $Phonenumber = Trim(stripslashes($_POST['Phonenumber'])); $Regarding = Trim(stripslashes($_POST['Regarding'])); $Comments = Trim(stripslashes($_POST['Comments'])); // validation $validationOK=true; if (Trim($Email)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (Trim($Comments)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=../error1.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "Phonenumber: "; $Body .= $Phonenumber; $Body .= "\n"; $Body .= "Regarding: "; $Body .= $Regarding; $Body .= "\n"; $Body .= "Comments: "; $Body .= $Comments; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <".$Email.">"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=../thanks2.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=../error2.html\">"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-452486 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 basically its like: if(empty($_reguest['email']){ echo 'sorry email was left empty'; } else{ } Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-452492 Share on other sites More sharing options...
valtido Posted January 29, 2008 Share Posted January 29, 2008 basically its like: if(empty($_reguest['email']){ echo 'sorry email was left empty'; } else{ } but he said he is filling up the form loool so it cnt be empty well check this link out and re write your coding loool http://www.w3schools.com/php/php_mail.asp hope it helps sorry i posted it accidently twice coz some error lool PS Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-452494 Share on other sites More sharing options...
websime Posted January 30, 2008 Author Share Posted January 30, 2008 okay here's some easy questions: 1. what is looool?? 2. Does anyone know if GoDaddy supports php? I am diggin thru my client's account and don't see it stated anywhere that they do. 3. They DO support asp. Can anyone point me to a site where I can get a simple asp mail script and learn more about it? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-453368 Share on other sites More sharing options...
revraz Posted January 30, 2008 Share Posted January 30, 2008 1. I guess a strange way of saying "lol" 2. I'm sure they do, but may depend on what package you have. You should ask them. 3. Google Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-453374 Share on other sites More sharing options...
websime Posted January 30, 2008 Author Share Posted January 30, 2008 Thanks! and how about a good book to pick up for first-time php guy. Only code experience I have is html and css at this point... Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-453404 Share on other sites More sharing options...
revraz Posted January 30, 2008 Share Posted January 30, 2008 Just search amazon.com for php and mysql (if you want to learn both). Just make sure you get the latest edition of whatever book you get. PHP5 and MySQL 5 would be the ones to look for. Quote Link to comment https://forums.phpfreaks.com/topic/88412-simple-php-contact-form-problems-with-code/#findComment-453406 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.