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

.../testingform.php?name=Shannon&email=shannon%40resultsenterprises.com&char2=checked&ship1=CANADA&enter=1&x=61&y=32

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.

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.

Member Avatar for diafol
.../testingform.php?name=Shannon&email=shannon%40resultsenterprises.com&char2=checked&ship1=CANADA&enter=1&x=61&y=32

How about:

<?php
if(isset($_GET['char2'])){
  $char2 = 'checked="checked" ';
}else{
  $char2="";
}
if(isset($_GET['char1'])){
  $char1 = 'checked="checked" ';
}else{
  $char1="";
}
?>

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

Didn't work! Thanks for trying...

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

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

I had typed the last part wrong!

You are the best!!!

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.