Okay I am going to pull out my hair. I have been working on this for over 10 hours and I know someone out there can help me.

I am looking to grab information from passed information


the field I am pulling is char2=checked it will either come through as char2=checked or char1=checked and I want it to fill out the below:

<input type="checkbox" name="Checkbox0" value="35182" [checked="echo $_GET["char1"]"] >&nbsp;Make-A-Wish<br>
			<input type="checkbox" name="Checkbox1" value="35184" [checked="echo $_GET["char2"]"]>&nbsp;Habitat for Humanity<br>

However the code above checks both boxes off even though only one comes through from the previous page. I have been reading up on the codes and in my form of PHP apparently as long as "checked" is in the string the box will be marked checked and I can't seem to just grab the word only i have tried just the echo get and put it in brackets and parentheses and it won't just print the word.

Someone help before I lose my mind!!

Thank you everyone.

8 Years
Discussion Span
Last Post by sjusts

Well my first thoughts on this are that no variable is being passed, and the browser is checking them both because it finds the words "checked" as you said.
Have you looked at the source on the page to see if you are seeing checked=checked for both inputs? My guess is no.
You may want to do something like this:

<input type="checkbox" name="Checkbox0" value="35182" <?php if(isset($_GET['char1'])) { echo mysql_real_escape_string($_GET['char1']); }?>>&nbsp;Make-A-Wish<br>
      <input type="checkbox" name="Checkbox1" value="35184" <?php if(isset($_GET['char2'])) { echo mysql_real_escape_string($_GET['char1']); }?>>&nbsp;Habitat for Humanity<br>

If neither are checked it means the variable didn't pass.

Edited by Tekkno: n/a


How about:

  $char2 = 'checked="checked" ';
  $char1 = 'checked="checked" ';

<input type="checkbox" name="Checkbox0" value="35182" <?php echo $char1;?>/>&nbsp;Make-A-Wish<br />
<input type="checkbox" name="Checkbox1" value="35184" <?php echo $char2;?>/>&nbsp;Habitat for Humanity<br />

It worked!!!!!!!!!!!!!!!

Thank you Thank you Thank you!!!!!!!!11

I had typed the last part wrong!

You are the best!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.