Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi I've been working on a script an

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi I've been working on a script and I've done all the sign up pages and stuff but I don't know how to do it so the user can login and view there information. What I need todo is just have a basic login for the different users and I want to make sure that the pages are secure.

The user records are stored in the users_tbl and the login form has the text boxes login [the username] & pass [the password] and the page they redirect to is team.php

So far I've come up with the following but it doesn't work. I'd be greatful if you could show me what is wrong and please could you show me how I can make the team.php secure. Thanx

<?
require(&quot;config.inc.php&quot;);
$db = mysql_connect($host,$login,$pass);
mysql_select_db($base,$db);

$sql = &quot;select pass from users_tbl where login='$login'&quot;;
$req = mysql_query($sql) or die('SQL Error !<br>'.$sql.'<br>'.mysql_error());

$data = mysql_fetch_array($req);

if($data['pass'] = $pass)
{
session_start();
session_register('login');
header('LOCATION: team.php');
}
else
{
echo '<p>Wrong name/pass. Try again</p>';
include('login.php');
exit;
}
?>
 
The only error I acan spot is in this bit :

if($data['pass'] = $pass)
{
session_start();
session_register('login');
header('LOCATION: team.php');
}
else


Should be :

if($data['pass'] == $pass)
{
session_start();
session_register('login');
header('LOCATION: team.php');
}
else


You need double equal signs for equal to Regards

Big Bad Dave

logo.gif


davidbyng@hotmail.com
 
Ah that's great cheers mate, do you know how I can make the page that it goes to secure so the users can't just put in team.php?id=??

I tried using an include statement for the page verif.php for the pages I wanted to secure and used the following code but it didn't work. Thanx

<?
session_start();

if(!session_is_registered('login'))
{
echo 'You are not logged in';
include('login.html');
exit;
}
?>
 
that's the way.

if you put that piece of code in all the secured pages you can verifty if he is logged in or not.
Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top