Jump to content

[SOLVED] Small problem


zamp0e

Recommended Posts

I've done a form where the user can vote for wich alternative he think should win, and I have a little problem with it, Is it possible to change this form so you can only vote for one alternative at once ? If so, how ? :)

 

<?php

 

if (!isset($_POST['submit'])) {

    ?>

 

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">

    <input type="checkbox" name="design[]" value="Stilig">Stilig

    <input type="checkbox" name="design[]" value="Snygg">Snygg

    <input type="checkbox" name="design[]" value="Helt OK">Helt OK

    <input type="checkbox" name="design[]" value="Lite wierd">Lite wierd

    <input type="checkbox" name="design[]" value="Asful">Asful

    <input type="checkbox" name="design[]" value="...">...

    <input type="submit" name="submit" value="Rösta!">

    </form>

 

<?php

    }

else {

    if (is_array($_POST['design'])) {

        echo 'You selected: <br />';

        foreach ($_POST['design'] as $a) {

          echo "<i>$a</i><br />";

}

  if($a==Stilig)

  {

  mysql_query("UPDATE roster SET antal=antal+1 WHERE id='1'")or die(mysql_error());

  }

        }

    else {

        echo 'Nothing selected';

}

   

}

?>

 

 

Thanks in advance.

 

 

Link to comment
https://forums.phpfreaks.com/topic/159859-solved-small-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.