Results 1 to 8 of 8

Thread: Help with login.php

  1. #1
    Corporal STAUFFi's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    269
    Thanks
    106
    Thanked 128 Times in 83 Posts

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

  2. #2
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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.
    timescale 0.01

  3. The Following 2 Users Say Thank You to kung foo man For This Useful Post:

    Jeplaa (31st July 2013),STAUFFi (31st July 2013)

  4. #3
    Corporal STAUFFi's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    269
    Thanks
    106
    Thanked 128 Times in 83 Posts
    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.
    Last edited by STAUFFi; 31st July 2013 at 09:31.

  5. #4
    Private First Class
    Join Date
    Dec 2012
    Posts
    127
    Thanks
    132
    Thanked 114 Times in 63 Posts
    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 ?
    Last edited by Jeplaa; 31st July 2013 at 09:43.

  6. #5
    Corporal STAUFFi's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    269
    Thanks
    106
    Thanked 128 Times in 83 Posts
    its user_data
    Last edited by STAUFFi; 31st July 2013 at 10:07.

  7. #6
    Private First Class
    Join Date
    Dec 2012
    Posts
    127
    Thanks
    132
    Thanked 114 Times in 63 Posts
    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 <...>

  8. The Following User Says Thank You to Jeplaa For This Useful Post:

    kung foo man (31st July 2013)

  9. #7
    Corporal STAUFFi's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    269
    Thanks
    106
    Thanked 128 Times in 83 Posts
    The Line ist for my connect_to_mysql.php.
    I have this line in my register.php to and works.


    Look:
    Click image for larger version. 

Name:	11.PNG 
Views:	76 
Size:	89.3 KB 
ID:	362
    Last edited by STAUFFi; 31st July 2013 at 12:39.

  10. #8
    Corporal STAUFFi's Avatar
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    269
    Thanks
    106
    Thanked 128 Times in 83 Posts
    Edit: error fixed.
    Problem: was in my userdata ( mysql) all infomations was on id = 0!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •