Hello,
I am trying to create a photo slideshow, where the user should rate each photograph. In order to vote, the user must first enter gender, location and age, and is then moved to the first photo.
My intention is then to make a new record (row) for each user with the user's data and points given to each photo. That is, the table consists of fields 'id' mediumint(6) auto_increment PRIMARY, 'ip' varchar(15), 'gender' varchar(10), 'area' varchar(20), 'age' tinyint(2), 'm01' tinyint(2), ... , 'm10' tinyint(2)
I put the whole thing on the same page index.php and attempts to build up an array of the photo ratings. Then in the end, after the last photo has been shown, the values from the voting forms are sent to the database.
The photo slideshow runs correctly, and I get no error from MySQL. A new record (row) is also created, but all the values are utter zeros. The value of each field in the new row becomes 0 or empty, except for the user's ip.
Here are some lines of my code:
else if ($p >= 1 && $p < 10) {
$rating[$p] = $points;
$p++;
style(); # Creates top of new page #
$image = "m".$p.".jpg";
echo "<img border='0' src='$image' height='300'></p>
<p style='text-align: center'> </p>
<p style='text-align: center'><b>Picture $p of 25</b></p>
<p style='text-align: center'> </p>
<form action='index.php' method='POST' name='vote'>
<input type='hidden' name='p' value='$p'>
<p style='text-align: center'><b>Points: 1<input type='radio' value='1' name='points' style='color: #FFFFFF; background-color: #000000'>
| 2<input type='radio' value='2' name='points' style='color: #FFFFFF; background-color: #000000'>
| 3<input type='radio' value='3' name='points' style='color: #FFFFFF; background-color: #000000'>
| 4<input type='radio' value='4' name='points' style='color: #FFFFFF; background-color: #000000'>
| 5<input type='radio' value='5' name='points' style='color: #FFFFFF; background-color: #000000'>
| 6<input type='radio' value='6' name='points' style='color: #FFFFFF; background-color: #000000'>
| 7<input type='radio' value='7' name='points' style='color: #FFFFFF; background-color: #000000'>
| 8<input type='radio' value='8' name='points' style='color: #FFFFFF; background-color: #000000'>
| 9<input type='radio' value='9' name='points' style='color: #FFFFFF; background-color: #000000'>
| 10<input type='radio' value='10' name='points' style='color: #FFFFFF; background-color: #000000'></b></p>
<p style='text-align: center'> </p>
<p style='text-align: center'><b>Worst - - >> - - Bad - - >> - - Medium - - >>
- - Good - - >> - - Best</b></p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'>
<input type='submit' value=' Next Picture ' style='color: #FFFFFF; font-weight: bold; border: 1px solid #FFFFFF; background-color: #000000'></p>
</form>
<p style='text-align: center'> </p>
</body>
</html>";
}
else if ($p == 10) {
style();
$currentIP = $_SERVER['REMOTE_ADDR'];
$connection = mysql_connect($host,$user,$password)
or exit ("Server connection failed");
$db = mysql_select_db($databasename,$connection)
or exit ("Database selection failed");
$query = "INSERT INTO vote
(ip, gender, area, age, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10)
VALUES
( '$currentIP', '$gender', '$area', '$age', '$rating[1]', '$rating[2]', '$rating[3]', '$rating[4]', '$rating[5]',
'$rating[6]', '$rating[7]', '$rating[8]', '$rating[9]', '$rating[10]')";
$result = mysql_query($query)
or exit ("Query failed");
echo "<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'> </p>
<p style='text-align: center'><b>Th</b>a<b>nk Y</b>o<b>u</b></p>
<p style='text-align: center'> </p>
</body>
</html>";
}
Any hints would be much appreciated. Thank you in advance.
Nico