login/register/logout scripts
Page 1 of 1 • Share
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
I really need scripts that work for register,login and logout pages(php/mysql).I am completely new to php/mysql and know only enough of start/end of php section.can someone please give me scripts(non-download and simple username/pass) for this.if you could also put areas of change to show what i need to change it to,thank you.
- CoddyMember
- Forum Posts : 45
Member Since : 2011-11-21
You want it to forumotion?
- LGforumModerator
- Forum Posts : 77
Member Since : 2011-11-12
There's quite a reasonable amount in terms of creating a secure log in and registration. Here's a few things to get you started.
I am going to assume you know enough about HTML forms and how they are sent to php.
You'll also have to create your database users table.
With fields of:
username > varchar(50)
password > varchar(150);
salt > varchar(6);
If your lost already, then stop now and forget your project. Your not ready.
Register
That is the very basics of a registration script and there is a lot to fill in the gaps.
But the registration of each website will be unique, in terms of database, whats being stored, validation etc..
I am going to assume you know enough about HTML forms and how they are sent to php.
You'll also have to create your database users table.
With fields of:
username > varchar(50)
password > varchar(150);
salt > varchar(6);
If your lost already, then stop now and forget your project. Your not ready.
Register
- Code:
$username = mysql_real_escape_string($_POST['username']);
$password = mysql_real_escape_string($_POST['password']);
//make the user confirm the pass word.
$cpass = mysql_real_escape_string($_POST['cpass']);
if(empty($username) || empty($password) || empty($cpass))
{
//change here, to do more than just exit.
exit;
}
if($cpass !== $password)
{
//change here to do more than exit.
exit;
}
//validate the username and password.
//check its length and make sure its not too short and not too long.
// maybe use a regex to make sure it doesn't contain any bad characters.
function createSalt()
{
$string = md5(uniqid(rand(), true));
return substr($string, 0, 6);
}
$salt = createSalt();
$p = hash('sha256', $salt . $password);
//password is now hashed and salted and secure.
//then insert the user into the database.
mysql_query('INSERT INTO your_users_table VALUES(\''.$username.'\',\''.$p.'\',\''.$salt.'\')');
That is the very basics of a registration script and there is a lot to fill in the gaps.
But the registration of each website will be unique, in terms of database, whats being stored, validation etc..
- grimofdoomMember
- Forum Posts : 106
Member Since : 2012-03-06
I got confused reading that,so i went and ended up finding phpacademy and started the first video on login. though i keep getting a T_STRING error on(it does have a closing)
UPDATE:i foud the problem,forgot the ";" at the end of the last line before it
- Code:
mysql_select_db("a3197062_Users") or die("could not find db");
UPDATE:i foud the problem,forgot the ";" at the end of the last line before it
- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|