Hi, I don’t have that much experience with php coding yet and for that reason cannot find the mistake in if statement that is hindering me to be able to login. Here is the code:
<?php if(empty($_POST)) { $status = 'Type your username and password below to log in.'; } else { $user = $_POST['user']; $passwd = $_POST['passwd']; } $error_list = array(); if(empty($user)) { $error_list[] = 'Please enter your username.'; } if(empty($passwd)) { $error_list[] ='Please enter your password'; } if(empty($error_list)) { require('../../sql_connect.php'); $sql = "SELECT id "; $sql .= "FROM members "; $sql .= "WHERE user='$user' "; $sql .= "AND pass='$passwd' "; $result = mysql_query($sql); if(mysql_num_rows($result) == 1) { session_start(); $_SESSION['logged_in'] = true; header('Location: index.php?mnu=home'); } else { $status = 'The username and/or password you supplied was incorrect.'; } } else { $status = '- ';
foreach($error_list as $error_message) {
$status .= "
- $error_message "; } $status .= '
The if statement that holds the code for the “== 1” is not functioning correct. In fact the error that I am getting is:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/investp8/public_html/admin/login_head.php on line 26
Can anyone help me?