need php checkbox help PRONTO!

  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post September 23rd, 2010, 12:34 am

righteous_trespasser wrote:
I think you're approaching this from the wrong angle ... Instead of submitting the form and creating a link from the post values, rather just include the correct files ... So in other words, create solution_1.html to solution_10.html files and just include them if necessary ... like so:

form.html

HTML Code: [ Select ]
<form action="checkbox-control.php" method="post">
  Please, check all the boxes that applies to your current sitiation:<br /><br />
  <input type="checkbox" name="problem[]" value="A" />Problem 1.<br />
  <input type="checkbox" name="problem[]" value="B" />Problem 2.<br />
  <input type="checkbox" name="problem[]" value="C" />Problem 3.<br />
  <input type="checkbox" name="problem[]" value="D" />Problem 4.<br />
  <input type="checkbox" name="problem[]" value="E" />Problem 5.<br />
  <input type="checkbox" name="problem[]" value="F" />Problem 6.<br />
  <input type="checkbox" name="problem[]" value="G" />Problem 7.<br />
  <input type="checkbox" name="problem[]" value="H" />Problem 8.<br />
  <input type="checkbox" name="problem[]" value="I" />Problem 9.<br />
  <input type="checkbox" name="problem[]" value="J" />Problem 10.<br />
<center><input type="submit" name="formSubmit" value="Submit" /></center><br /><br />
<br /> If your problem is not listed here then please let me know so.<br />
</form>
  1. <form action="checkbox-control.php" method="post">
  2.   Please, check all the boxes that applies to your current sitiation:<br /><br />
  3.   <input type="checkbox" name="problem[]" value="A" />Problem 1.<br />
  4.   <input type="checkbox" name="problem[]" value="B" />Problem 2.<br />
  5.   <input type="checkbox" name="problem[]" value="C" />Problem 3.<br />
  6.   <input type="checkbox" name="problem[]" value="D" />Problem 4.<br />
  7.   <input type="checkbox" name="problem[]" value="E" />Problem 5.<br />
  8.   <input type="checkbox" name="problem[]" value="F" />Problem 6.<br />
  9.   <input type="checkbox" name="problem[]" value="G" />Problem 7.<br />
  10.   <input type="checkbox" name="problem[]" value="H" />Problem 8.<br />
  11.   <input type="checkbox" name="problem[]" value="I" />Problem 9.<br />
  12.   <input type="checkbox" name="problem[]" value="J" />Problem 10.<br />
  13. <center><input type="submit" name="formSubmit" value="Submit" /></center><br /><br />
  14. <br /> If your problem is not listed here then please let me know so.<br />
  15. </form>


checkbox-control.php

PHP Code: [ Select ]
<?php
  for($i=0;$i<11;$i++){
    if(isset($_POST['problem'][$i]) && !empty($_POST['problem'][$i])){
      include("includes/solution_$i.html");
    }
  }
?>
  1. <?php
  2.   for($i=0;$i<11;$i++){
  3.     if(isset($_POST['problem'][$i]) && !empty($_POST['problem'][$i])){
  4.       include("includes/solution_$i.html");
  5.     }
  6.   }
  7. ?>

Someone missed my previous post :P
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post September 23rd, 2010, 12:34 am

  • BomWatchout
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Sep 20, 2010
  • Posts: 12
  • Status: Offline

Post September 23rd, 2010, 12:47 am

I have this:

Code: [ Select ]
<?php
$pro = $_POST['problem'];

