Jump to content

Check box validation


SirChick

Recommended Posts

My code won't allow the validation to succeed if everything is ok. I have a check box which the user has to tick in order for the process to take place. I'm not sure why but it always dies and produces my error .

 

Form :

<form name="" method="POST" action="breakoutofjail.php" enctype="text/plain" id="Form1">

<div id="bv_Text2" style="position:absolute;left:158px;top:92px;width:150px;height:16px;z-index:1" align="center">
<font style="font-size:13px" color="#000000" face="Arial"><i>Costs 10 Courage!</i></font></div>
<input type="checkbox" id="Checkbox1" name="BreakOutCheckBox" value="" style="position:absolute;left:324px;top:58px;z-index:2">
<input type="submit" id="Button1" name="BreakOut" value="Try To Break Out" style="position:absolute;left:158px;top:57px;width:144px;height:24px;z-index:0">
</form>

 

 

 

This is the validation on the breakoutofjail.php :

$Check = $_POST['BreakOutCheckBox'];

$Check = (isset($_POST['BreakOutCheckBox']) ? true : false);
if (!$Check) {
		die("You must tick the validation box, this avoids people accidently clicking the button!");
	}

 

 

If i echo $Check there is no response to it so its completely empty... even when ticked or not.

Link to comment
Share on other sites

This is the new alteration but still not working.

 

<input type="checkbox" id="Checkbox1" name="BreakOutCheckBox" value="yes" style="position:absolute;left:324px;top:58px;z-index:2">

 

$Check = $_POST['BreakOutCheckBox'];


if (!($Check  == 'Yes')){
		die("You must tick the validation box, this avoids people accidently clicking the button!");
	}

Link to comment
Share on other sites

Two things:

 

There is nothing technically wrong with your IF statement, but I would suggest changing it to this:

if ($Check != 'Yes'){

 

Let's verify that the receiving page is getting the values you are expecting. Put this on the page receiving the post data.

 

print_r($_POST);

 

Please post the output.

Link to comment
Share on other sites

<?

include ("jailinclude.php");
?>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>British Jail</title>
</head>
<body bgcolor="#FFAD5B" text="#000000" style="scrollbar-face-color:#C8E8F8;scrollbar-arrow-color:#000000;scrollbar-3dlight-color:#C8E8F8;scrollbar-darkshadow-color:#404040;scrollbar-highlight-color:#E8F4FF;scrollbar-shadow-color:#40B0E8;scrollbar-track-color:#E8F4FF;">
<div id="bv_" style="position:absolute;left:233px;top:290px;width:430px;height:32px;z-index:3" align="center">
<font style="font-size:13px" color="#000000" face="Arial"><b>You are in jail! You must wait till you are released before you can continue your normal Civilian Life!</b></font></div>
<div id="bv_" style="position:absolute;left:294px;top:193px;width:280px;height:16px;z-index:4" align="left">
<font style="font-size:13px" color="#000000" face="Arial"><u>Time In Jail:</u> <b><?= $TimeInJail ?> minutes.</b></font></div>
<img src="Banner1.jpg" id="Image1" alt="" align="top" border="2" width="996" height="96" style="position:absolute;left:0px;top:0px;width:996px;height:96px;border-color:#FFFFFF;z-index:5">
<div id="bv_" style="position:absolute;left:216px;top:366px;width:472px;height:150px;z-index:6" align="left">
<form name="" method="POST" action="breakoutofjail.php" enctype="text/plain" id="Form1">

<div id="bv_Text2" style="position:absolute;left:158px;top:92px;width:150px;height:16px;z-index:1" align="center">
<font style="font-size:13px" color="#000000" face="Arial"><i>Costs 10 Courage!</i></font></div>
<input type="checkbox" id="Checkbox1" name="BreakOutCheckBox" value="Yes" style="position:absolute;left:324px;top:58px;z-index:2">
<input type="submit" id="Button1" name="BreakOut" value="Try To Break Out" style="position:absolute;left:158px;top:57px;width:144px;height:24px;z-index:0">
</form>
</div>
</body>
</html>

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.