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 = "nathan_k_boothby_1994@hotmail.co.uk";

//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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.