Log in php help.


$username = $_POST[‘username’];
$password = $_POST[‘password’];

if ($username&&$password)

$connect = mysql_connect(“dsql.somewebhosting.com”,“a6193817_FAKE”,“jfake”) or die(“Sorry, coudn’t connect!”);
mysql_select_db(“a6243817_phplog”) or die (“Couldn’t find db”);
die(“Please enter Username, and Password!”);


Can anyone either make that a little more advanced, I want it to where the log in usses cookies, and tells me if that username doesn’t exsist, ect. Please help.

Code depends on structure of your database (users table). You need to query user by username and compare password. Just like this:
$r = mysql_query(“select * from users where username=’”.addslashes($username)."’");
$f = mysql_fetch_array($r);
if($f[‘Passw’] != md5($password)){
die(‘Check your password and try again!’);
die(‘Access denied!’);

Sponsor our Newsletter | Privacy Policy | Terms of Service