I want to add a simple rating system to my random video site (id = youtube id)
I don't have much experience with php and MySQL and I'm not sure how to update a field using submit buttons in this way:
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" name"rateform">
<input name="rateup" type="image" src="up.png" id="rateup" value="rateup" />
<input name="ratedown" type="image" src="down.png" id="ratedown"
value="ratedown" />
</form>
<?PHP
mysql_connect(",",",",",")or die(mysql_error());
mysql_select_db(",")or die(mysql_error());
if ($_POST['rateup'])
{
mysql_query("UPDATE utube SET rating = rating + 1
WHERE (id = $pageid)");} else if ($_POST['ratedown']) {
mysql_query("UPDATE utube SET rating = rating - 1
WHERE (id = $pageid)");}
?>
Is there something I have to do to link the html and php together?
All of the statements return the correct values by themselves (i.e $pageid)
but when I press the buttons there is nothing happening to any fields.
When I put the mysql query directly into phpmyadmin it also works,
I'm just not sure about how the html communicates with the php?
I'd appreciate if someone were to inform me of how this works so I can get my script to work.