if(empty($pro))
{
echo("You got this error because you didnt select any issue.<br />
  Please, click the back bottom and recheck your issues.");
}
else
{
$N = count($pro);

echo("You selected $N issues(s) in your computer: ");


 for($i=0;$i<11;$i++){
  if(isset($_POST['problem'][$i]) && !empty($_POST['problem'][$i])){
   include("includes/solution_$i.html");
  }
 }
?>
  1. <?php
  2. $pro = $_POST['problem'];
  3. if(empty($pro))
  4. {
  5. echo("You got this error because you didnt select any issue.<br />
  6.   Please, click the back bottom and recheck your issues.");
  7. }
  8. else
  9. {
  10. $N = count($pro);
  11. echo("You selected $N issues(s) in your computer: ");
  12.  for($i=0;$i<11;$i++){
  13.   if(isset($_POST['problem'][$i]) && !empty($_POST['problem'][$i])){
  14.    include("includes/solution_$i.html");
  15.   }
  16.  }
  17. ?>

getting parse error in line 21
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post September 23rd, 2010, 12:48 am

The else is not closed. You need one more } before the ?>
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • BomWatchout
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Sep 20, 2010
  • Posts: 12
  • Status: Offline

Post September 23rd, 2010, 12:54 am

ok see it now, but this still is not what I am looking for. As i said before "this checkboxes are not meant to give the user the direct tutorial link, they are meant to inform me of their current situation and from that I will grant them a tutorial."

This will just give open a tutorial for each individual checkbox..

sample:

box1 I have windows XP
box2 I have a 32-bit OS
box3 I do not have the game

what kind of tutorial it would be if they only check box 1?

I think the tutorial file names should be looking something like tutorial_ABC or tutorial_BDGEJ etc..
  • BomWatchout
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Sep 20, 2010
  • Posts: 12
  • Status: Offline

Post September 23rd, 2010, 1:33 am

Finally, I did it!!! :D

I must thank you ALOT Bogey for the time and patience for spent here, you really help me man, I owe you one for this. You too righteous_trespasser, thanks for the support.
You guys made my day right now. I can't find the words to say how thankful I am!!! :D

ok here is the final result:

Forum.html
Code: [ Select ]
<form action="checkbox-control.php" method="post">
 Please, check all the boxes that applies to your current sitiation:<br /><br />
 <input type="checkbox" name="problem[]" value="A" />Problem 1.<br />
 <input type="checkbox" name="problem[]" value="B" />Problem 2.<br />
 <input type="checkbox" name="problem[]" value="C" />Problem 3.<br />
 <input type="checkbox" name="problem[]" value="D" />Problem 4.<br />
 <input type="checkbox" name="problem[]" value="E" />Problem 5.<br />
 <input type="checkbox" name="problem[]" value="F" />Problem 6.<br />
 <input type="checkbox" name="problem[]" value="G" />Problem 7.<br />
 <input type="checkbox" name="problem[]" value="H" />Problem 8.<br />
 <input type="checkbox" name="problem[]" value="I" />Problem 9.<br />
 <input type="checkbox" name="problem[]" value="J" />Problem 10.<br />
<center><input type="submit" name="formSubmit" value="Submit" /></center><br /><br />
<br /> If your problem is not listed here then please let me know so.<br />
</form>
  1. <form action="checkbox-control.php" method="post">
  2.  Please, check all the boxes that applies to your current sitiation:<br /><br />
  3.  <input type="checkbox" name="problem[]" value="A" />Problem 1.<br />
  4.  <input type="checkbox" name="problem[]" value="B" />Problem 2.<br />
  5.  <input type="checkbox" name="problem[]" value="C" />Problem 3.<br />
  6.  <input type="checkbox" name="problem[]" value="D" />Problem 4.<br />
  7.  <input type="checkbox" name="problem[]" value="E" />Problem 5.<br />
  8.  <input type="checkbox" name="problem[]" value="F" />Problem 6.<br />
  9.  <input type="checkbox" name="problem[]" value="G" />Problem 7.<br />
  10.  <input type="checkbox" name="problem[]" value="H" />Problem 8.<br />
  11.  <input type="checkbox" name="problem[]" value="I" />Problem 9.<br />
  12.  <input type="checkbox" name="problem[]" value="J" />Problem 10.<br />
  13. <center><input type="submit" name="formSubmit" value="Submit" /></center><br /><br />
  14. <br /> If your problem is not listed here then please let me know so.<br />
  15. </form>


Checkbox-control.php

Code: [ Select ]
<html>
<?php
$pro = $_POST['problem'];
if(empty($pro))
{
echo("You got this error because you didnt select any issue.<br />
  Please, click the back bottom and recheck your issues.");
}
else
{
$N = count($pro);

echo("You selected $N issues(s) in your computer: ");
}

?>
<br /><br />
Based on what you choosed, we recommend the following tutorial for you<br /><br />
<center>
<a href=
 "tutorial_<?php
  for($i=0; $i < $N; $i++)
  {
   echo($pro[$i]); 
  }
  ?>.html
">your tutorial</a>
</center>
</html>
  1. <html>
  2. <?php
  3. $pro = $_POST['problem'];
  4. if(empty($pro))
  5. {
  6. echo("You got this error because you didnt select any issue.<br />
  7.   Please, click the back bottom and recheck your issues.");
  8. }
  9. else
  10. {
  11. $N = count($pro);
  12. echo("You selected $N issues(s) in your computer: ");
  13. }
  14. ?>
  15. <br /><br />
  16. Based on what you choosed, we recommend the following tutorial for you<br /><br />
  17. <center>
  18. <a href=
  19.  "tutorial_<?php
  20.   for($i=0; $i < $N; $i++)
  21.   {
  22.    echo($pro[$i]); 
  23.   }
  24.   ?>.html
  25. ">your tutorial</a>
  26. </center>
  27. </html>

I trully hope someone else might find this useful in the future. Thanks again guys, this forum rock and I won't be leaving it any time soon :D
  • Bogey
  • Bogey
  • Genius
  • User avatar
  • Joined: Jul 14, 2005
  • Posts: 8211
  • Loc: USA
  • Status: Offline

Post September 23rd, 2010, 10:38 am

We must have miss-understood what you were asking for all this time :shock: Glad you figured it out.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
  • BomWatchout
  • Newbie
  • Newbie
  • No Avatar
  • Joined: Sep 20, 2010
  • Posts: 12
  • Status: Offline

Post September 23rd, 2010, 1:48 pm

well, now I need to shorten those outcomes by echo-ing errors if the user check certain boxes together. I know this can be solved using the "if" and "else" statements. Would it be too much to ask?

I will show a sample using my bad php knowledge :)

Code: [ Select ]
<html>

<?php

$pro = $_POST['problem'];

if(empty($pro))
{
echo("You got this error because you didnt select any issue.<br />
  Please, click the back bottom and recheck your issues.");
}
else
{
$N = count($pro);

echo("You selected $N issues(s) in your computer: ");
}

?>
<br /><br />

Based on what you choosed, we recommend the following tutorial for you<br /><br />
<center>
<a href="tutorial_<?php
for($i=0; $i < $N; $i++)
{
  $p = ($pro[$i]);
  $a = array(($pro[$i]));
  if(array_key_exists("A"||"AB"||"ABC",$a)) /*<-- in here I meant to say if the value A (only) or the values AB (only) or values ABC (only) exist in the array...*\
  {
  echo("error");
  }
  else
  {
  echo($p);
  }
}
?>.html
">your tutorial</a>
</html>
  1. <html>
  2. <?php
  3. $pro = $_POST['problem'];
  4. if(empty($pro))
  5. {
  6. echo("You got this error because you didnt select any issue.<br />
  7.   Please, click the back bottom and recheck your issues.");
  8. }
  9. else
  10. {
  11. $N = count($pro);
  12. echo("You selected $N issues(s) in your computer: ");
  13. }
  14. ?>
  15. <br /><br />
  16. Based on what you choosed, we recommend the following tutorial for you<br /><br />
  17. <center>
  18. <a href="tutorial_<?php
  19. for($i=0; $i < $N; $i++)
  20. {
  21.   $p = ($pro[$i]);
  22.   $a = array(($pro[$i]));
  23.   if(array_key_exists("A"||"AB"||"ABC",$a)) /*<-- in here I meant to say if the value A (only) or the values AB (only) or values ABC (only) exist in the array...*\
  24.   {
  25.   echo("error");
  26.   }
  27.   else
  28.   {
  29.   echo($p);
  30.   }
  31. }
  32. ?>.html
  33. ">your tutorial</a>
  34. </html>

For more that I try it seems not to apply the "if" statement I added... it just goes over it and states the "else" statement.
Little help please? :D

Post Information

  • Total Posts in this topic: 22 posts
  • Users browsing this forum: No registered users and 121 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.