Login Script Not working HELP !

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
VR-Fox
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2010 11:30 am

Login Script Not working HELP !

Post by VR-Fox »

I have a php login script that is not working I have looked over it several times and can not find why it is not working.
MySQL database is called "sbm" my table in the database is called "administrators" and there are 2 fields first one is called "name" second one is called "password" I have 3 records in the database. here is my code...

login.php

<form name="form1" method="post" action="auth.php">
<label>User Name
<input type="text" name="admin" tabindex="1" size="21">
</label>
<label>Password
<input type="password" name="password" tabindex="2" size="21" mask="x">
</label>
<p>
<input type="submit" name="submit" value="Login" tabindex="3">
</p>
</form>

auth.php

<? php
include_once 'Test.php';
session_start();

if (isset($_POST['submit']))
{
$admin=$_POST['admin'];
$password=$_POST['password'];
$admin=strip_tags($admin);
$password=strip_tags($password);
$password=md5($password);

$query = "select name,password from administrators where name='$admin' and '$password'";
$result = mysql_query($query) or die ("Could not query administrators");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['admin']=$admin;
echo "Logged in successfully";
}
else
{
echo "Wrong user name or password.";
echo "<a href='RecordsAdmin.php'>Continue</a>";
}
}
?>

my connection php (Test.php)

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_Test = "localhost";
$database_Test = "sbm";
$username_Test = "root";
$password_Test = "xxxxxx";
$Test = mysql_pconnect($hostname_Test, $username_Test, $password_Test) or trigger_error(mysql_error(),E_USER_ERROR);

if(!$Test) die("Could not connect to MySQL");
if(!mysql_select_db($database_Test,$Test))
die("That database does not exist");
?>

Can anyone give me any clues to why this is not working ?

VR-Fox
VR-Fox
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2010 11:30 am

Re: Login Script Not working HELP !

Post by VR-Fox »

Never Mind found the problem Stupid Picky PHP syntax had a space in the opening tag <? php instead of <?php DOH !

:)

VR-Fox
Post Reply