Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 18:44

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Website Login Script for your players

Discussion on Website Login Script for your players within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
Angellinho's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 102
Received Thanks: 25
Website Login Script for your players

Hello! I want to release a sample Login Script for players.
Let`s start making the Configurations. Open a Text editor and create a file configuration.php

PHP Code:
<?php
    
// MySQL connect information.
    
$c_username "root";
    
$c_password "mysql password";
    
$c_host "localhost"//leave this
    
$c_database "yourdatabase";

    
// Connect.
    
$connection mysql_connect($c_host$c_username$c_password)
    or die (
"It seems this site's database isn't responding.");

    
mysql_select_db($c_database)
    or die (
"It seems this site's database isn't responding.");

?>
Save it into your web directory.

Now let`s make the Login.php

Add this code above your <head> tag element.

PHP Code:
<?php
session_start
();
// Check if he wants to login:
if (!empty($_POST[username]))
{
    require_once(
"configuration.php");

    
// Check if he has the right info.
    
$query mysql_query("SELECT * FROM accounts
                            WHERE Username = '
$_POST[username]'
                            AND Password = '
$_POST[password]'")
    or die (
"Error, something wrong.");
    
    
$row mysql_fetch_array($query)
    or die (
"Error, somethign wrong.");
    
    if (!empty(
$row[Username])) // he got it.
    
{
        
$_SESSION[username] = $row[Username];
        echo 
"Welcome $_POST[username]! You've been successfully logged in click <a href=login.php>Here</a>.";
        exit();
    }
    else 
// bad info.
    
{
        echo 
"Error - Couldn't login user.<br /><br />
            Please try again."
;
        exit();
    }
}

?>
Below, add this:

PHP Code:
<?php
session_start
();
require_once(
"configuration.php");

$query "select Name FROM entities WHERE Owner='$_SESSION[username]'";
$result mysql_query($query);

while(
$row mysql_fetch_assoc($result))
{
$c=$row['Name'];
}

$query2 "select ConquerPoints FROM entities WHERE Owner='$_SESSION[username]'";
$result2 mysql_query($query2);

while(
$row2 mysql_fetch_assoc($result2))
{
$cp=$row2['ConquerPoints'];
}


// Check his status.
if (!empty($_SESSION[username])) // he got it.
{
    echo 
"You are currently logged in, <b>$_SESSION[username]</b>. <a href=logout.php>Logout</a>";
        echo 
"Users Login script by Angell<a href='http://*************/forum/'>(4Botters)</a><br>";
        echo 
"<br>";
        echo 
"Char name: <font color=red>$c</font>";
        echo 
"ConquerPoints: <font color=red>$cp</font>";
}

else 
// bad info.
{
    echo 
"You are currently <b>NOT</b> logged in.";


echo
'                                            <p>Please Login First</p>
                                            <p>
                                            <form action=Login.php method=post>
                                            <table width=300 border=0 align=center cellpadding=0 cellspacing=1>
                                           <tr>
                                            <td><p><h3>Username:</h3></p></td>
                                            <td><p><input type=text name=username STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></p></td>
                                            </tr>
                                            <tr>
                                            <td><p><h3>Password:</h3></p></td>
                                            <td><p><input type=password name=password STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></p></td>
                                            </tr>
                                            <tr>
                                            <td><input type="submit" value="Login"></td>
                                            </tr>
                                            </table>
                                            </form></p>'
;
}

?>
You may have to modify the query to show your Char name, Coins(in this case CPs, first time was designed for conquer) or anything you want.
Example:
PHP Code:
$query "select VIP FROM account WHERE name='$_SESSION[username]'";
$result mysql_query($query);

while(
$row mysql_fetch_assoc($result))
{
$vip=$row['VIP'];

And then to make it show, add below
Code:
// Check his status.
if (!empty($_SESSION[username])) // he got it.
{
this code:
PHP Code:
echo "VIP: <font color=red>$vip</font>"
That`s everything. Close your <body>, there should be no <html> element.
Thanks for reading this.
Angellinho is offline  
Old 12/22/2011, 16:36   #2
 
NotEnoughForYou's Avatar
 
elite*gold: 0
Join Date: Jun 2010
Posts: 3,407
Received Thanks: 2,024
Why do you use a loop , when there is just 1 user with this name ? Also you can select both statements in one query
NotEnoughForYou is offline  
Old 12/22/2011, 18:04   #3
 
JacK le chilla's Avatar
 
elite*gold: 2
Join Date: May 2011
Posts: 448
Received Thanks: 110
Uh very nice for exploiting <3 bsp: Username: 'or1=1' Password: 'or1=1' D

in this script you can use very much exploits, pls check your variables on valid characters with preg_match for example
JacK le chilla is offline  
Old 12/22/2011, 22:37   #4
 
Angellinho's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 102
Received Thanks: 25
I just wanted to release a sample login script I made, whatever.
Angellinho is offline  
Old 12/22/2011, 22:42   #5
 
NotEnoughForYou's Avatar
 
elite*gold: 0
Join Date: Jun 2010
Posts: 3,407
Received Thanks: 2,024
if you use this script everybody can delete your database
NotEnoughForYou is offline  
Old 02/21/2012, 10:49   #6
 
Angellinho's Avatar
 
elite*gold: 0
Join Date: Dec 2010
Posts: 102
Received Thanks: 25
I`m not that sure as you are, Isn`t that vulnerable to SQLi.

and that thing with 'or1=1' isn`t working on it.
Angellinho is offline  
Old 02/21/2012, 20:21   #7
 
galaxyo's Avatar
 
elite*gold: 0
Join Date: Dec 2007
Posts: 425
Received Thanks: 183
Its not safe. Just google "SQL-Injection".
galaxyo is offline  
Old 02/22/2012, 20:19   #8
 
JacK le chilla's Avatar
 
elite*gold: 2
Join Date: May 2011
Posts: 448
Received Thanks: 110
Quote:
and that thing with 'or1=1' isn`t working on it.
it works, but if you want to fix it simple, use mysql_real_escape_string() to safe your SQL querys.

MfG JacK
JacK le chilla is offline  
Reply


Similar Threads Similar Threads
all players purity sro plz come and answar me why i get dc when i login in :(
11/15/2011 - SRO Private Server - 2 Replies
plz any help for this proplem in the photo :mad::mad::mad::mad::mad: http://www6.0zz0.com/2011/11/13/20/156565348.jpg
[HELP]SCRIPT PHP PLAYERS ONLINE
04/12/2011 - Dekaron Private Server - 12 Replies
Not know much about PHP I'M WITH A DOUBT AS AGENT IN AN ONLINE PLAYERS SYNTAX WHAT IT IN TIME FOR YOU TO READ THE DATABASE NOT READ NAMES OF FILES CONTAINING ", ... BELOW IS THE FILE: <style type="text/css"> <!-- body,td,th { font-family: Verdana, Geneva, sans-serif; color: #FFFF00; font-weight: bold; } body {
[Suche] Online players script
02/26/2011 - WoW Private Server - 1 Replies
Hey Hab ein problem ich suche ein online player script für ascent. Leider hab ich nicht viele kenntnisse mit php aber sql schon.. Also ich hab schon gegoogelt aber nix gefunden jetzt hofffe ich das ihr vlt eins kennt. wäre euch wirklich dankbar. mfg mike11995
MSSQL Script to ban players
02/03/2011 - Shaiya PServer Development - 6 Replies
Hi. Is there any1 who has a mssql player ban scipt by char name? Or maybe by account name? So a script that changes the status of a player to -5 ? Thank You.
[Help]Login issues with other players
10/15/2010 - Shaiya Private Server - 1 Replies
Ok, here's my issue: I've done everything that james's guide said to do to install the server. I have it up and running, and my staff is on hamachi. However, whenever they press the game.exe, it gives them the error checking server, please check notice board. The game is clearly online, I entered in all the commands, and yet they still can't get in. The IP is changed in the game.exe, everything is the way it's supposed to be, yet i'm the only one who can get in game. What is it i'm doing wrong,...



All times are GMT +2. The time now is 18:44.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.