-
Help with login.php
I create now a better website with register and loginsystem.
but i have a problem.
my pw,user and email are prodected with 512 bits.
when i use my login panel he dont read the data from mysql ( user_data)
and dont switch to index.php.
Need help.
Code:
<? session_start(); ob_start();
include_once "connect_to_mysql.php";
if(isset($_POST['login_sub'])){
$email = $_POST['email'];
$pass = hash("sha512", $_POST['pass']);
$sql = mysql_query ("SELECT + FROM userdata WHERE email = '".mysql_real_escape_string($email)."'");
$row = mysql_fetch_object($sql);
if($row->status == 0){echo "Dein Account wurde gesperrt.";}else
if($email == $row->email){
if($pass == $row->password){
if($row->status == 1){
$_SESSION["username"] = $row->id;
mysql_query("UPDATE user_data SET online= '1'");
header("Location:index.php");}}else{echo "PW";}}else{echo "email";}
}
echo "
<form action'' method='post'>
<input type='text' name'email' required='required' placeholder='Your Email'><br>
<input type='password' name'pass' required='required' placeholder='Your Password'><br>
<input type='submit' name'login_sub' value='Einloggen'>
</form>
";
?>
-
Code:
$sql = mysql_query ("SELECT + FROM userdata WHERE email = '".mysql_real_escape_string($email)."'");
SELECT * FROM ...
You can either use an IDE with debugger or always add some print's in your code. And please post error messages next time.
-
He dont switch to index.php and dont login with email/pw.
I copy this code in my php script " error_reporting(E_ALL);" but not errors coming.
My Link:
http://kd24849.p02.zap-hosting.com/test/login.php
The "Registrierungsformular" works , He created data to mysql.
-
Make sure that your index.php is in the same directory. Try to change:
PHP Code:
header("Location:index.php");
into:
PHP Code:
header('Refresh: 1; index.php');
also name of the table is: user_data or userdata ?
-
-
Ok then in line:
PHP Code:
$sql = mysql_query ("SELECT * FROM userdata WHERE email = '".mysql_real_escape_string($email)."'");
You've got FROM userdata. As you said your db is called user_data, so should be SELECT * FROM user_data <...>
-
1 Attachment(s)
The Line ist for my connect_to_mysql.php.
I have this line in my register.php to and works.
Look:
Attachment 362
-
Edit: error fixed.
Problem: was in my userdata ( mysql) all infomations was on id = 0!