Jump to content
MakeWebGames

PHP If Statement - This Has Really Stumped Me


Octet

Recommended Posts

I am trying to check whether what the person entered is the day, although this isn't the best method to preventing spam it is the method I am going to be using for the time being. At the top of my webpage I have a clock, which the user needs to enter the day from in order to confirm that they are in fact a human. The problem is my script sends the message regardless, the script should be really simple but I cannot work out why it isn't doing what it is supposed to.

 

<?php

$ContactReason 			= mysql_real_escape_string($_POST['ContactReason']);
$Title					= mysql_real_escape_string($_POST['Title']);
$Message				= mysql_real_escape_string($_POST['Message']);
$Human					= mysql_real_escape_string($_POST['Human']);
$BConfirmation			= mysql_real_escape_string($_POST['BConfirmation']);
$Date					= date("Y/m/d H:i:s");

$HumanAnswer 		        = date("d");

if ($BConfirmation)
{
	die ("BOT WARNING - We have reason to believe you are a bot and have restricted your access to our servers");
}

if ($Human == $HumanAnswer);
{

	if ($ContactReason == "Null")
	{
		die (Header ('Location: Errors/Contact/Fields.php'));
	}

	if ($Title && $Message)
	{

		mysql_connect ("", "", "") or die ("Couldn't Connect to the Database Server");
		mysql_select_db ("") or die ("Couldn't Find Database on the Server");

		mysql_query ("INSERT INTO Contact (ContactReason, Title, Message, Date_Sent) VALUES ('$ContactReason', '$Title', '$Message', '$Date')");

		mysql_close();

		die (Header ('Location: Errors/Contact/Sent.php'));
	}

	die (Header ('Location: Errors/Contact/Fields.php'));

}

die (Header ('Location: Errors/Contact/Human.php'));

?>

 

The problem is somewhere on line 17, I have killed the script early and got it to echo out the '$Human' and '$HumanAnswer' variables and they both are correct, the '$Human' being what I entered and '$HumanAnswer' being what is on the clock.

Any ideas would be appreciated, I am sure it is really simple and something that I've overlooked.

(Note: I've removed my information from the mysql_select_db and mysql_connect for security)

Link to comment
Share on other sites

You: "The problem is somewhere on line 17"

Line 17: if ($Human == $HumanAnswer);

Hint: if ($var1== $var2) {} else {}

try work it out ;)

Thanks, I found my error :P

I put a ; on the end of it meaning the results where being ignored. Stupid mistake, I knew it was going to be something simple

Link to comment
Share on other sites

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.   Paste as plain text instead

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