Thread: Make a Working Login,Logout, and Member page from scratch

Page 1 of 3 123 LastLast
Results 1 to 10 of 23
  1. #1 Make a Working Login,Logout, and Member page from scratch 
    Ken
    Ken is offline
    Active Service Provider
    Ken's Avatar
    Join Date
    Jun 2008
    Age
    26
    Posts
    747
    Thanks given
    184
    Thanks received
    55
    Discord
    View profile
    Rep Power
    368
    Well a friend Bloody isle wanted me a post on how to do this Correctly so please take your time this will be a long Tutorial..

    Spoiler for mysql:
    Step 1 open phpmyadmin and create a database called phplogin:

    Step 2: Make a Table called users

    Set the Number of fields to three.
    Then fill your fields out like this must be exactly alike.

    Phew pat your self on the back the boring part is over now lets get into source code.
    Now i reccomend using notepad ++ to edit php but notepad will do fine i guess.
    Open up notepad and make a file called login.php This will be used to login to your database.
    on the first line write
    Code:
    <php?
    This will let your server know to start parseing php.
    Now hit enter 2 times and type
    Code:
    session_start();
    this will start a session to keep your user logged in.
    now hit enter and add these two variables
    Code:
    $username = $_POST['username'];
    $password = $_POST['password'];
    this will declare the usernames coming from the login form i will show you how to make after this.
    hit enter 1ce or twice and add
    Code:
    if ($username&&$password)
    {
    this is saying if the username and password are entered to run this statement under that add this
    Code:
    $connect = mysql_connect("localhost","user","password") or die("Couldnt Connect to the Database?");
    basically that will try to connect to the database and if it cant connect it will kill the script and let you know it cannot connect. edit those fields to your mysql information than hit enter once more and add
    Code:
    mysql_select_db("phplogin") or die("Couldn't find Database");
    This is going to select your database pretty self explanatory...
    Code:
    $query = mysql_query("SELECT * FROM users WHERE username='$username'");
    this is going to check the database for your information..
    under that add...
    Code:
    $numrows = mysql_num_rows($query);
    Now hit enter twice and add
    Code:
    if ($numrows!=0)
    {
    while ($row = mysql_fetch_assoc($query))
    	{
    		$dbusername = $row['username'];
    		$dbpassword = $row['password'];
    	}
    basically it declares username and password in the database. now hit enter.
    Add this code now
    Code:
    	if ($username==$dbusername&&$password==$dbpassword)
    	{
    this says that if the username and password entered entered match the ones in the database it will run the method under it.
    So under that add:
    Code:
    echo "You have successfully logged in, <a href='member.php'>Click</a> here to enter the Member Page.";
    		$_SESSION['username']=$dbusername;
    	}
    Basically that will start a session to keep you logged in then link you to the member page i am going to show you how to make.
    Now under that add
    Code:
    else
    		echo "Incorrect Username or Password They are Case Senesetive!";
    }
    which is basically saying otherwise if the password is incorrect let them know..
    under that add these error messages
    Code:
    else
    	die("That Username Doesnt Exist");
    }
    else
    	die("Please enter a username and Password");
    and the final part of this file stop parseing the php
    Code:
    ?>
    Make a new File Called Index.php
    Inside that add:
    Code:
    <html><center><form action='login.php' method='POST'>
    		<font color="white">Username: <input type='text' name='username'><br>
    		Password: <input type='password' name='password'><br>
    		<input type='submit' value='Log in'></font></center>
    	</form></html>
    Which is basically just the login form for the database

    Now make a new file called Member.php
    Begin parseing php
    Code:
    <?php
    Start your session
    Code:
    session_start();
    Check the session
    Code:
    if($_SESSION['username'])
    Welcome the user with options
    Code:
    echo "<center><font color='white'>Welcome, ".$_SESSION['username']."!<br><a href='./acp'>AdminCP</a><br><a href='logout.php>Logout</a></font></center>";
    Make an else statement if not logged in
    Code:
    else
    	die("You must be logged in to View this Page.");
    Stop Parseing Php
    Code:
    ?>
    Finally the logout.php
    Code:
    <?php
    after calling php start a session
    Code:
    session_start();
    Now Destroy it
    Code:
    session_destroy();
    Echo the Logout
    Code:
    echo "You've been Logged out, <a href='index.php'>Click here</a> to return.";
    End Parseing
    Code:
    ?>
    Now i will be adding a Register.php soon but until then follow the steps below to add a user.
    Open Phpmyadmin
    open your phplogin database
    click the insert button near the userstable
    leave the id field blank
    fill in your username
    fill in your password
    Save.


    UPDATE: Register.php will be here very soon i had an error but i just fixed it so i will be posting it soon
    [Only registered and activated users can see links. ]
     

  2. #2  
    Banned

    Join Date
    Apr 2009
    Posts
    1,425
    Thanks given
    209
    Thanks received
    50
    Rep Power
    0
    lawl easy
    goodjob , good for beginners
     

  3. #3  
    The internet's reject
    Andy's Avatar
    Join Date
    Jun 2007
    Age
    31
    Posts
    4,376
    Thanks given
    148
    Thanks received
    1,522
    Rep Power
    3133
    Good job i like crack
    What am I watching now?

     

  4. Thankful user:

    Ken

  5. #4  
    Ken
    Ken is offline
    Active Service Provider
    Ken's Avatar
    Join Date
    Jun 2008
    Age
    26
    Posts
    747
    Thanks given
    184
    Thanks received
    55
    Discord
    View profile
    Rep Power
    368
    Quote Originally Posted by Codeusa View Post
    Good job i like crack
    Ty for replying, and crack killz
    [Only registered and activated users can see links. ]
     

  6. #5  
    Donator Market Banned Market Banned



    Join Date
    Feb 2009
    Posts
    3,821
    Thanks given
    88
    Thanks received
    113
    Rep Power
    5000
    goodjob thanks lalw
     

  7. Thankful user:

    Ken

  8. #6  
    Botnet admin

    HaVoK0321's Avatar
    Join Date
    Jan 2009
    Posts
    551
    Thanks given
    51
    Thanks received
    23
    Rep Power
    247
    Cool
     

  9. Thankful user:

    Ken

  10. #7  
    Ken
    Ken is offline
    Active Service Provider
    Ken's Avatar
    Join Date
    Jun 2008
    Age
    26
    Posts
    747
    Thanks given
    184
    Thanks received
    55
    Discord
    View profile
    Rep Power
    368
    Quote Originally Posted by Flow View Post
    goodjob thanks lalw
    Yw
    Quote Originally Posted by TsGh MiKe View Post
    Cool
    Init?
    [Only registered and activated users can see links. ]
     

  11. #8  
    Soulze
    Guest
    Good job, nice to see how others do it .
     

  12. Thankful user:

    Ken

  13. #9  
    Ken
    Ken is offline
    Active Service Provider
    Ken's Avatar
    Join Date
    Jun 2008
    Age
    26
    Posts
    747
    Thanks given
    184
    Thanks received
    55
    Discord
    View profile
    Rep Power
    368
    Quote Originally Posted by Soulze View Post
    Good job, nice to see how others do it .
    It is kinda interesting
    [Only registered and activated users can see links. ]
     

  14. #10  
    Savanah
    Guest
    Quote Originally Posted by »Ǥєσяgισ« View Post
    lawl easy
    goodjob , good for beginners
    You couldn't do anything like this.
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •