Jump to content

Login script


unistake

Recommended Posts


Hi all again,

 

This script was working perfectly but I have not got a clue what changed in it or how and can not seem to find the problem.

 

The connection works, email and password variables match the mysql databases so must be my Syntax.

 

appreciate if you can help.

 

<?php

include("../cxn.php");

$sql = "SELECT password FROM Members WHERE email='$_POST[email]'";
$result = mysqli_query($cxn,$sql)
or die ("Couldn't execute query1");

$num = mysqli_num_rows($result);
if ($num >0) // Login Name found 
{
	$sql = "SELECT * FROM Members WHERE email='$_POST[email]' AND password=md5('$_POST[password]')";
	$result2 = mysqli_query($cxn,$sql)
		or die ("Couldn't execute query2");
	$num2 = mysqli_num_rows($result2);
	if ($num2 > 0) // password correct
		{
			session_start();
			$_SESSION['auth']="yes";
			$_SESSION['logname'] = $_POST['email'];
			$logname = $_SESSION['logname'];
			$today = date("Y-m-d h:i:s");
			$sql = "INSERT INTO Login (email,loginTime)
					VALUES ('$logname', '$today')";
			$result = mysqli_query($cxn,$sql)
				or die ("Can't execute insert query");
			echo "you have logged in!";
			header("Location: ../$_POST

");
		}
	else 
		{
			$message = "The email address, '$_POST[email]' is registered, but you have not entered the correct password! Please try again.<br>";
			include("../login.html");
		}
}

?>

Link to comment
https://forums.phpfreaks.com/topic/216104-login-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.