Jump to content

Recommended Posts

if the checkboxes all have different names, then $_POST['checkboxname'] should be set to the value or to 'on' if no value was used. if you want to use the same name, you should use it like so:

<input type="checkbox" name="chkbox[]" value="val1" />
<input type="checkbox" name="chkbox[]" value="val2" />
<input type="checkbox" name="chkbox[]" value="val3" />

and in PHP, $_POST['chkbox'] should be an array of which values you selected

CheckBoxes either return the value or dun

so ya can use isset to determine the value

 

$checkbox = isset($_GET['mycheckbox'])?1:0;

 

1 if it was checked

0 if it wasnt

 

CheckBoxes either return the value or dun

so ya can use isset to determine the value

 

$checkbox = isset($_GET['mycheckbox'])?1:0;

 

1 if it was checked

0 if it wasnt

 

 

Ok, I'm sorry, let me clear this up...I miswrote ....I use $_POST to get all form items successfully.  My inputtexts.  I only have one checkbox (if you used multiple...wouldn't you use radio buttons instead?).

The $_POST on the checkbox doesn't seem to get any value.

I put in your code and now all it returns is a 0, even when its checked.

$rememberMe = isset($_POST['remember'])?1:0;
.
.
.
<SCRIPT>
alert('<?php echo $rememberMe ?>');
</script>
.
.
.
<FORM NAME="frmLogin" METHOD="post" ACTION="index.php">
<INPUT TYPE="checkbox" NAME="remember">
</FORM>

All I'm seeing now on the alert box is a 0.

 

 

Nevermind, I'm sorry.  I was closing the FORM before the checkbox.

 

<?php if ($loginExist==0){ ?>
				<FORM NAME="frmLogin" METHOD="post" ACTION="index.php">					
				Username<INPUT TYPE="TEXT" NAME="username" SIZE="15"> 
				Password<INPUT TYPE="password" NAME="password" SIZE="15">
				<INPUT TYPE="hidden" NAME="mode" VALUE="1">
				<INPUT TYPE="submit" VALUE="Login">
				</FORM>
			<?php }else{ ?>					
					<?php echo $fname ?><br>						
			<?php } ?>
				Register | Our Mission
			<?php if ($loginExist==0){ ?>
				    <INPUT TYPE="checkbox" NAME="remember">Remember Me

			<?php } ?>

 

I fixed it and now it works.

 

<?php if ($loginExist==0){ ?>
				<FORM NAME="frmLogin" METHOD="post" ACTION="index.php">					
				Username<INPUT TYPE="TEXT" NAME="username" SIZE="15"> 
				Password<INPUT TYPE="password" NAME="password" SIZE="15">
				<INPUT TYPE="hidden" NAME="mode" VALUE="1">
				<INPUT TYPE="submit" VALUE="Login">

			<?php }else{ ?>					
					<?php echo $fname ?><br>						
			<?php } ?>
				Register | Our Mission
			<?php if ($loginExist==0){ ?>
				    <INPUT TYPE="checkbox" NAME="remember">Remember Me
</FORM>

			<?php } ?>

 

I guess thats why you say post your source code....

I just didn't want to post all of it because its a pretty big page.

Thank you guys...and sorry for the misinformation on my part.

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.