Hopefully someone can help me,
I am trying to create a members area where a user ID and password is entered to access the area. If the user does not exist they have to create one and this is entered into a mysql database (this bit works fine), but when the user then tries to logon it fails in the code and I cannot find where, the code for the logon inspection is written below:-
<?php
sessiom_start();
if (isset($_POST['userid']) && isset($_POST['pass']))
//if the user has just tried to login
$username="web21-logon";
$password="logon";
$database="web21-logon";
$userid = $_POST['userid'];
$newpass = $_POST['pass'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = 'select * from login'
."where Username='$userid'"
." and Password='$newpass'";
$result=mysql_query($query);
if ($result->num_rows >0)
{
//if they are in the database register the user ID
$_SESSION['valid_user']=$userid;
}
mysql_close();
?>
<h1>Home page</h1>
<?
if (isset($_SESSION['valid_user']))
{
echo 'You are logged in as: '.$_SESSION['valid_user'].' <br />';
echo '<a href="logout.php">Log out</a><br />;
}
?>
I am trying to create a members area where a user ID and password is entered to access the area. If the user does not exist they have to create one and this is entered into a mysql database (this bit works fine), but when the user then tries to logon it fails in the code and I cannot find where, the code for the logon inspection is written below:-
<?php
sessiom_start();
if (isset($_POST['userid']) && isset($_POST['pass']))
//if the user has just tried to login
$username="web21-logon";
$password="logon";
$database="web21-logon";
$userid = $_POST['userid'];
$newpass = $_POST['pass'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = 'select * from login'
."where Username='$userid'"
." and Password='$newpass'";
$result=mysql_query($query);
if ($result->num_rows >0)
{
//if they are in the database register the user ID
$_SESSION['valid_user']=$userid;
}
mysql_close();
?>
<h1>Home page</h1>
<?
if (isset($_SESSION['valid_user']))
{
echo 'You are logged in as: '.$_SESSION['valid_user'].' <br />';
echo '<a href="logout.php">Log out</a><br />;
}
?>