need php checkbox help PRONTO!

  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

I want to create a php checkbox tutorial for my forum soon as possible. I have alot of messages from eveyone in the forum and that just consumes alot of my bandwidth. So, instead of doing something about stopping those messages i want to create that tutorial. The problem I am having with it right now is that i want to start it up with a few questions, using the checkboxes, in the checkboxes i want to have the problems they are getting. Once they click the "submit" buttum i want the tutorial to open one of several pages i have ready to solve them.

To put it more clear. Depending on what they choose from the checkboxes, they will get a different page once they click "submit". for example if they check box1, box2 and box3 then submit, they will be redirected to a different place than then one they will be if they check the box1 and box2.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

Form.html
HTML Code: [ Select ]
<form method="post" action="tutorial.php">
Check Name 1 <input type="checkbox" name="Check_Name[]" />
Check Name 2 <input type="checkbox" name="Check_Name[]" />
Check Name 3 <input type="checkbox" name="Check_Name[]" />
<input type="submit" name="Submit" /></form>
  1. <form method="post" action="tutorial.php">
  2. Check Name 1 <input type="checkbox" name="Check_Name[]" />
  3. Check Name 2 <input type="checkbox" name="Check_Name[]" />
  4. Check Name 3 <input type="checkbox" name="Check_Name[]" />
  5. <input type="submit" name="Submit" /></form>

