the php code generated is when I entered the result from the browser on phpmyadmin sql interface, it ran okay and I clicked Create PHP Code.
I am connecting to the right database, which details are below:
PHP Code:
//mysqli_connect.php
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD', 't1212');
DEFINE ('DB_HOST', 'localhost');
DEFINE ('DB_NAME', 'test');
//Make the connection to the database.
$dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
OR die ('Could not connect to MYSQL: ' . mysqli_connect_error());
Could there be something wrong with this code snippet?:
PHP Code:
if(isset ($_POST['submit'])){
$username = strip_tags($_POST['username']);
$password = strip_tags($_POST['pwd']);
if (isset ($username) && isset ($password))
{
$sql = "SELECT * FROM users WHERE user_name = '$username' AND pass = SHA1('$password')";
$rs = mysqli_query($dbc,$sql ) OR die (mysqli_error($dbc));
$row = mysqli_fetch_assoc($rs);
if(mysql_num_rows($row)>0)
{
if($row['user_level']== 'admin')
{
header("Location:admin/welcome_admin.php");
}
else{
header("Location:admin/register.php");
}
}
}
Help is appreciated
Bookmarks