Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = "root";
- $password = "";
- $hostname = "localhost";
- $dbh = mysql_connect($hostname, $username, $password)
- or die("Unable to connect to MySQL");
- $selected = mysql_select_db("votes",$dbh)
- or die("Could not select database votes<br><br>");
- $user_ip = $_SERVER['REMOTE_ADDR'];
- $opin = $_POST['opin'];
- if(isset($opin) && isset($user_ip)){
- mysql_query("insert into voteinfo (ip, vote) values ('$user_ip', $opin)");
- }
- ?>
- <form name="votefrm" action="./" method="post">
- <input type="radio" name="opin" value="1"><label>Game 1</label><br>
- <input type="radio" name="opin" value="2"><label>Game 2</label><br>
- <input type="radio" name="opin" value="3"><label>Game 3</label><br>
- <input type="radio" name="opin" value="4"><label>Game 4</label><br>
- <input type="radio" name="opin" value="5"><label>Game 5</label><br>
- <input type="radio" name="opin" value="6"><label>Game 6</label><br>
- <input type="radio" name="opin" value="7"><label>Game 7</label><br>
- <input type="radio" name="opin" value="8"><label>Game 8</label><br>
- <input type="radio" name="opin" value="9"><label>Game 9</label><br>
- <input type="radio" name="opin" value="10"><label>Game 10</label><br><br>
- <input type="submit" value="Submit vote">
- </form>
- <?php
- if(isset($opin) && isset($user_ip)){
- echo 'Your vote (' . $opin . ') has been registrered.';
- $query = "select * from voteinfo";
- $result = mysql_query($query);
- $row = mysql_fetch_assoc($result);
- while mysql_fetch_assoc($row){
- echo $row['vote'];
- }
- }
- mysql_close($dbh);
- ?>
Add Comment
Please, Sign In to add comment