LaughingKor
Banned
- Joined
- Jan 6, 2013
- Messages
- 12,496
- Reaction score
- 0
Currently working on the login / doLogin page, the username and password i entered is correct however it just shows the 'else' statement, " $msg = "<p>Sorry, you must enter a valid username and password to log in.<a href='login.php'>Back</a></p>";.
Any help will be greatly appreciated
These are taken from the input of the previous page (login).
these are the from the columns of the database
Any help will be greatly appreciated
Code:
<?php
session_start();
$msg = "";
if(!isset($_SESSION['email'])) {
if (isset($_POST['email'])) {
$entered_email = $_POST['email'];
$entered_password = $_POST['password'];
include ("dbFunctions.php");
$query = "SELECT * FROM parent WHERE parent_email = '$entered_email' AND parent_password = SHA1('$entered_password')";
$result = mysqli_query($link, $query) or die(mysqli_error($link));
if (mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_array($result);
$_SESSION['parent_id'] = $row['parent_id'];
$_SESSION['full_name'] = $row['full_name'];
$_SESSION['email'] = $row['parent_email'];
$_SESSION['parent_address'] = $row['parent_address'];
$_SESSION['role'] = $row['role'];
$msg = "<p><i>Welcome, " . $_SESSION['email'] . "!</i>";
$msg .= "<i><br/>Go to <a href='index.php'>Home</a></p></i>";
} else {
$msg = "<p>Sorry, you must enter a valid username and password to log in.<a href='login.php'>Back</a></p>";
Code:
$_POST['email'] and $_POST['password']
These are taken from the input of the previous page (login).
Code:
if (mysqli_num_rows($result) == 1) {
$row = mysqli_fetch_array($result);
$_SESSION['parent_id'] = $row['parent_id'];
$_SESSION['full_name'] = $row['full_name'];
$_SESSION['email'] = $row['parent_email'];
$_SESSION['parent_address'] = $row['parent_address'];
$_SESSION['role'] = $row['role'];
these are the from the columns of the database