Help please... stuck on this..

[code]<?php
session_start();
$title = “Productions - Login”; ?>

<?php require("styles/top.php") ?>
<?php
$form = "<form action='login.php' method='post'>
<table>
<tr>
<td>Username:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password'></td>
</tr>
<tr>
<td></td>
<td><input type='submit' name='loginbtn' value='Login'></td>
</tr>
</table>
</form>";

if ($_POST['loginbtn']){
	$username = strip_tags($_POST['username']);
	$password = strip_tags($_POST['password']);
		
		if($username && $password){
			require("scripts/config.php");
			$pass = md5($password);
			
			$query = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password'");
			$numrows = mysql_num_rows($query);
			
			if($numrows == 1){
			
				$row = mysql_fetch_assoc($query);
				$dbid = $row['id'];
				$dbuser = $row['username'];
				
				$_SESSION['user'] = $dbuser;
				$_SESSION['userid'] = $dbid;
				
				echo "<b>$dbuser</b> you have been successfully logged in.";
			}
			else
				echo "You login informations was incorrect. $form";
		}
		else
			echo "You did not fill in the fields. $form";
			
	}
	else{
		echo "$form";
}
?>
<?php require("styles/bottom.php") ?>[/code]

hey if anyone can help me with this i am new to PHP and could use some help.

What are you trying to do? Are you getting any specific errors? What’s the problem?

No errors that i can see i dont know how to debug a login page. but it just says one of my echos which all my info is correct so i dont know why it echos that.

What’s being displayed?

Also it may have been added for shorthand and I wasn’t aware but its good practice regardless to make sure you have a curly bracket “{/}” after your 'else" you have some and then some don’t.

If you’re getting an incorrect password statement it might be because in your query you are comparing the db to $password which isn’t encrypted yet, change that to $pass it may work.

Also I would suggest using a little more than striptags to secure user input. Hope this helps give it a try and see if it works,

Sponsor our Newsletter | Privacy Policy | Terms of Service