PDA

View Full Version : Help with login.php



STAUFFi
31st July 2013, 02:43
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.


<? 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>
";
?>

kung foo man
31st July 2013, 08:56
$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.

STAUFFi
31st July 2013, 09:24
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.

Jeplaa
31st July 2013, 09:36
Make sure that your index.php is in the same directory. Try to change:
header("Location:index.php");

into:
header('Refresh: 1; index.php');

also name of the table is: user_data or userdata ?

STAUFFi
31st July 2013, 10:00
its user_data

Jeplaa
31st July 2013, 12:33
Ok then in line:
$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 <...>

STAUFFi
31st July 2013, 12:35
The Line ist for my connect_to_mysql.php.
I have this line in my register.php to and works.


Look:
362

STAUFFi
15th August 2013, 10:36
Edit: error fixed.
Problem: was in my userdata ( mysql) all infomations was on id = 0!