FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Developing a Login Script for Website





HussanAli
Hey , i want to know how to add membership or login system for my WebSite ? Any suggestions
flatliner
A simple Mysql and PHP soltuions would do the job grand. Its easy if you know PHP and abit of Mysql. Basicly what you do is when a user signs up hes/her details get place in the Mysql database, eg password and username. Then when they go to log in its just an easy Mysql query of the database amd an php if() statment. If the infromation ths user has put in matchs one of the rows of infromation the the mysql database redriect them here or for more secuity, start session. I have a few of these type of scripts on some of my websites, I will see what I can do about postting them.
Clever_As_Sin
Try using PHP::Auth library: http://pear.php.net/package/Auth. It is free, effective and easy to use.
A typical example of using is:
Code:

require_once "Auth.php";

// Takes three arguments: last attempted username, the authorization
// status, and the Auth object.
// We won't use them in this simple demonstration -- but you can use them
// to do neat things.
function loginFunction($username = null, $status = null, &$auth = null)
{
    /*
     * Change the HTML output so that it fits to your
     * application.
     */
    echo "<form method=\"post\" action=\"test.php\">";
    echo "<input type=\"text\" name=\"username\">";
    echo "<input type=\"password\" name=\"password\">";
    echo "<input type=\"submit\">";
    echo "</form>";
}

$options = array(
  'dsn' => "mysql://user:password@localhost/database",
  );
$a = new Auth("DB", $options, "loginFunction");

$a->start();

if ($a->checkAuth()) {
    /*
     * The output of your site goes here.
     */
}
thinkingskull
<html>
<body>

<h3>PHP User Registration Form</h3>

<?
// only validate form when form is submitted
if(isset($_POST["submit_button"])){
$error_msg='';
if(trim($_POST["username_input"])=='' || strlen(trim($_POST["username_input"])) < 6 || strlen(trim($_POST["username_input"])) > 15) {
$error_msg.="Please enter a username between 6 to 15 characters long<br>";
}
if(trim($_POST["password_input"])=='' || strlen(trim($_POST["password_input"])) < 4) {
$error_msg.="Please enter a password at least 4 characters long<br>";
}
if(trim($_POST["email_input"])=='') {
$error_msg.="Please enter an email<br>";
} else {
// check if email is a valid address in this format username@domain.com
if(!ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]", $_POST["email_input"])) $error_msg.="Please enter a valid email address<br>";
}

// display error message if any, if not, proceed to other processing
if($error_msg==''){
// other process here
} else {
echo "<font color=red>$error_msg</font>";
}
}
?>

<form method="POST" action="registration.php">
<table border="1" cellpadding="7" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="16%" align="right">First Name</td>
<td width="84%">
<input type="text" name="first_name_input" size="20" value="<? echo $first_name_input; ?>"></td>
</tr>
<tr>
<td width="16%" align="right">Last Name</td>
<td width="84%">
<input type="text" name="last_name_input" size="20" value="<? echo $last_name_input; ?>"></td>
</tr>
<tr>
<td width="16%" align="right">Username</td>
<td width="84%">
<input type="text" name="username_input" size="20" value="<? echo $username_input; ?>"> (between
6 to 15 characters)</td>
</tr>
<tr>
<td width="16%" align="right">Password</td>
<td width="84%">
<input type="password" name="password_input" size="20" value="<? echo $password_input; ?>">
(must be at least 4 characters)</td>
</tr>
<tr>
<td width="16%" align="right">Email</td>
<td width="84%">
<input type="text" name="email_input" size="20" value="<? echo $email_input; ?>"></td>
</tr>
<tr>
<td width="16%" align="right"> </td>
<td width="84%">
<input type="submit" value=" Register " name="submit_button"></td>
</tr>
</table>
</form>

</body>
</html>
thinkingskull
the above script will validate the submitted info....

u cn then add the info into the db....

i think some one before me has already told u tht.... Very Happy Very Happy Very Happy Very Happy
DanielXP
http://rmb-scripting.com/tutorials.php?tutorial&tid=58

And theres a load of addons for it.

http://rmb-scripting.com/tutorials.php?cat=8
Related topics
simple login script
Login Script
Login Script - PHP
150 frih$ if you make me a login script with....
Fix up a login script
Login System Tutorial Part 1 Creating Registration
Free PHP/MySQL login script
problem with login script
PHP login script problem
Free php script login / register , GREAT!
Servlet Basic login script?
Protect Your Page With Simple Login But Yet Powerful Script
Simple PHP Login Script
PHP Login-Script (With Sessions)
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.