Is this code right?

From: Date: Mon, 19 Jan 2004 17:22:52 +0000
Subject: Is this code right?
Groups: php.general 
Request: Send a blank email to php-general+get-175045@lists.php.net to get a copy of this message
Hi all.. I made this code for the login.php page.. it will compare A value from the users machine (Serial) and with a value inside the database (In that users' row).. so after logging it will check if also this value is the same and then echo something..is the following code is right for that? : <?php $link = mysql_connect("localhost", "Database username", "Database password) or die("Could not connect: " . mysql_error()); mysql_select_db("Table name", $link); $UserName = $_GET['UserName']; $Password = $_GET['Password']; $Serial = $_GET['Serial']; $query = "SELECT Serial, Password from accounts where UserName='$UserName'"; $result = mysql_query($query) or die("Query errort: " . mysql_error()); $row = mysql_fetch_row($result) or die("User Not found: " . mysql_error()); $Serial = htmlspecialchars($row[0]); $UserPassword = $row[1]; $UserSerial = $row[1]; mysql_close($link); if($UserSerial == $Serial){ print<<<END <HTML> <BODY> Right serial! </BODY></HTML> END; }else{ print<<<END <HTML> <BODY> Sorry, wrong serial! </BODY></HTML> END; } if($UserPassword == $Password){ print<<<END <HTML> <BODY> Logged in successfully </BODY></HTML> END; }else{ print<<<END <HTML> <BODY> Sorry, wrong password! </BODY></HTML> END; } ?> -------------------------------------------------------------------------------- Please notice : " PHP: ------------------------------------------------------------------------------ $UserSerial = $row[1]; ------------------------------------------------------------------------------ " must I put it " PHP: ------------------------------------------------------------------------------ $UserSerial = $row[2]; ------------------------------------------------------------------------------ " or something else? Regards.. Waiting your reply..

« previous php.general (#175045) next »