Jump to content

PHP/MySQL Login Script


Mute

Recommended Posts

I've had a Google and come up short so was hoping someone here might have what I'm looking for. Right now we are using vBulletin as both our forum and also as our login/register/user management.

 

We're thinking of dropping vB just because our forum isn't used enough to warrant it. Thus, we would need a new login script etc. Rather than re-inventing the wheel and writing my own, I was hoping there was a generic script out there that people might be using that simplifies the whole process.

 

So basically it's would have a sample registration and login forms and a simple include file to carry user session info across multiple pages. Perhaps with periodic updates to stay on top of the latest security updates etc.

 

Built in Facebook Connect and other social network stuff would be another great asset.

 

Anyone come across anything like this?

Link to comment
Share on other sites

There is no "simple" solution, just as there is no set standard for a login. Thats mostly due to everyone having a different system from the next persons (well in a matter of thinking, there are those upload, and click installable apps like vB, WP, SMF, etc..). But with that in mind its nearly impossible to just have a login that would just be upload and play for any given system cause how you structure your site might not support the concept well without making it.

 

The most basic of basic logins...

 

html side:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="name" id="name" value="" />
<input type="password" name="pass" id="pass" value="" />
<input type="submit" name="submitLogin" id="submitLogin" value="Login" />
</form>

php side (same page):
<?php
if((isset($_POST['submitLogin']))||(!empty($_POST['submitLogin']))||(trim($_POST['submitLogin']) !== ""))
{
$errors = "none";
$msg = "";
    if((!isset($_POST['name']))||(empty($_POST['name']))||(trim($_POST['name']) == "")){$errors = "yes";$msg .="Name not provided<br />";}
    if((isset($_POST['pass']))||(!empty($_POST['pass']))||(trim($_POST['pass']) !== "")){$errors = "yes";$msg .="Password not provided<br />";}

if($errors == "none"){$_SESSION['loggedin']="yes";$msg = "Logged in...";}
echo $msg;
}
?>

Link to comment
Share on other sites

lol I messed my own self up..

 

html side:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="text" name="name" id="name" value="" />
<input type="password" name="pass" id="pass" value="" />
<input type="submit" name="submitLogin" id="submitLogin" value="Login" />
</form>

php side (same page):
<?php
if((isset($_POST['submitLogin']))||(!empty($_POST['submitLogin']))||(trim($_POST['submitLogin']) !== ""))
{
$errors = "none";
$msg = "";
    if((!isset($_POST['name']))||(empty($_POST['name']))||(trim($_POST['name']) == "")){$errors = "yes";$msg .="Name not provided<br />";}
else{if($_POST['name'] !== "my-username"){$errors = "yes";$msg .="Username not found<br />";}
if($_POST['pass'] !== "my-secret-password"){$errors = "yes";$msg .="Password not provided<br />";
}
    if((!isset($_POST['pass']))||(empty($_POST['pass']))||(trim($_POST['pass']) == "")){$errors = "yes";$msg .="Password not provided<br />";}else{if($_POST['pass'] !== "my-secret-password"){$errors = "yes";$msg .="Password does not match<br />";}
}


if($errors == "none"){$_SESSION['loggedin']="yes";$msg = "Logged in...";}
echo $msg;
}
?>

Link to comment
Share on other sites

@monkeytooth:

Instead of:

if((isset($_POST['submitLogin']))||(!empty($_POST['submitLogin']))||(trim($_POST['submitLogin']) !== ""))

it is easier and better to use:

if($_SERVER['REQUEST_METHOD'] == 'POST'){

because IE does not put the button 'submitLogin' in the $_POST -array when you hit enter...

Link to comment
Share on other sites

  • 5 weeks later...

here is one that i am done with i left all the user information in it to help all of you, i think it is a good system.

All the user and password details are useless because this was on one of my testing servers

 

http://shift.site40.net/main/login2/login2.zip

 

this link will become invalid soon, like a month, well when i complete testing other scripts for me to use on my main website.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.