Originally Posted by
rossco
Yes, because the creator wanted it to say that.
HTML Code:
<form method="POST" action="vote.php" onsubmit="return confirm('Are you sure?');">
hehe I'm not so idiot hehe. well the code that I made(taking in consideration the board I used) was this:
the board works this way, loads first a xxxx.php page to load variables, make sql queries etc, then use the variables in a xxx.template.php page.
this is what I wrote on the xxx.php page
Code:
// movie rate system
if (isset($_REQUEST['Reset']) && !$user_info['is_guest'])
{
db_query("
DELETE *FROM {$db_prefix}MoviesVotes WHERE userID = $ID_MEMBER AND movieID=$topic", __FILE__, __LINE__);
}
$request = db_query("
SELECT *FROM {$db_prefix}MoviesVotes WHERE userID = $ID_MEMBER AND movieID=$topic", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
if($row)
{
$context['already_voted']=true;
$context['past_rate']=$row['rating'];
}
else
$context['already_voted']=false;
if (isset($_REQUEST['Rate']) && !$user_info['is_guest'])
{
$rating = (int) $_POST['vote'];
if ($rating >= 1 && $rating <= 10)
db_query("
REPLACE INTO {$db_prefix}MoviesVotes
(userID, movieID, rating)
VALUES
($ID_MEMBER, $topic, $rating)", __FILE__, __LINE__);
$request = db_query("SELECT COUNT(*) AS n_votes FROM {$db_prefix}MoviesVotes WHERE movieID=$topic", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
$request = db_query("SELECT AVG(vote) AS average FROM {$db_prefix}MoviesVotes WHERE movieID=$topic", __FILE__, __LINE__);
$row2 = mysql_fetch_assoc($request);
$rating = number_format($row2['average'], 2, ‘.’, ”);
db_query("UPDATE {$db_prefix}Movies SET n_votes='$row['n_votes']', average='$rating' WHERE movieID=$topic", __FILE__, __LINE__);
}
and this on the xxx.template.php:
Code:
f($context['user']['is_logged'])
{
if($context['already_voted'])
{
echo '<b>',$context['past_rate'],'</b> <form action="', $scripturl, '?topic=', $context['current_topic'], ' method="POST" style="margin: 0;">
<input type="hidden" name="sc" value="', $context['session_id'], '" />
<input type="submit" name="Reset" value="Reset" />
</form>';
}
else
{
echo '
<form action="', $scripturl, '?topic=', $context['current_topic'], ' method="POST" style="margin: 0;">
<select name="vote">';
for ($i = 1; $i <= 10; $i++)
echo '
<option value="', $i, '">', $i, '</option>';
echo '
</select>
<input type="hidden" name="sc" value="', $context['session_id'], '" />
<input type="submit" name="Rate" value="Rate" />
</form>';
}
}
else
{
echo'You need to be loged in order to rate this movie';
}
the variables relative to the board are correct so the problem is not there, I made some testing and noticed that for example the forms seems that are not sending values and I can't understand why :p and also that popup message appear . The IFs on the xxx.template file are working at 100% btw so there's not a problem there either
Bookmarks