Jump to content

Trying to Create a Login System


topflight

Recommended Posts

Hi all I am trying to create a log in system with different user acesses(i.e 1=normal 2=admin and etc...). Well I am now receiving an error which says:

 

Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\logincheck.php on line 30

 

I look at like 30 and I can't find nothing wrong. I am still new to php so please bare with me. Here is my login in system code.

 

login.php

<style type="text/css">
.idBox {
width:50px;
}
.passwordBox {
width:80px;
}
</style>
</head>
<body>
<table border="0" align="center">
<form action="logincheck.php" method="post"> 
  
<tr>
    <td align="center">ID:</td><td align="center">ASA<input type="text" name="login" class="idBox"></td>
  </tr>
  <tr>
    <td align="center">Password:</td><td align="center"><input type="password" name="pwd" class="passwordBox"></td>
  </tr>
  <tr>
    <td></td><td align="center"><input type="submit" name="submit" value="Login"></td>
  </tr>
</table>
</form>

<body>

logincheck.php

 

<?php
session_start();

header("Location: crewcenter.php");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?php
include 'db.php';
?>
<?php
$login = $_POST['login'];
$pwd = $_POST['pwd'];
?>
<?php
if($_POST[submit]){

if((!$login) || (!pwd)){
echo'Please insert all of the information';
include'login.php';

} else {

$sql = "SELECT * FROM `pilots` WHERE login = `$login` AND pwd = `$pwd`";
$query = mysql_query($sql) or die mysql_error());
$pcheck = mysql_num_rows($query);

if($pcheck==0){
echo'Incorrect Login Information';
} else {

session_register('login');
$_SESSION['login'] = $login;

session_register('pwd');
$_SESSION['pwd'] = $pwd;

session_register('fname');
$_SESSION['fname'] = $fname;

session_register('lname');
$_SESSION['lname'] = $lname ;

}

}
?>

crewcenter.php

<?php

session_start(); 

session_checker(); 

function session_checker(){ 

if(!session_is_registered('login')){

include 'login.php'; 

exit(); 

} 

} 

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

 

This is line 30 where I am receiving the problems.

<?php $query = mysql_query($sql) or die mysql_error());?>

 

Also please give me any suggestions on my login code.

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/129961-trying-to-create-a-login-system/
Share on other sites

thanks but... when I type the correct information from the database in the form it goes to crewcenter.php but instead of displaying a white page since the password and login is write it just keep reshowing the login form. I wonder why is that happening.

put this in crewcenter.php instead...

 

<?php

session_start(); 

session_checker(); 

function session_checker(){ 

if(!session_register('login')){

include 'login.php'; 

exit(); 

} 

} 

?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
</body>
</html>

The following line in logincheck.php is unconditionally redirecting to crewcenter.php -

 

header("Location: crewcenter.php");

 

Programs only do what the code tells them to do. Why do you have that line of code near the start of logincheck.php?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.