Hello, this might be quite a challenging task to ask for help with, but I’m truly stuck and I would be grateful if maybe someone was able to help me with this assignment.
I’m working on my assignment. (http://wikisend.com/download/488226/300582_assignment_2014_v1_2(1).pdf]300582_assignment_2014_v1_2(1).pdf)
I am stuck on 7 “This panel should display a welcome message to the user, using his/her chosen username. It should also display his/her ranking”
User Ranking:
When a user’s tip is compared to the actual outcome of the game, the user receives a score and a
margin. If the user correctly predicts which team would win (or correctly predicted a draw) they
receive a score of 1; otherwise 0.
The margin is a measure of how close the user’s prediction was to the actual result — a smaller
margin corresponds to a better prediction. It is calculated as the absolute value of the difference
between the predicted point difference and the real point difference:
margin = |point difference in tip - actual point difference in game|
For instance, again for the game between GWS Giants (home) and Melbourne (away), if a user predicts
a number 10 (meaning GWS Giant wins with a 10-point difference), but the actual point difference
is –7 (meaning GWS Giants lose with a 7-point difference), the margin received by this user for
this game will be 17.
A user’s ranking is based on his/her total score and total margin of all games predicted. The users
will first be ranked according to their total scores. If a tie occurs on the total scores of two users, the
tie will be broken by looking at these two user’s total margins: the user with smaller total margin will
have the better ranking. If ties occur on both score and margin, these two users are ranked randomly.
So far I have created a userlogin.htm which posts to userlogin.php the username and password entered.
This is what I have for my userlogin.php and it’s not working, I know something is wrong.
[php]require_once(“nocache.php”);
$id = $_POST[“id”];
$pword = $_POST[“pword”];
if (empty($id) || empty($pword)){
header(“location: userlogin.htm”);}
else {
require_once(“dbconn.php”);
$sql = "select username, score, margin from users "
$sql .= “where username = ‘$id’ and password = ‘$pword’ order by score desc”;
$rs = mysql_query($sql, $dbConn);
echo “done”;
if (mysql_num_rows($rs)> 0 ) {
session_start();
$_SESSION[“who”] = $id;
$_SESSION[“score”] = mysql_result($rs,0,“score”);
$_SESSION[“margin”] = mysql_result($rs,0,“margin”);
$_SESSION[“numrows”] = mysql_num_rows($rs);
header(“location: tipping.php”);
}
else {
header(“location: userlogin.htm”);}
}[/php]