Im looking for help with the following code, I think i done it right but im getting errors on line 13 and line 16, My data in the mysql is under userName and userPass (encrypted) but when i hit the submit button im getting an error, Here is the original code, can anyone shed any light on it for me please. my database table name is ‘users’ once submitted i need it to redirect to display_data.php i have already set the confip.php file up.
[code=php]
<?php
include(“config.php”);
session_start();
if($_SERVER[“REQUEST_METHOD”] == “POST”) {
// username and password sent from form
$myusername = mysqli_real_escape_string($db,$_POST[‘username’]);
$mypassword = mysqli_real_escape_string($db,$_POST[‘password’]);
$sql = “SELECT id FROM admin WHERE username = ‘$myusername’ and passcode = ‘$mypassword'”;
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$active = $row[‘active’];
$count = mysqli_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count == 1) {
session_register(“myusername”);
$_SESSION[‘login_user’] = $myusername;
header(“location: welcome.php”);
}else {
$error = “Your Login Name or Password is invalid”;
}
}
?>
Do i change the following line to this
[code=php] $sql = “SELECT id FROM users WHERE username = ‘$userName’ and passcode = ‘$userPass'”;