IPB

Welcome Guest ( Log In | Register )



Tags
This content has not been tagged yet
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
no avatar
Super Member
*********
Group: Members
Posts: 440
Joined: 22-March 05
Member No.: 4,795



Post #21 post Apr 3 2005, 08:22 AM
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
no avatar
Premium Member
********
Group: Members
Posts: 156
Joined: 14-March 05
From: Washington, USA
Member No.: 4,520



Post #22 post Apr 6 2005, 07:08 PM
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
no avatar
Newbie
*
Group: Members
Posts: 1
Joined: 6-March 07
Member No.: 39,605



Post #23 post Mar 6 2007, 01:24 AM
Whenever I try this, it always says "ERROR:Not added to the database."

[codebox]<?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
?>[/codebox]
Go to the top of the page
+Quote Post
Mr-Slowly
no avatar
Newbie
*
Group: Validating
Posts: 1
Joined: 21-March 07
Member No.: 40,440



Post #24 post Mar 21 2007, 05:29 PM
nice tut man thanx wink.gif
Go to the top of the page
+Quote Post
MCSESubnet
no avatar
Newbie
*
Group: Members
Posts: 5
Joined: 21-March 07
Member No.: 40,446



Post #25 post Mar 21 2007, 07:50 PM
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
no avatar
Newbie
*
Group: Members
Posts: 4
Joined: 21-March 07
Member No.: 40,461



Post #26 post Mar 21 2007, 10:50 PM
thx for the tut this helps =]
Go to the top of the page
+Quote Post
studentaugustow
no avatar
Newbie
*
Group: Members
Posts: 1
Joined: 2-April 07
Member No.: 40,967



Post #27 post Apr 2 2007, 12:11 PM
Nice.Thx
Go to the top of the page
+Quote Post
d0n0t.p4n1c
no avatar
Newbie
*
Group: Members
Posts: 1
Joined: 1-July 07
Member No.: 45,809



Post #28 post Jul 1 2007, 05:43 PM
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
no avatar
Advanced Member
*******
Group: Members
Posts: 127
Joined: 30-June 07
Member No.: 45,710



Post #29 post Jul 5 2007, 03:19 AM
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
no avatar
Newbie
*
Group: Members
Posts: 1
Joined: 5-July 07
Member No.: 46,020



Post #30 post Jul 5 2007, 11:11 PM


That's about it!. I used many simple examples hoping that you will learn how the internal systems work so you can expand on them and design a system that's just right for your needs. Have fun! ph34r.gif[/quote]
hey dude i have a question. I followed your tutorial. See when i add the code it is previewed before you go back to the the contraol center(using freehostingnow.com). When it previews in shows it all but when i go to http://www.sro-gaming.freehostingnow.com/register/login.php the pages are blank. if you know what's weong email me at sro-gaming@hotmail.com
Subject: login trouble
thnx
[note=jlhaslip]No need to quote the whole Original Posting into your reply[/note]
Go to the top of the page
+Quote Post

7 Pages V  < 1 2 3 4 5 > » 
Reply to this topicStart new topic

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts   0 Albus Dumbledore 1,133 18th June 2006 - 08:28 AM
Last post by: Albus Dumbledore
No New Posts   9 noxit 871 30th July 2004 - 02:57 PM
Last post by: templest
No new   32 ultrasmad 3,931 14th February 2005 - 11:01 AM
Last post by: Someone
No new   16 ultrasmad 3,094 21st May 2005 - 10:04 AM
Last post by: alexia
No New Posts   3 ultrasmad 781 30th July 2004 - 03:27 PM
Last post by: templest
No New Posts   12 BooZker 936 8th July 2006 - 07:50 AM
Last post by: BooZker
No new   34 Bash 9,070 23rd February 2007 - 05:13 AM
Last post by: btdesign
No New Posts   2 zachtk8702 497 13th August 2004 - 04:26 PM
Last post by: zachtk8702
No New Posts   2 threepach 692 19th February 2008 - 08:30 PM
Last post by: threepach
No New Posts   0 etycto 300 2nd September 2007 - 09:43 PM
Last post by: etycto


 



RSS Lo-Fi Version Time is now: 4th December 2008 - 01:48 AM