Baz Khilji
New member
please can some one help correct this code. ive never used sqlite before and haven't got much php 5 experiance
<html>
<head>
<?php
error_reporting (E_ALL);
$user = " ";
$pass = " "; // ensures that no values are allocated to $user and $pass before any action is taken
if(isset($_POST['user']))
{ $user = $_POST['user']; // is the user field was filled make '$user' be its reference tag
}
if(isset($_POST['pass']))
{ $pass = $_POST['pass']; // // is the pass field was filled make '$pass' be its reference tag
}
$dbh = new PDO("sqlite:accounts"); // connect to the database in the same directory
$query="SELECT * FROM accounts WHERE username='$user'"; // select all records where the username matchs $user
if($query!==1) echo"User not found, "; // if there are 0 or more than 1 result
$row=($query); // reference the result of the above query
if($row['password']!==$pass){ //if the pass word field doesnt match the $pass
echo"bad pass"; //print "bad pass" to screen
}
else echo '<URL=home.php">'; //if all matches redirect to home.php
?>
</head>
<body>
<h1 align="center"> the car company </h1>
<table width="300" border="3" align="left" cellpadding="0" cellspacing="1" bgcolor="YELLOW">
<tr>
<form action="login.php" method="post" >
<td>
<table width="100%" border="8" cellpadding="3" cellspacing="1" bgcolor="YELLOW">
<tr>
<td colspan="3"><strong>SIGN IN</strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="user" type="text" id="user"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="pass" type="password" id="pass"></td></tr>
<tr><td>
<input type="submit" name="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<?php
error_reporting (E_ALL);
$user = " ";
$pass = " "; // ensures that no values are allocated to $user and $pass before any action is taken
if(isset($_POST['user']))
{ $user = $_POST['user']; // is the user field was filled make '$user' be its reference tag
}
if(isset($_POST['pass']))
{ $pass = $_POST['pass']; // // is the pass field was filled make '$pass' be its reference tag
}
$dbh = new PDO("sqlite:accounts"); // connect to the database in the same directory
$query="SELECT * FROM accounts WHERE username='$user'"; // select all records where the username matchs $user
if($query!==1) echo"User not found, "; // if there are 0 or more than 1 result
$row=($query); // reference the result of the above query
if($row['password']!==$pass){ //if the pass word field doesnt match the $pass
echo"bad pass"; //print "bad pass" to screen
}
else echo '<URL=home.php">'; //if all matches redirect to home.php
?>
</head>
<body>
<h1 align="center"> the car company </h1>
<table width="300" border="3" align="left" cellpadding="0" cellspacing="1" bgcolor="YELLOW">
<tr>
<form action="login.php" method="post" >
<td>
<table width="100%" border="8" cellpadding="3" cellspacing="1" bgcolor="YELLOW">
<tr>
<td colspan="3"><strong>SIGN IN</strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="user" type="text" id="user"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="pass" type="password" id="pass"></td></tr>
<tr><td>
<input type="submit" name="submit" value="submit" /></td>
</tr>
</table>
</form>
</body>
</html>