Hi,
New to PHP if you could please let me know how do we write in php to create a Login form and store it in a sql database.
Thanks,
I will really appreciate it.
Database Handling
Moderator: General Moderators
Theres quite a bit you need to do for this. Read Sessions.
auth.php
Have all your session functions in some file - asssuming you are writing sessions to db and not using files.
Code: Select all
<form action="e;auth.php"e; method="e;post"e;>
<input type="e;text"e; name="e;username"e;/>
<input type="e;password"e; name="e;password"e;/>
<input type="e;submit"e; name="e;btn"e; value="e;Login"e;/>
</form>Code: Select all
// Connect to the db
mysql_connect($host,$db_username,$db_password) or die("Could not connect to the Database");
mysql_select_db($db_databasename) or die("Could not select database");
// Do all the checking for username and password - $_POST['username'] and $_POST['password']
mysql_query("INSERT INTO 'LoginStats' VALUES()");
session_module_name("user");
session_set_save_handler("Session_Open","Session_Close","Session_Read","Session_Write","Session_Remove","Session_GC");
session_start();Code: Select all
function Session_Open($path,$name)
{
}
function Session_Close()
{
}
function Session_Read($id)
{
}
function Session_Write($id,$data)
{
}
function Session_Remove($id)
{
}
function Session_GC($life)
{
}-
method_man
- Forum Contributor
- Posts: 257
- Joined: Sat Mar 19, 2005 1:38 am