Jump to content

Recommended Posts

i need help with this login form im not sure whats wrong with it i just het a blank page when i try to load the form.... im using this youtube tutorial 

 
<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start ();
?>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>Login</title>
</head>
<body>
   <?php
   
   $form = "<form action='./login.php' method='post'>
   <table>
   <tr>
      <td>Username:</td>
   <td><input type='text' name='user' /></td>
   
   </tr>
   <tr>
  
      <td>Password:</td>
   <td><input type='password' name='password' /></td>
   
   </tr>
   <tr>
   
      <td></td>
   <td><input type='submit' name='loginbtn' value='Login' /></td>
  
   </tr>
   <table>   
   </form";
   
   if ($_POST['loginbtn']){
    $user = $_POST['user'];
    $password = $_POST ['password'];
    
if ($user){
if ($password){
require("connect.php");
 
$password = md5(md5("yjtfjtfjj".$password."xjtfjtfjj"));
 
 
$query = mysql_query("SELECT * FROM users WHERE username='$user'");
$numrows = msql_num_rows($query);
if ($numrows == 1){
$row = mysql_fetch_assoc($query); 
$dbid = $row['id'];
$dbuser = $row['username'];
$dbpass = $row['password'];
$dbactive = $row['active'];
 
if ($password == $dbpass){
if dbactive == 1){
$_SESSION['userid'] = $dbid;
$_SESSION['username'] = $dbuser;
 
echo "you have been logged in as <b>$dbuser</b> <a href './members.php'> Click here</a> to go to the Members page";
}
else 
echo "you must activate your account to login $form";
}
else 
echo "incorrect password $form";
 
 
}
else 
echo "Incorrect username. $form";
      mysql_close();
     }
     else
      echo "You must enter your password. $form";
    
           }
           else
                echo "You must enter your username. $form";
   
    }
    else
       echo $form;
    ?>
</html>
Edited by CripDawg
Link to comment
https://forums.phpfreaks.com/topic/294954-php-login-form-problem/
Share on other sites

your code has a typo error on line 57 and throws the following php syntax error - Parse error: syntax error, unexpected 'dbactive' (T_STRING), expecting '(' in your_file.php on line 57

 

look at line 57 in your code and try to determine what's missing on that line (the error message actually says.)

 

you need to have php's error_reporting set to E_ALL and display_errors set to ON in your php.ini on your development system to get php to help you, by reporting all the errors it detects. parse errors like this one prevent your code from ever running, so putting any sort of error_reporting/display_errors settings in your code won't do anything in this case. also, by having these settings in your php.ini, you don't ever need to remember to put them into code for testing and remove them when you put code onto a live server.

 

fixing the typo error on line 57 will let your code run and display the form.

your code has a typo error on line 57 and throws the following php syntax error - Parse error: syntax error, unexpected 'dbactive' (T_STRING), expecting '(' in your_file.php on line 57

 

look at line 57 in your code and try to determine what's missing on that line (the error message actually says.)

 

you need to have php's error_reporting set to E_ALL and display_errors set to ON in your php.ini on your development system to get php to help you, by reporting all the errors it detects. parse errors like this one prevent your code from ever running, so putting any sort of error_reporting/display_errors settings in your code won't do anything in this case. also, by having these settings in your php.ini, you don't ever need to remember to put them into code for testing and remove them when you put code onto a live server.

 

fixing the typo error on line 57 will let your code run and display the form.

i dont see any typo on that line?

EDIT: i found it but now when i log in with my account it shows another blank page when it should say 'you have been looged in as my usename

Edited by CripDawg

That's an old and unsecured login tutorial, try to find one incorporating mysqli_* or pdo and using something like crypt or password_hash

im not really interested in finding a different tutorial this is only needs to be simple demonstration it wont actually be put into use

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.