Hi I am working on a ranking script where users can rank each other by using 2 forms. one for voting up, one for voting down.
HTML Code:
<form id="form1" name="form1" method="post" action="userprofile.php?up=true">
<label>
<input type="hidden" name="up" value="1">
<input type="submit" name="button" id="button" value="Vote Up" />
</label>
</form>
<form id="form2" name="form2" method="post" action="userprofile.php?down=true">
<label>
<input type="hidden" name="down" value="1">
<input type="submit" name="button3" id="button3" value="Vote Down" />
</label>
</form>
But I am getting alot of errors, which arent normally there if the ranking script wasnt here. such as
Notice: Undefined variable: name in C:\wamp\www\prototype4\userprofile.php on line 111
Notice: Undefined variable: location in C:\wamp\www\prototype4\userprofile.php on line 117
I have these on various different lines
The actual ranking script ( its not fully complete ) but I was expecting the create numbers to be shown when echoed and no errors.
the GET["id"] is used because on a previous page all id's are drawn into a url then a user can click a user and will display the profile, this is where the ranking script is.
PHP Code:
$useridvar = $_GET["id"];
if ($_GET["up"]=="true")
{
$sql="SELECT * FROM `numbers` WHERE `id` = '".$useridvar."'";
$result=mysql_query($sql);
if (!$result) die('Invalid query: ' . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$karma = $row["rank"];
}
$karma = $karma + $_POST['up'];
echo $karma;
$_GET["up"]="false";
}
if ($_GET["down"]=="true")
{
$_GET["down"]="false";
}
|