Hello, I wonder what's the different between online and offline. This script works offline, after I have it online, there are some problems occur. For instance, after login to the admin with the correct username and password, I suppose to be taken to the admin page, instead I get stucked at 1. (echo $count).
Last time, I had mixed up slash "/" and backslash "\"
slash works offline (in windows) then after upload it online the web hosting customer support said it suppose to be backslash (in linux).
This time, I wonder why the script stuck at 1.
proses.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "rustoleum";
mysql_connect($servername, $username, $password) or die("Not connected");
mysql_select_db($database) or die("Not connected to the database");
/* the files */
// username and password sent from form
$username=$_POST['username'];
$password=$_POST['password'];
// To protect MySQL injection (more detail about MySQL injection)
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$encrypted_password = md5($password);
$sql=("SELECT * FROM user WHERE username='$username' and password='$encrypted_password'") or die(mysql_query);
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
echo $count;
echo "lanjut";
// If result matched $username and $password, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("password");
header("location:admin.php");
}
else {
echo "Wrong Username or Password";
}
?>