tutorial.php
PHP Code: [ Select ]
<?php
if(isset($_POST['submit']))
{
    $p = null;
    if(isset($_POST[check_name[0]]))
    {
        $p .= '0';
    }
    if(isset($_POST[check_name[1]))
    {
        $p .= '1';
    }
    if(isset($_POST[check_name[2]))
    {
        $p .= '2';
    }
    if(!isset($_POST[check_name[0]) && !isset($_POST[check_name[1]) && !isset($_POST[check_name[2]))
    {
        $p = '012';
    }
 
    $page = "tutorial_$p";
 
    // Now you redirect the user to $page
}
?>
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4.     $p = null;
  5.     if(isset($_POST[check_name[0]]))
  6.     {
  7.         $p .= '0';
  8.     }
  9.     if(isset($_POST[check_name[1]))
  10.     {
  11.         $p .= '1';
  12.     }
  13.     if(isset($_POST[check_name[2]))
  14.     {
  15.         $p .= '2';
  16.     }
  17.     if(!isset($_POST[check_name[0]) && !isset($_POST[check_name[1]) && !isset($_POST[check_name[2]))
  18.     {
  19.         $p = '012';
  20.     }
  21.  
  22.     $page = "tutorial_$p";
  23.  
  24.     // Now you redirect the user to $page
  25. }
  26. ?>

This approach will do the following.

You have 3 checkboxes. For each possibility you will have a page.

There are 6 different pages that to be made:

tutorial_0
tutorial_1
tutorial_2
tutorial_01
tutorial_02
tutorial_12

This is in no way the best solution because I'm not thinking well right now.
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

thanks alot for the coding. One last thing i want to ask? I am not that good at php, how can i redirect a user to a string value without them having to click any links?

I mean, from that .php file, just open then $page string once the value for it had been defined.

Code: [ Select ]
 ..if(!isset($_POST[check_name[0]) && !isset($_POST[check_name[1]) && !isset($_POST[check_name[2]))
  {
    $p = '012';
  }

  $page = "tutorial_$p"; <-- [here]

  // Now you redirect the user to $page
...
  1.  ..if(!isset($_POST[check_name[0]) && !isset($_POST[check_name[1]) && !isset($_POST[check_name[2]))
  2.   {
  3.     $p = '012';
  4.   }
  5.   $page = "tutorial_$p"; <-- [here]
  6.   // Now you redirect the user to $page
  7. ...


I also get a parse error in line 5, not sure exactly what it is...
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

This code has to be before the header or anything.

PHP Code: [ Select ]
<?php
header("LOCATION: $page");
?>
  1. <?php
  2. header("LOCATION: $page");
  3. ?>


I'm pretty sure it is
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

I am still getting parse error with the tutorial.php code you provided, can't find the exact place of the error, just know is in line 5..

Code: [ Select ]
<?php
if(isset($_POST['submit']))
{
  $p = null;
  if(isset($_POST[check_name[0]]))
  {
    $p .= '0';
  }
  if(isset($_POST[check_name[1]))
  {
    $p .= '1';
  }
  if(isset($_POST[check_name[2]))
  {
    $p .= '2';
  }
  if(!isset($_POST[check_name[0]) && !isset($_POST[check_name[1]) && !isset($_POST[check_name[2]))
  {
    $p = '012';
  }

  $page = "tutorial_$p";

  // Now you redirect the user to $page
}
?>
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4.   $p = null;
  5.   if(isset($_POST[check_name[0]]))
  6.   {
  7.     $p .= '0';
  8.   }
  9.   if(isset($_POST[check_name[1]))
  10.   {
  11.     $p .= '1';
  12.   }
  13.   if(isset($_POST[check_name[2]))
  14.   {
  15.     $p .= '2';
  16.   }
  17.   if(!isset($_POST[check_name[0]) && !isset($_POST[check_name[1]) && !isset($_POST[check_name[2]))
  18.   {
  19.     $p = '012';
  20.   }
  21.   $page = "tutorial_$p";
  22.   // Now you redirect the user to $page
  23. }
  24. ?>
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

you need to replace the following:

PHP Code: [ Select ]
isset($_POST[checkname[0]])


with the following:

PHP Code: [ Select ]
isset($_POST['check_name'][0])
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

I haven't coded for a while if you haven't noticed :D


Welcome back R_T
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

sorry for my delay answering... my forum went down so I guess there wont be any hurries to get the codes now :(

ok so, so far what i have is this

Form.html

Code: [ Select ]
<form method="post" action="tutorial.php">
Check Name 1 <input type="checkbox" name="Check_Name[]" />
Check Name 2 <input type="checkbox" name="Check_Name[]" />
Check Name 3 <input type="checkbox" name="Check_Name[]" />
<input type="submit" name="Submit" /></form>
  1. <form method="post" action="tutorial.php">
  2. Check Name 1 <input type="checkbox" name="Check_Name[]" />
  3. Check Name 2 <input type="checkbox" name="Check_Name[]" />
  4. Check Name 3 <input type="checkbox" name="Check_Name[]" />
  5. <input type="submit" name="Submit" /></form>


tutorial.php

Code: [ Select ]
<?php
 header("LOCATION: $page");
if(isset($_POST['submit']))
{
  $p = null;
  if(isset($_POST['check_name'][0]]))
  {
    $p .= '0';
  }
  if(isset($_POST['check_name'][1]))
  {
    $p .= '1';
  }
  if(isset($_POST['check_name'][2]))
  {
    $p .= '2';
  }
  if(!isset($_POST['check_name'][0]) && !isset($_POST['check_name'][1]) && !isset($_POST['check_name'][2]))
  {
    $p = '012';
  }

  $page = "tutorial_$p";


}
?>
  1. <?php
  2.  header("LOCATION: $page");
  3. if(isset($_POST['submit']))
  4. {
  5.   $p = null;
  6.   if(isset($_POST['check_name'][0]]))
  7.   {
  8.     $p .= '0';
  9.   }
  10.   if(isset($_POST['check_name'][1]))
  11.   {
  12.     $p .= '1';
  13.   }
  14.   if(isset($_POST['check_name'][2]))
  15.   {
  16.     $p .= '2';
  17.   }
  18.   if(!isset($_POST['check_name'][0]) && !isset($_POST['check_name'][1]) && !isset($_POST['check_name'][2]))
  19.   {
  20.     $p = '012';
  21.   }
  22.   $page = "tutorial_$p";
  23. }
  24. ?>


Now i get this error for tutorial.php:
Parse error: parse error, expecting `','' or `')'' on line 6 :(





Yesterday, I was making some research on this and found something close to what I'm looking for. I think that the only thing I have to fix is the outcome after people hit submit:

Tutorial.php

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 ]
<?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 < $N; $i++)
 {
  echo($pro[$i] . " ");
 }


}

?> <br /><br />

Based on what you choosed, we recommend the following tutorial for you<br />
<a href="link to tutorial here">sample</a>
  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 < $N; $i++)
  13.  {
  14.   echo($pro[$i] . " ");
  15.  }
  16. }
  17. ?> <br /><br />
  18. Based on what you choosed, we recommend the following tutorial for you<br />
  19. <a href="link to tutorial here">sample</a>


This will just echo back what you selected. I want the checkbox-control.php to automatically generate a link to one of my tutorials depending on what the people checked in tutorial.php just like Bogey was doing
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

PHP Code: [ Select ]
if(isset($_POST['check_name'][0]]))

The last ' ] ' is extra


I'm sorry, the header("LOCAT..... thing needs to be right after you define $page.


I meant that it needs to go before any HTML. It can go after PHP but not before any HTML.
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

I am feeling kinda embarrassed to ask you this but can you please tell me how i can fix the one I am currently working on? yours is good but I already started working on this one:



Tutorial.php

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 ]
<?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 < $N; $i++)
 {
  echo($pro[$i] . " ");
 }


}

?> <br /><br />

Based on what you choosed, we recommend the following tutorial for you<br />
<a href="link to tutorial here">sample</a>
  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 < $N; $i++)
  13.  {
  14.   echo($pro[$i] . " ");
  15.  }
  16. }
  17. ?> <br /><br />
  18. Based on what you choosed, we recommend the following tutorial for you<br />
  19. <a href="link to tutorial here">sample</a>


..and yes, I have about 10 reported problems. Thank you for your time
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

Well, if it's ten problems you don't want to make like 100 different pages :lol:



Alright. I got another possible solution for you. It requires a bit more PHP though.

This one's a bit different then the other one.

For each problem you have a tutorial on how to fix something. Problem 1 would be check box #1, problem 2 would be check box #2 and so on...

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

Remember that in this way, you are including the contents of one page inside of another page, so in the problem_1.html through problem_10.html all you put in there is the tutorial... the body. No <html><head><body> tags or anything like that.

I'm also not sure if this is suitable to your needs.

(I'm also not 100% sure about the PHP... it should work, but if it brings up errors... well, post it here if you can't fix them).
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

well, is not really that many tutorials i have to make because I also plan on finding a way to send an error if certain boxes combinations are checked. You see, the list of 10 I have is not really all the reported problems.


I will tell you the complete story, that way we will be in the same page.

I host a forum of YuGiOh. The game you can download for free and play online also for free. There are drawbacks with the game though, bad things. One of them is that the game won't save until some registry problems are solved. There are also ways to get all the game cards using some tutorials i made, but there are problems with that too, problems like: if you do it wrong you might end up getting black screen or game not opening at all.

Back in my forum I have alot of resources for the game, like modifications and stuff and that is one of the reasons why people keep coming, that and to look for answers to those problems i mentioned. The list I want to make will just INFORM me of their current situation, based on that, I will grant them with a tutorial that fits their situation. Here is the complete list I want to post:

Code: [ Select ]
<form action="checkbox-form.php" method="post">
  Please, check all the boxes that applies to your current sitiation:<br /><br />
  <input type="checkbox" name="problem[]" value="A" />I am using a 32-bit computer.<br />
  <input type="checkbox" name="problem[]" value="B" />I am using Windows 7 / vista.<br />
  <input type="checkbox" name="problem[]" value="C" />I am using Windows XP.<br />
  <input type="checkbox" name="problem[]" value="D" />I used BomWatchOut's installer but i still do not have all cards.<br />
  <input type="checkbox" name="problem[]" value="E" />I have the game.<br />
  <input type="checkbox" name="problem[]" value="F" />I do not have the game.<br />
  <input type="checkbox" name="problem[]" value="G" />*I am not sure if i have only one Yu-Gi-Oh! game in my computer.*<br />
  <input type="checkbox" name="problem[]" value="H" />I cannot save replays and/or decks.<br />
  <input type="checkbox" name="problem[]" value="I" />I get a black screen and I cannot see anything.<br />
  <input type="checkbox" name="problem[]" value="J" />I don't know where my "run" command is.<br />
<center><input type="submit" name="formSubmit" value="Submit" /></center><br /><br />
Please, pay special attention to the boxes with a *<br /> If your problem is not listed here then please let me know so.<br />
<b>If you check more boxes than the ones you have to, then you might end up getting nothing</b>
</form>
  1. <form action="checkbox-form.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" />I am using a 32-bit computer.<br />
  4.   <input type="checkbox" name="problem[]" value="B" />I am using Windows 7 / vista.<br />
  5.   <input type="checkbox" name="problem[]" value="C" />I am using Windows XP.<br />
  6.   <input type="checkbox" name="problem[]" value="D" />I used BomWatchOut's installer but i still do not have all cards.<br />
  7.   <input type="checkbox" name="problem[]" value="E" />I have the game.<br />
  8.   <input type="checkbox" name="problem[]" value="F" />I do not have the game.<br />
  9.   <input type="checkbox" name="problem[]" value="G" />*I am not sure if i have only one Yu-Gi-Oh! game in my computer.*<br />
  10.   <input type="checkbox" name="problem[]" value="H" />I cannot save replays and/or decks.<br />
  11.   <input type="checkbox" name="problem[]" value="I" />I get a black screen and I cannot see anything.<br />
  12.   <input type="checkbox" name="problem[]" value="J" />I don't know where my "run" command is.<br />
  13. <center><input type="submit" name="formSubmit" value="Submit" /></center><br /><br />
  14. Please, pay special attention to the boxes with a *<br /> If your problem is not listed here then please let me know so.<br />
  15. <b>If you check more boxes than the ones you have to, then you might end up getting nothing</b>
  16. </form>


As you can see, some of them cannot be together, so in the end, it will not be 100 tutorials
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

Oh, that makes sense :)

Still, if you use my first option, it's like 80+ pages :lol:
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6230
  • Loc: South-Africa

Post 3+ Months Ago

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. ?>
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

but 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.

If it were that easy I would do it long time ago :)
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

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
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

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
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

The else is not closed. You need one more } before the ?>
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

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
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

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
  • Genius
  • Genius
  • Bogey
  • Posts: 8399
  • Loc: USA

Post 3+ Months Ago

We must have miss-understood what you were asking for all this time :shock: Glad you figured it out.
  • BomWatchout
  • Newbie
  • Newbie
  • BomWatchout
  • Posts: 12

Post 3+ Months Ago

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

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.