PDA

View Full Version : Some PHP help please


arenlor
03-17-2007, 01:08 AM
The code is as follows (I removed my mysql connection stuff, but that all works, it's the header redirect that's giving me an issue, $logum is 1.<?php $user = $_POST['username'];
$pass = $_POST['password'];
$gold = "select username,password from blogs where username=MD5('$user') and password=SHA1('$pass')";
$log = mysql_query($gold);
$logum = mysql_num_rows($log);
if($logum == 1){header("Location:index2.php");} ?>
<p>Please login below, if you don't have a login please <a href="register.php" title="register">register</a>.</p>
<?php echo "<form action=\"$PHP_SELF\" method=\"post\"><input type=\"text\" name=\"username\" id=\"username\" /><input type=\"password\" name=\"password\" id=\"password\" /><input type=\"submit\" value=\"Login\" /></form>"; ?>The page that this is is http://arenblogs.com/login.php The user and pass are 'test' no 's

UnlimitedMB
03-17-2007, 01:28 AM
1. this code is insecure, pass all user changable variables through mysql_escape_string() before using in a mysql query.

2. you need a space after Location: and then exit;

arenlor
03-17-2007, 04:36 AM
I was assuming you had magic quotes on

cr0wonline
03-17-2007, 08:20 PM
Actually Eric, mysql_real_escape_string() is much better to use ;)

Also, exit; is optional, as it is automatically executed by the server if it doesn't exist.