Guest User

Untitled

a guest
Mar 3rd, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2. $username = "root";
  3. $password = "";
  4. $hostname = "localhost";
  5. $dbh = mysql_connect($hostname, $username, $password)
  6. or die("Unable to connect to MySQL");
  7. $selected = mysql_select_db("votes",$dbh)
  8. or die("Could not select database votes<br><br>");
  9.  
  10. $user_ip = $_SERVER['REMOTE_ADDR'];
  11. $opin = $_POST['opin'];
  12. if(isset($opin) && isset($user_ip)){
  13. mysql_query("insert into voteinfo (ip, vote) values ('$user_ip', $opin)");
  14. }
  15. ?>
  16.  
  17. <form name="votefrm" action="./" method="post">
  18. <input type="radio" name="opin" value="1"><label>Game 1</label><br>
  19. <input type="radio" name="opin" value="2"><label>Game 2</label><br>
  20. <input type="radio" name="opin" value="3"><label>Game 3</label><br>
  21. <input type="radio" name="opin" value="4"><label>Game 4</label><br>
  22. <input type="radio" name="opin" value="5"><label>Game 5</label><br>
  23. <input type="radio" name="opin" value="6"><label>Game 6</label><br>
  24. <input type="radio" name="opin" value="7"><label>Game 7</label><br>
  25. <input type="radio" name="opin" value="8"><label>Game 8</label><br>
  26. <input type="radio" name="opin" value="9"><label>Game 9</label><br>
  27. <input type="radio" name="opin" value="10"><label>Game 10</label><br><br>
  28.  
  29. <input type="submit" value="Submit vote">
  30. </form>
  31.  
  32. <?php
  33. if(isset($opin) && isset($user_ip)){
  34. echo 'Your vote (' . $opin . ') has been registrered.';
  35.  
  36. $query = "select * from voteinfo";
  37. $result = mysql_query($query);
  38.  
  39. $row = mysql_fetch_assoc($result);
  40. while mysql_fetch_assoc($row){
  41. echo $row['vote'];
  42. }
  43. }
  44. mysql_close($dbh);
  45. ?>
Add Comment
Please, Sign In to add comment