The following is the code to add score
Code: Select all
<html>
<head><title>Add your high schore</title></head>
<form method ="post" enctype = "multipart/form-data" action = "<?php echo $_SERVER['PHP_SELF'];?>">
<?php
if(!isset($_POST['submit']) && !isset($_POST['name']) && !isset($_POST['score']) ){ ?>
<label for='name'>Name</label>
<input type = 'text' name = 'name' id ='name'> <br />
<label for='score'>Score</label>
<input type = 'text' name = 'score' id ='score'> <br />
<label for='screenshot'>Screen Shot</label>
<input type = 'file' name = 'screenshot' id ='screenshot'>
<input type = 'submit' name ='submit' id='submit' value='ADD'>
</form>
<?php
}
else
{
$name = $_POST['name'];
$score = $_POST['score'];
$screenshot = $_FILES['screenshot']['name'];
$dbc = mysqli_connect('localhost','root','','guitarproj');
$query = "INSERT INTO guitarwars VALUES (0, NOW(), '$name', '$score', '$screenshot')";
$result= mysqli_query($dbc,$query);
$target = 'img/' . $name . 'verified.gif';
move_uploaded_file($_FILE['screenshot']['tmp_name'], $target);
echo 'Your score has been posted under ' . $target;
}
?>
</html>Code: Select all
<html>
<head><title>The submitted scores for guitar wars</title></head>
<body>
<?php
$dbc = mysqli_connect('localhost','root', '','guitarproj');
$query = "SELECT * FROM guitarwars";
$data = mysqli_query($dbc,$query);
while($row = mysqli_fetch_array($data))
{
echo 'Name: ';
echo $row['name'] . '<br />';
echo 'Score: ';
echo $row['score'] . '<br />';
echo '<img src ="img/' . $row['name']['tmp_name'] . '.gif" />';
echo '<br />';
}
?>
</body>
</html>