本帖最後由 oliverlau 於 2017-1-2 02:06 編輯
請教各位幫我睇睇有咩問題,出唔到結果
<?php
require('config.php');
$email = $_POST['email'];
$password = $_POST['password'];
$refer = $_POST['refer'];
if ($email == '' || $password == '')
{
// No login information
header('Location: login.php?refer='. urlencode($_POST['refer']));
}
else
{
// Authenticate user
$con = mysqli_connect("localhost", "admin", "12345678","member");
if (!$con) {
die("Database connection failed: " . mysqli_error());
}
$db_select=mysqli_select_db($con,"tiffinet_member");
if (!$db_select) {
die("Database selection failed: " . mysqli_error());
}
$query = "SELECT userid, MD5(UNIX_TIMESTAMP() + userid + RAND(UNIX_TIMESTAMP()))
guid FROM susers WHERE email = '$email' AND password = password('$password')";
$result = mysqli_query($con,$query);
if ( false===$result ) {
printf("error: %s\n", mysqli_error($con));
}
if (mysqli_num_rows($result))
{
$row = mysqli_fetch_row($result);
// Update the user record
$query = "UPDATE susers SET guid = '$row[1]' WHERE userid = $row[0]";
mysqli_query($con,$query)
or die('Error in query2');
// Set the cookie and redirect
// setcookie( string name [, string value [, int expire [, string path
// [, string domain [, bool secure]]]]])
// Setting cookie expire date, 6 hours from now
$cookieexpiry = (time() + 21600);
setcookie("session_id", $row[1], $cookieexpiry);
if (empty($refer) || !$refer)
{
$refer = 'test.php';
}
header('Location: '. $refer);
}
else
{
// Not authenticated
header('Location: login.php?refer='. urlencode($refer));
}
}
?> |