Chatbox

You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 login/register/logout scripts on 6/4/2012, 8:29 pm

grimofdoom

avatar

Member
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.

View user profile

2 Re: login/register/logout scripts on 7/4/2012, 7:25 pm

Coddy

avatar

Member
You want it to forumotion?

View user profile

3 Re: login/register/logout scripts on 7/4/2012, 11:56 pm

LGforum

avatar

Moderator
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
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..

View user profile

4 Re: login/register/logout scripts on 8/4/2012, 5:49 pm

grimofdoom

avatar

Member
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)
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

View user profile

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum