Php Simple Login Tutorial - Learn how to make a simple login!

Pages: 1, 2, 3, 4, 5, 6, 7
free web hosting
Open Discussion > CONTRIBUTE > Tutorials

Php Simple Login Tutorial - Learn how to make a simple login!

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

Reply

nickmealey
I like that alot! I'm trying to lurn php and mySql, and that help. Two thumbs up!

Reply

Garath
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
?>

 

 

 


Reply

Mr-Slowly
nice tut man thanx wink.gif

Reply

MCSESubnet
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



Reply

xelynn
thx for the tut this helps =]

Reply

studentaugustow
Nice.Thx

Reply

d0n0t.p4n1c
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?

Reply

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

Reply

sro-gaming


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
Notice from jlhaslip:
No need to quote the whole Original Posting into your reply

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2, 3, 4, 5, 6, 7
Recent Queries:-
  1. php login example tutorial - 0.55 hr back. (1)
  2. login tutorial php example - 0.67 hr back. (1)
  3. example php login page - 1.46 hr back. (1)
  4. php login example - 1.78 hr back. (1)
  5. login example php - 1.80 hr back. (1)
  6. how to make a login script php - 5.57 hr back. (1)
  7. simple login php code - 7.21 hr back. (1)
  8. pear connection - 7.44 hr back. (1)
  9. easy login page setup - 7.51 hr back. (1)
  10. php login script tutorial - 7.58 hr back. (1)
  11. tutorial login php simples - 8.21 hr back. (1)
  12. how to make a log in page for your site - 8.46 hr back. (1)
  13. making login page php - 8.72 hr back. (1)
  14. login php example - 8.96 hr back. (1)
Similar Topics

Keywords : php, simple, login, learn, make, simple, login

  1. To Automatically Run Command When Login / Logoff
    (3)
  2. Simple Php Login And Registration System
    (15)
    Hello. This is my first web tutorial ever. This is basically a simple register and login script.
    Yes, I know it’s a bit rubbish but I’m quite new to PHP/MySQL. Here’s the register form. This can
    be any file extension you like. I’d recommend calling it register.html . CODE
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html
    xmlns="http://www.w3.org/1999/xhtml"> <head> <meta
    http-equiv="Content-Type" content="text/ht....
  3. Automatic Login
    in WinXP (5)
    Ever wanted to just turn on our computer and when you get back it's already on the desktop?
    (Rather then having to login at the welcome screen) Now some computer have this feature by default,
    but what if it gets broken, try this. On an Administrator account goto start >> Run, and type
    "control userpasswords2" (without the quotes) Uncheck the box that "Users must enter a Username and
    Password to use this computer", then press Ok. You will be prompted to enter a default user and
    their pasword, then next time you restart the computer it will automaticaly login to that....
  4. Simple Login In Visual Basic 6
    user interaction example trough login programm (6)
    First of all, I am NOT a programmer, this is something my friend taught me. It describes basic
    interaction with the user, while showing basic functionality of this simple programm. So, without
    further ado, we're off to the tutorial: First of all, start your visual basic, when prompted
    for new project, select Standard Exe . Next, we need to open code window, so we can start typing
    the program. This can be done in two ways, one is double clicking on the form, or selecting Code
    from View menu. If you double clicked on the form, you will see following text: CODE ....
  5. How To Put A Phpbb Login Box On Your Main Site.
    Code and .php included!!! (18)
    I have included my coded file with this... Ok here is the code. CODE // //Create login area,
    replace the phpBB2 in /phpBB2/login.php with your forum's //directory // <form
    action="/phpBB2/login.php" method="post" target="_top"> <table
    width="25%" cellspacing="2" cellpadding="2" border="0"
    align="center">  <tr> <td align="left"
    class="nav"><a href="/phpBB2/index.php" class="nav">Prank Place
    Forum Index</a></td>....
  6. Php/mysql Login/register
    Tutorial for login with databases. (2)
    Start register code. Register.php CODE <form method=post
    action=register.php?action=register  name=s> <table>
    <tr><td>Username:</td><td><input type=text
    name=user></td></tr>
    <tr><td>Email:</td><td><input type=text
    name=email></td></tr>
    <tr><td>Pass:</td><td><input type=password
    name=pass></td></tr> <tr><td>Verify
    Pass:</td><td><input ....
  7. Complete Login And Registration System
    doesn't use mysql! (9)
    kLogin 0.1 QUOTE(readme.txt) Readme file to kLogin 0.1 To use the internet explorer fix:
    download the latest IE7 ZIP file
    (http://sourceforge.net/project/showfiles.php?group_id=109983&package_id=119707) Extract the ie7
    zip file to the root directory of your web server. Example, if you are using a unix/linux server,
    it's on "public_html/" or "home/public_html" Open kLogin.php file with your editor and edit the
    $info_text or $info_txt variable. Then, extract the kLogin.php file in to the root
    directory of your web server also. Just run kShoutBo....
  8. Multiple Admin Login (php)
    This is a script that doesnt requre SQL (3)
    first off make a login.html page Code: QUOTE Admin Login Username: Password:
    then make a check.php page Code: QUOTE $admin1 = "admin1"; //
    first admin username $adm_pass1 = "password1"; // first admin password $admin2 =
    "admin2"; // second admin username $adm_pass2 = "password2"; // second admin password
    if(($username == $admin1 && $password == $adm_pass1) || ($username ==
    $admin2 && $password == $adm_pass2)){ echo "Congratulations " . $_POST . " ....
  9. Complete Login System
    With PHP + MYSQL (57)
    Its an complete login sistem made and tested by me and I think itwill be very usefull for people who
    are tryn to learn PHP. First, let's make register.php: CODE <?
    include("conn.php"); // create a file with all the database connections
    if($do_register){ // if the submit button were clicked if((!$name)
    || (!$email) || (!$age) || (!$login) ||
    (!$password) || (!$password2)){ print "You can't let
    any fields in blank....

    1. Looking for php, simple, login, learn, make, simple, login

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for php, simple, login, learn, make, simple, login

*MORE FROM TRAP17.COM*
advertisement



Php Simple Login Tutorial - Learn how to make a simple login!



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE