Jump to content

If(isset()){} not working


blink359

Recommended Posts

Im trying to use an if isset to stop my error messages displaying before they submit the form it worked on another part of my website but wont work for this, It just wond submit the form at all when i click submit here is the code:

<html>
<head>
</head>
<body>
<form action="contact.php" method="post">
<fieldset>
<legend>Contact Us</legend>
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 type="submit" value="Send Email">


</form>
Required fields are marked with a *<br><br>
<?php
if(isset($_POST['Submit'])){
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$to = "[email protected]";

//checcking that all relevent information is entered and correct
if(!$message || !$email)
{
	$errmessage ="Please fill in all required data.";
}
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 ="The text you wrote did not match the image.";  
		}
//Sending the email if nothing is wrong
if(!$errmessage)
{
header("location:send.php?to=".$to."&subject=".$subject."&email=".$email."&message=".$message."");
}else{
	echo $errmessage;
}
}
?>
</fieldset>

<br><br><br>
</body>
</html>

 

And here is a link to the page:

http://valiantflight.comlu.com/emailer/contact.php

 

Any help will be greatly appriciated,

 

Thanks,

 

Blink359

Link to comment
https://forums.phpfreaks.com/topic/218992-ifisset-not-working/
Share on other sites

<input name="Submit" type="submit" value="Send Email">

 

Or even better still, include a hidden field in the form, and check for its value to determine whether the form was submitted. This is actually the preferred method, as there are some browsers that don't properly handle setting the submit button if the user submits the form by hitting the enter key instead of clicking the submit button.

Link to comment
https://forums.phpfreaks.com/topic/218992-ifisset-not-working/#findComment-1135700
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.