Page 1 of 1
Database Handling
Posted: Mon Jun 06, 2005 2:24 am
by NewinPHP
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.
Posted: Mon Jun 06, 2005 3:38 am
by anjanesh
Theres quite a bit you need to do for this. Read
Sessions.
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>
auth.php
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();
Have all your session functions in some file - asssuming you are writing sessions to db and not using files.
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)
{
}
Posted: Mon Jun 06, 2005 8:07 pm
by method_man
by putting the sessions in any file you mean just save them with any name like sessions.php? im confused
Posted: Tue Jun 07, 2005 12:20 am
by anjanesh
The session functions can be anywhere as long as you include it in your scripts.
Sessions can be stored either in a file or in a db.
Session stored in files will be in some tmp folder while for db you'll have to define the functions to handle session handling.
Posted: Tue Jun 07, 2005 3:54 pm
by method_man
ok thanks
