Hi,
I need to make a user login page where they just enter the details (username and password) and it carry's those variables to the login process page. I can dot hat but i need to know, without using sessions or anything how to get the username form the database and then compare the stored password for it.
I seem to always be getting pages showing me i need to use sessions but i wish not to use them on this occasion.
I would be very gratefull for some help in creating the login process php page.
Thanks,
Danco
comparing 2 database fields
Moderator: General Moderators
This a somewhat simple. There are many ways to skin a cat.
If you are not going to use session variables you will need to check that a user is logged in on every page.
This isn't guaranteed to be error free - use at own risk.
Good Luck!
If you are not going to use session variables you will need to check that a user is logged in on every page.
This isn't guaranteed to be error free - use at own risk.
Good Luck!
Code: Select all
<?php if($_POST['submit']=="") { ?>Code: Select all
<form method="post" action="">
Login Page - Form with three inputs
Username:<input type="text" name="username"><br>
Password:<input type="password" name="password"><br>
<input type="submit" name="submit" value="submit">Code: Select all
} else if($_POST['submit']=="submit") {
$query = "SELECT * FROM db.table " .
"WHERE " .
"username = " . $_POST['username'] . " " .
"AND " .
"password = " . $_POST['password'] ;
$connection = mysql_connect(your db stuff here) ;
$db = mysql_select_db("your_db_name") ;
$result = mysql_db_query($query,$connection) ;
$row = mysql_fetch_assoc($result)
if ($row<>"") {
header ("Location: http://abc.def.com/login.php") ;
} else {
header ("Location: http://abc.def.com/you_are_logged_in.php") ;
} // end of row conditional
}// end of post conditional