Wondering how I can stop certain infomation from showing
Posted: Mon Dec 04, 2006 3:33 am
Wondering how I can stop certain infomation from showing if your username & password isnt correct
thats the code, where would I put stuff so if it doesnt find ur details in the Data base, it wont show the err, Buttons for the home page (for logged in only)
Code: Select all
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
if (!$con = mysql_connect("localhost","root",""))
{
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db("userdetails", $con))
{
die('Could not select the database: ' . mysql_error());
}
// Check to see if this var is set
if (isset($_POST['login']))
{
$login = mysql_real_escape_string($_POST['login']);
$password = mysql_real_escape_string($_POST['loginpw']);
$sql = "SELECT * FROM `users` WHERE `username` = '$login' AND `userpass` = '$password'";
if (!$result = mysql_query($sql))
{
die('Could not execute the query: ' . mysql_error());
}
while($row = mysql_fetch_array($result))
{
echo $row['username'] . ' ' . $row['password'] . '<br />';
}
}
else
{
echo 'The post var login was not set';
}
?>