I can't seem to figure out the code to get selection box on feedback form to work...? Watch

Tangerine Dream
Badges: 0
Rep:
?
#1
Report Thread starter 10 years ago
#1
I can't seem to figure out the code to get selection box on feedback form to work. The php:

Code:
<?
  $one = $_REQUEST['one'] ;
  $two = $_REQUEST['two'] ;
  $three = $_REQUEST['three'] ;
  $four = $_REQUEST['four'] ;
  $five = $_REQUEST['five'] ;
  $mail = $_REQUEST['email'] ;
  
  if (!isset($_REQUEST['email'])) {
    header( "Location: http://www.test.co.uk/feesandfree.html" );
  }
  elseif (empty($mail)) {
    header( "Location: http://www.test.co.uk/feesandfree.html" );
  }
 else {

    $email = "[email protected]";
    $subject = "Free Info Request";
    $sendmess = "Contact Details:\nEmail: ".$mail."\n\n1: ".$one."\n2: ".$two."\n3: ".$three."\n4: ".$four."\n5: ".$five;
    $from ="From: $mail";
  
    mail( $email, $subject, $sendmess, $from );
    header( "Location: http://www.test.co.uk/submitted.html" );
  }
?>
the HTML:

Code:
<form id="form1" name="form1" method="post" action="submit.php">  <ul type="disc">
    <li>What type of parent are you?  Mandy Moaner, Posy Pushover, or Sarah Saintly? <input type="checkbox" name="one" id="one" />
    </li>
    <li>Ready for the Olympics?  Rate your family&rsquo;s health and fitness! 
      <input type="checkbox" name="two" id="two" />
    </li>
    <li>If only they would&hellip;&hellip;..?  What&rsquo;s driving you mad in your household? 
      <input type="checkbox" name="three" id="three" />
    </li>
    <li>Parents&rsquo; Nights - how to make the most of them. 
      <input type="checkbox" name="four" id="four" />
    </li>
    <li>Top Tips for Stress- free homework. 
      <input type="checkbox" name="five" id="five" />
      <br />
    </li>
  </ul>
  Email: 
  <input name="email" type="text" />
  <input name="submit" type="submit" value="Send me selected questionnaires" />
      </form>
and this is what shows in my email when someone submits the feedback form:

Code:
Contact Details:
Email: [email protected]

1:
2:
3:
4:
5:
So it ignores, or doesn't output the 5 selection boxes and whether they are ticked or not by the user... and I can't seem to get it to work. I was planning on it saying YES or NO as the output (ticked or unticked)

Thanks for any help This is driving me mad!
0
quote
reply
alex-hs
Badges: 2
Rep:
?
#2
Report 10 years ago
#2
You need a value attribute for each checkbox, eg. <input type="checkbox" name="five" id="five" value="yes" />
The downside to checkboxes is that if they're unticked you get a null value passed back to the php script - you can get round this by using an if statement to check if the value is "yes" and if not, set it to "no".
0
quote
reply
Tangerine Dream
Badges: 0
Rep:
?
#3
Report Thread starter 10 years ago
#3
sorted! thanks
0
quote
reply
X

Reply to thread

Attached files
Write a reply...
Reply
new posts
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Who is most responsible for your success at university

Mostly me (759)
90.57%
Mostly my university including my lecturers/tutors (79)
9.43%

Watched Threads

View All
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise