Welcome Guest ( Log In | Register)



7 Pages V  < 1 2 3 4 5 > »   
Reply to this topicStart new topic
> Php Simple Login Tutorial, Learn how to make a simple login!
elevenmil
post Apr 3 2005, 08:22 AM
Post #21


Super Member
*********

Group: Members
Posts: 441
Joined: 22-March 05
Member No.: 4,795



Hey guys I found a tutorial that fixed my problem...thanks to all that tried to help...I believe the tutorial link I found is under the hosted members area, it is a really easy step by step guide that include improvements to the original php codes, thanks again everyone.
Go to the top of the page
 
+Quote Post
nickmealey
post Apr 6 2005, 07:08 PM
Post #22


Premium Member
********

Group: Members
Posts: 156
Joined: 14-March 05
From: Washington, USA
Member No.: 4,520



I like that alot! I'm trying to lurn php and mySql, and that help. Two thumbs up!
Go to the top of the page
 
+Quote Post
Garath
post Mar 6 2007, 01:24 AM
Post #23


Newbie
*

Group: Members
Posts: 1
Joined: 6-March 07
Member No.: 39,605



Whenever I try this, it always says "ERROR:Not added to the database."

CODE
<?php

// dbConfig.php is a file that contains your
// database connection information. This
// tutorial assumes a connection is made from
// this existing file.
include ("dbconfig.php");


//Input vaildation and the dbase code
if ( $_GET["op"] == "reg" )
{
$bInputFlag = false;
foreach ( $_POST as $field )
{
if ($field == "")
{
$bInputFlag = false;
}
else
{
$bInputFlag = true;
}
}
// If we had problems with the input, exit with error
if ($bInputFlag == false)
{
die( "Problem with your registration info. "
."Please go back and try again.");
}

// Fields are clear, add user to database
// Setup query
$q = "INSERT INTO `dbUsers` (`username`,`password`,`email`) "
."VALUES ('".$_POST["username"]."', "
."PASSWORD('".$_POST["password"]."'), "
."'".$_POST["email"]."')";
// Run query
$r = mysql_query($q);

// Make sure query inserted user successfully
if ( !mysql_insert_id() )
{
die("Error: User not added to database.");
}
else
{
// Redirect to thank you page.
Header("Location: register.php?op=thanks");
}
} // end if


//The thank you page
elseif ( $_GET["op"] == "thanks" )
{
echo "<h2>Thanks for registering!</h2>";
}

//The web form for input ability
else
{
echo "<form action=\"?op=reg\" method=\"POST\">\n";
echo "Username: <input name=\"username\" MAXLENGTH=\"16\"><br />\n";
echo "Password: <input type=\"password\" name=\"password\" MAXLENGTH=\"16\"><br />\n";
echo "Email Address: <input name=\"email\" MAXLENGTH=\"25\"><br />\n";
echo "<input type=\"submit\">\n";
echo "</form>\n";
}
// EOF
?>
Go to the top of the page
 
+Quote Post
Mr-Slowly
post Mar 21 2007, 05:29 PM
Post #24


Newbie
*

Group: Validating
Posts: 1
Joined: 21-March 07
Member No.: 40,440



nice tut man thanx wink.gif
Go to the top of the page
 
+Quote Post
MCSESubnet
post Mar 21 2007, 07:50 PM
Post #25


Newbie
*

Group: Members
Posts: 5
Joined: 21-March 07
Member No.: 40,446



Here is the MD5 alternative:


CODE
<?PHP
$user_name = $_POST['u_name'];
$password = $_POST['pass'];

//db connection string
$db = mysql_connect("localhost","root","pass");
mysql_select_db("my_database",$db);
//replace the above values with your actual database val

//We will now retrive the password from the database
$sql_query = mysql_query("SELECT password FROM user_data WHERE user_name='$user_name'",$db);
$rs = mysql_fetch_row($sql_query);

//comparing passwords
Note before we can compare the password we use md5() to encrypt the $password becuase the password that we retrive from the database is in the encrypted form.
if(md5($password) != $rs[0])
echo "ERROR: Invalid User";
else
echo "Congrats, Password is correct!";
?>



( I pulled this off www.phpbuddy.com ) Although this shows you how fast and easy it is to use MD5 and personally I prefer it over PEAR


Go to the top of the page
 
+Quote Post
xelynn
post Mar 21 2007, 10:50 PM
Post #26


Newbie
*

Group: Members
Posts: 4
Joined: 21-March 07
Member No.: 40,461



thx for the tut this helps =]
Go to the top of the page
 
+Quote Post
studentaugustow
post Apr 2 2007, 12:11 PM
Post #27


Newbie
*

Group: Members
Posts: 1
Joined: 2-April 07
Member No.: 40,967



Nice.Thx
Go to the top of the page
 
+Quote Post
d0n0t.p4n1c
post Jul 1 2007, 05:43 PM
Post #28


Newbie
*

Group: Members
Posts: 1
Joined: 1-July 07
Member No.: 45,809



Everything except the login worked for me here. It says "Sorry, could not log you in. Wrong login information." when I try to login, even when I KNOW I'm using the right username/password combo. Any help?
Go to the top of the page
 
+Quote Post
GamerGlitch
post Jul 5 2007, 03:19 AM
Post #29


Advanced Member
*******

Group: Members
Posts: 121
Joined: 30-June 07
Member No.: 45,710



Thank you, man. Good tutorial. However, on my site I just use my PHPBB Forum's login as the membership / login system. This still may come in handy if I ever drop that forum, though.
Go to the top of the page
 
+Quote Post
sro-gaming