i have made a contact us form that emails to my email,, but the problem is that i made a text field to avoid spam machines, which says 1+1= ? , and the answer in the input field must be always 2

if(isset($guess) == "2"){
		die("Please Enter all the fields correctly");
		}

but it didnt work i tried also != ,,
can anyone write me his own code ,,please please help !!

Recommended Answers

All 6 Replies

Can you please provide the entire code you are using so that it will be helpful to detect where the problem lies...

Thanks!

have a html form for users to enter the answer:

form method=post action=abc.php
input type="text" name="answer"
input type="submit" value="submit"
/form

Then, use php to obtain the value entered in field:


$value=$_POST;

if($value!=2){
echo "sorry!! Answer wrong!!";
}

it would be

<?php
if($_POST['guess'] != 2) {
die("Answer is rong");
} else {
 what happens if right
}
?>
Member Avatar for diafol

This is wrong:

if(isset($guess) == "2"){

You're trying to test and check its existence in one go - do this:

if(isset($guess) && $guess == "2"){

mine is rite....try it

Member Avatar for diafol

> mine is rite....try it

Your html is up the spout, try again yourself!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.