1

When i check this form i always come to the google option, no matter which combination. i don't know what i am doing wrong. i'm using the same form for checkboxes on an other case. 1-6 is always google. even not configurated multi-choices are google.

.pic{
        background: url("#") no-repeat;
        width:616px;
        height:525px;
        position: relative;
        }
    input[type="checkbox"] {
          transform:scale(1.3, 1.3);
        }
        .poin1{
        left: 548px;
        bottom:59px;
        position: absolute;
        }
        .poin2{
        left: 540px;
        bottom:155px;
        position: absolute;
        }
        .poin3{
        left: 500px;
        bottom:265px;
        position: absolute;
        }
        .poin4{
        left: 495px;
        bottom:325px;
        position: absolute;
        }
      .poin5{
        left: 479px;
        bottom:385px;
        position: absolute;
        }
      .poin6{
        left: 465px;
        bottom:460px;
        position: absolute;
        }



<form method="post" action="../includes/messung_jeans.php">  <div class="pic">
    <input type="checkbox" id="cb1" name="cb1" value="m1" class="poin1">
    <input type="checkbox" id="cb2" name="cb2" value="m2" class="poin2">
    <input type="checkbox" id="cb3" name="cb3" value="m3" class="poin3">
    <input type="checkbox" id="cb4" name="cb4" value="m4" class="poin4">
   <input type="checkbox" id="cb5" name="cb5" value="m5" class="poin5">
   <input type="checkbox" id="cb6" name="cb6" value="m6" class="poin6">


</div>
  <div class="buttonHolder">
<input type="submit" name="send" <a class="btn primary-button" value="Weiter" /> </a>

    </div>



<?

if($_POST['cb1'] == m1){
    header("Location: http://www.google.com");
}
elseif($_POST['cb2'] == m2 ){
    header("Location: http://www.yahoo.com");
}
elseif($_POST['cb2'] == m2 && $_POST['cb1'] == m1 ){
    header("Location: http://www.bild.de");
}
elseif($_POST['cb3'] == m3 ){
    header("Location: http://www.bing.com");
}
elseif($_POST['cb4'] == m4 ){
    header("Location: http://www.bing.com");
}
elseif($_POST['cb5'] == m5 ){
    header("Location: http://www.bing.com");
}
elseif($_POST['cb6'] ==  m6 ){
    header("Location: http://www.bing.com");
}

else {
    header("Location: http://www.floridataxreduction.com");
}  
?>
Cœur
  • 37,241
  • 25
  • 195
  • 267
filledat
  • 47
  • 6

1 Answers1

0

<form method="post" action="../includes/messung_jeans.php">  <div class="pic">
    <input type="checkbox" id="cb1" name="cb1" value="m1" class="poin1">
    <input type="checkbox" id="cb2" name="cb2" value="m2" class="poin2">
    <input type="checkbox" id="cb3" name="cb3" value="m3" class="poin3">
    <input type="checkbox" id="cb4" name="cb4" value="m4" class="poin4">
   <input type="checkbox" id="cb5" name="cb5" value="m5" class="poin5">
   <input type="checkbox" id="cb6" name="cb6" value="m6" class="poin6">


</div>
  <div class="buttonHolder">
<input type="submit" name="send" class="btn primary-button" value="Weiter" /> 

    </div>

Add Your PHP code as below.

<?php
if(isset($_POST['cb1']) && !isset($_POST['cb2'])){
   header("Location: http://www.google.com");
}
elseif(isset($_POST['cb2']) && !isset($_POST['cb1'])){
   header("Location: http://www.yahoo.com");
}
elseif(isset($_POST['cb2']) && isset($_POST['cb1'])){
   header("Location: http://www.bild.de");
}
elseif(isset($_POST['cb3'])){
header("Location: http://www.bing.com");
}
elseif(isset($_POST['cb4'])){
header("Location: http://www.bing.com");
}
elseif(isset($_POST['cb5'])){
   header("Location: http://www.bing.com");
}
elseif(isset($_POST['cb6'])){
   header("Location: http://www.bing.com");
}
else {
   header("Location: http://www.floridataxreduction.com");
}
?>
Pravin Vavadiya
  • 3,195
  • 1
  • 17
  • 34
  • thank you, this worked! but: elseif(isset($_POST['cb2']) && isset($_POST['cb1'])){ header("Location: http://www.bild.de"); } ---- if i try this, its again google – filledat Dec 03 '16 at 08:51
  • can you explain me why the above poster is using exit() and why you use this construct. what is better? – filledat Dec 03 '16 at 09:58
  • In above poster using exist() is not required. Because if condition is true it's redirect to Header location not check another condition.... – Pravin Vavadiya Dec 03 '16 at 10:05
  • ah i see it, it means his exit is useless, if i need 1,2 and 3 in the future, because it will stop at 1 & 2 – filledat Dec 03 '16 at 10:34
  • @filledat yea it is required to be there to format data and session and to stop any malicious request to rest of the script. please before you anything say and before changing your mind what is the best answer, do not listen beginner s opinions, it is better to go to php site, learn more about header() and exit() from experts. `http://php.net/manual/en/function.header.php` `http://stackoverflow.com/questions/2747791/why-i-have-to-call-exit-after-redirection-through-headerlocation-in-php` `http://stackoverflow.com/questions/8665985/php-utilizing-exit-or-die-after-headerlocation` –  Dec 03 '16 at 12:23
  • @felixsturm You have use exit() in if condition. So, if condition is true then redirects to given location url and after call exit(). Means code execute without check another elseif condition. if another condition is true for this but this is not checking because you have use exit() function. – Pravin Vavadiya Dec 03 '16 at 12:53
  • @PravinVavadiya exit() is required after header() function of course if you want to stop execution of script and obviously questioner wanted this. end of story –  Dec 03 '16 at 15:04