blink359 Posted November 17, 2010 Share Posted November 17, 2010 Hi im trying to mix php and html in a form however when i do this the whole page disapears and i dont know why the working form is: http://valiantflight.comlu.com/emailer/contact.php <html> <head> <title>Contact Us</title> </head> <body> <fieldset> <legend>Contact Us</legend> <form action="contact.php" method="post"> <input type="hidden" name="frmsubmit"> Your Email:*<br> <input type="text" name="email"><br> Subject:*<br> <select name="subject"> <option value=""></option> <option value="1">Recruitment</option> <option value="2">Absense</option> <option value="3">Enquiry</option> </select> <br> Message:*<br> <textarea name="message" cols="50" rows="5"></textarea> <br> <?php require_once('recaptchalib.php'); $publickey = "6LeB8LwSAAAAAKwvC3HWJNwWw9vYiSEkvFEvDduD"; // you got this from the signup page echo recaptcha_get_html($publickey); ?> <br> <input name"Submit" type="submit" value="Send Email"> </form> Required fields are marked with a *<br><br> <?php if(isset($_POST['frmsubmit'])){ $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; //checcking that all relevent information is entered and correct require_once('recaptchalib.php'); $privatekey = "6LeB8LwSAAAAAA_0IIEnAxL5uOau0TBm83Iog7Ey"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if(!$message || !$email || !$subject) { $errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>"; } if (!$resp->is_valid) { $errmessage ="<font color='red'>The text entered does not match the picture provided.</font>"; } //Sending the email if nothing is wrong if(!$errmessage) { header("location:send.php?subject=".$subject."&email=".$email."&message=".$message.""); }else{ echo $errmessage; } } ?> </fieldset> <br><br><br> </body> </html> and the one that doesnt work is: http://valiantflight.comlu.com/emailer/test/contact.php <html> <head> <title>Contact Us</title> </head> <body> <fieldset> <legend>Contact Us</legend> <form action="contact.php" method="post"> <?php if(isset($_POST['frmsubmit'])){ $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; //checcking that all relevent information is entered and correct ?> <input type="hidden" name="frmsubmit"> Your Email:*<br> <input type="text" name="email"> <?php if(!$email) { $errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>"; echo("<font color='red'><br>Please enter your email.</font>"); } ?> <br> Subject:*<br> <select name="subject"> <option value=""></option> <option value="1">Recruitment</option> <option value="2">Absense</option> <option value="3">Enquiry</option> </select> <?php if(!$subject) { $errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>"; echo("<font color='red'><br>Please select a subject.</font>"); } ?> <br> Message:*<br> <textarea name="message" cols="50" rows="5"></textarea> <?php if(!$message) { $errmessage ="<font color='red'>The marked areas in the form have not been filled in correctly.</font>"; echo("<font color='red'><br>Please enter a message to send.</font>"); } ?> <br> <?php require_once('recaptchalib.php'); $publickey = "6LeB8LwSAAAAAKwvC3HWJNwWw9vYiSEkvFEvDduD"; // you got this from the signup page echo recaptcha_get_html($publickey); require_once('recaptchalib.php'); $privatekey = "6LeB8LwSAAAAAA_0IIEnAxL5uOau0TBm83Iog7Ey"; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { $errmessage ="<font color='red'>Some parts of the form have not been entered correctly and have been marked above</font>"; echo("<font color='red'>The text you entered does not match the picture provided.</font>"); } ?> <br> <input name"Submit" type="submit" value="Send Email"> </form> Required fields are marked with a *<br><br> <?php //Sending the email if nothing is wrong if(!$errmessage) { header("location:send.php?subject=".$subject."&email=".$email."&message=".$message.""); }else{ echo $errmessage; } } ?> </fieldset> <br><br><br> </body> </html> If anyone can help it would be really great Thanks, Blink359 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2010 Share Posted November 17, 2010 All of your form html is inside the if(isset($_POST['frmsubmit'])) { conditional statement. By that logic the form will not display unless it has already been submitted. See how that could be a little bit of a problem? Quote Link to comment Share on other sites More sharing options...
blink359 Posted November 17, 2010 Author Share Posted November 17, 2010 Ahh thank you i will go edit now Quote Link to comment Share on other sites More sharing options...
blink359 Posted November 17, 2010 Author Share Posted November 17, 2010 When it errors now it does exactly what it's meant to but it resets the field anyway to stop that, otherwise people could get very annoyed Quote Link to comment 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.