Login PHP

Junior Spellweaver
Joined
Apr 6, 2009
Messages
141
Reaction score
10
I NEED HELP WITH 1 THING!!!!

How do i make a drop-down box with the accounts characters on it? (I have the login/pass for account)
 
Last edited:
BUMP:

here's what i got so far, i used wizkids reg page to make a login page that just shows account info (for now ^^)

PHP:
<!--BEGIN CUSTOM HTML CODE-->

<script type=text/javascript>
var msg = "Right click disabled !"
if(document.layers) window.captureEvents(Event.MOUSEDOWN);

function no_click(e){
if (navigator.appName == 'Netscape' && ( e.which == 2 || e.which == 3))
{
alert(msg);return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
{
alert(msg);return false;
}
}
window.onmousedown=no_click;
document.onmousedown=no_click; </script> 
<body bgcolor="#999999">
<div align="center">
  <p><strong><font color="#FFFFFF"></font></strong></p>
  <p>
    <?php
$servername = "GunZ";
$accounttable = "Account";
$logintable = "Login";

$host = "HOST";
$user = "sa";
$pass = "pass";
$dbname = "GunzDB";

$connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");

function antisql($sql) {
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}

function gtfo($wut) {
echo "<center><table width='500' cellpadding='5' cellspacing='0' border='0' style='border: 1px ;'>
<tr>
<td align=center width='100%' style='border-bottom: 1px solid black;'><b>Message</b></td>
</tr>
<tr>
<td width='100%'><center>$wut</center></td>
</tr>
</table>";
die();
}

function num_rows(&$rid) {
$num= odbc_num_rows($rid);
if ($num >= 0) {
return $num;
}
if (!odbc_fetch_row($rid, 1)) {
odbc_fetch_row($rid, 0);
return 0;
}
if (!odbc_fetch_row($rid, 2)) {
odbc_fetch_row($rid, 0);
return 1;
}
$lo= 2;
$hi= 8192000;
while ($lo < ($hi - 1)) {
$mid= (int)(($hi + $lo) / 2);
if (odbc_fetch_row($rid, $mid)) {
$lo= $mid;
} else {
$hi= $mid;
}
}
$num= $lo;
odbc_fetch_row($rid, 0);
return $num;
}
?>
    <html>
    <head>
    </p>
</div>
</head>
<body>
<center>
<?php
$ip = antisql($_SERVER['REMOTE_ADDR']);
$query1 = odbc_exec($connect,"SELECT AID FROM $logintable WHERE LastIP = '$ip'");
$i=1;
while (odbc_fetch_row($query1, $i)){
$aid = odbc_result($query1, 'AID');
$query2 = odbc_exec($connect,"SELECT UGradeID FROM $accounttable WHERE AID = '$aid'");
odbc_fetch_row($query2);
$ugradeid = odbc_result($query2, 1);
if ($ugradeid == "253")
{
gtfo("You're account is banned!");
}
$i++;
}
echo "<table width='350'>
<form action='" . $_SERVER['PHP_SELF'] . "?act=doreg' method='POST'>
<b>Login to an $servername account.</b><br><br>
<tr>
<td width='50%'><b>Username:</b></td>
<td width='50%'><input type='text' name='username'></td>
</tr>
<tr>
<td width='50%'><b>Password:</b></td>
<td width='50%'><input type='password' name='password'></td>
</tr>
<tr>
<td width='50%'><b></b></td>
<td width='50%'><input type='submit' value='Login'></td>
</tr>
</table>";
function Secure($var){
$var = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$var);
$var = str_replace("'","",$var);
$var = trim($var);
$var = strip_tags($var);
$var = addslashes($var);
$var = str_replace("'", "''", $var);
$var = nl2br($var);
$var = htmlentities($var);
return $var;
}
function SecureInput($input,$fieldname){
if (!empty($input)){
Secure($input);
} else {
echo $fieldname." not filled in";
exit();
}
}
$username = Secure($_GET['username']);
$password = Secure($_GET['password']);
$getuserdata = odbc_fetch_array(odbc_exec($connect,"SELECT * FROM Login WHERE UserID = '".$username."' "));
if ($password == $getuserdata['Password'])
{
gtfo("Account info:<br><br>
Username: $_POST[username]<br>
Password: $_POST[password]<br><br>
Have fun at $servername!");
}
?>
<br>
<font size="1">Copyright © 2010</font>
</center>
</body>
</html>

<!--END CUSTOM HTML CODE-->

Errors (THESE ERRORS ARE RIGHT UNDER THE TABLE FOR SOME REASON):

Code:
Notice: Undefined index: username in C:\wamp\www\poo.php on line 202

Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\poo.php on line 184

Notice: Undefined index: password in C:\wamp\www\poo.php on line 203

Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\poo.php on line 184

Notice: Undefined index: username in C:\wamp\www\poo.php on line 208

Notice: Undefined index: password in C:\wamp\www\poo.php on line 209
Message
Account info:

Username:
Password:

Have fun at GunZ

BUGS:

Any user/pass works >.>
 
Last edited:
Upvote 0
BUMP:

here's what i got so far, i used wizkids reg page to make a login page that just shows account info (for now ^^)

PHP:
<!--BEGIN CUSTOM HTML CODE-->

<script type=text/javascript>
var msg = "Right click disabled !"
if(document.layers) window.captureEvents(Event.MOUSEDOWN);

function no_click(e){
if (navigator.appName == 'Netscape' && ( e.which == 2 || e.which == 3))
{
alert(msg);return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
{
alert(msg);return false;
}
}
window.onmousedown=no_click;
document.onmousedown=no_click; </script> 
<body bgcolor="#999999">
<div align="center">
  <p><strong><font color="#FFFFFF"></font></strong></p>
  <p>
    <?php
$servername = "GunZ";
$accounttable = "Account";
$logintable = "Login";

$host = "HOST";
$user = "sa";
$pass = "pass";
$dbname = "GunzDB";

$connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");

function antisql($sql) {
$sql = trim($sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}

function gtfo($wut) {
echo "<center><table width='500' cellpadding='5' cellspacing='0' border='0' style='border: 1px ;'>
<tr>
<td align=center width='100%' style='border-bottom: 1px solid black;'><b>Message</b></td>
</tr>
<tr>
<td width='100%'><center>$wut</center></td>
</tr>
</table>";
die();
}

function num_rows(&$rid) {
$num= odbc_num_rows($rid);
if ($num >= 0) {
return $num;
}
if (!odbc_fetch_row($rid, 1)) {
odbc_fetch_row($rid, 0);
return 0;
}
if (!odbc_fetch_row($rid, 2)) {
odbc_fetch_row($rid, 0);
return 1;
}
$lo= 2;
$hi= 8192000;
while ($lo < ($hi - 1)) {
$mid= (int)(($hi + $lo) / 2);
if (odbc_fetch_row($rid, $mid)) {
$lo= $mid;
} else {
$hi= $mid;
}
}
$num= $lo;
odbc_fetch_row($rid, 0);
return $num;
}
?>
    <html>
    <head>
    </p>
</div>
</head>
<body>
<center>
<?php
$ip = antisql($_SERVER['REMOTE_ADDR']);
$query1 = odbc_exec($connect,"SELECT AID FROM $logintable WHERE LastIP = '$ip'");
$i=1;
while (odbc_fetch_row($query1, $i)){
$aid = odbc_result($query1, 'AID');
$query2 = odbc_exec($connect,"SELECT UGradeID FROM $accounttable WHERE AID = '$aid'");
odbc_fetch_row($query2);
$ugradeid = odbc_result($query2, 1);
if ($ugradeid == "253")
{
gtfo("You're account is banned!");
}
$i++;
}
echo "<table width='350'>
<form action='" . $_SERVER['PHP_SELF'] . "?act=doreg' method='POST'>
<b>Login to an $servername account.</b><br><br>
<tr>
<td width='50%'><b>Username:</b></td>
<td width='50%'><input type='text' name='username'></td>
</tr>
<tr>
<td width='50%'><b>Password:</b></td>
<td width='50%'><input type='password' name='password'></td>
</tr>
<tr>
<td width='50%'><b></b></td>
<td width='50%'><input type='submit' value='Login'></td>
</tr>
</table>";
function Secure($var){
$var = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),"",$var);
$var = str_replace("'","",$var);
$var = trim($var);
$var = strip_tags($var);
$var = addslashes($var);
$var = str_replace("'", "''", $var);
$var = nl2br($var);
$var = htmlentities($var);
return $var;
}
function SecureInput($input,$fieldname){
if (!empty($input)){
Secure($input);
} else {
echo $fieldname." not filled in";
exit();
}
}
$username = Secure($_GET['username']);
$password = Secure($_GET['password']);
$getuserdata = odbc_fetch_array(odbc_exec($connect,"SELECT * FROM Login WHERE UserID = '".$username."' "));
if ($password == $getuserdata['Password'])
{
gtfo("Account info:<br><br>
Username: $_POST[username]<br>
Password: $_POST[password]<br><br>
Have fun at $servername!");
}
?>
<br>
<font size="1">Copyright © 2010</font>
</center>
</body>
</html>

<!--END CUSTOM HTML CODE-->
Errors (THESE ERRORS ARE RIGHT UNDER THE TABLE FOR SOME REASON):

Code:
Notice: Undefined index: username in C:\wamp\www\poo.php on line 202

Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\poo.php on line 184

Notice: Undefined index: password in C:\wamp\www\poo.php on line 203

Deprecated: Function sql_regcase() is deprecated in C:\wamp\www\poo.php on line 184

Notice: Undefined index: username in C:\wamp\www\poo.php on line 208

Notice: Undefined index: password in C:\wamp\www\poo.php on line 209
Message
Account info:

Username:
Password:

Have fun at GunZ
BUGS:

Any user/pass works >.>

Code:
[COLOR=#000000]<font size="1">Copyright © 2010</font>

Hmm...
[/COLOR]
 
Upvote 0
Lol at least Coole gave it a shot :P. Nice try bra try using
Code:
<?php
if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
?>
. That helps a little.
 
Upvote 0
Okay well i fixed that problem, i have a login page :D but i need help with creating clans :S

How do i make a drop-down box with the accounts characters on it? (I have the login/pass for account)
 
Upvote 0
* Bump *

^^ Please help with above ^^

Recap: I need a combobox (drop-down box) in PHP that gets how many characters an account has and shows every character in the combobox (drop-down box)

If your amazing at PHP and can learn things like this really fast heres how you make a combobox (drop-down box)

PHP:
<html>
<body>

<select>
  <option>Volvo</option>
  <option>Saab</option>
  <option>Mercedes</option>
  <option>Audi</option>
</select>
 
</body>
</html>

Example from w3schools
 
Upvote 0
PHP:
<? 
$query = mssql_query("SELECT CID, Name FROM Character WHERE AID = '" . $_SESSION['AID'] . "' AND CharNum != '-1'");
?>

<select name="charlist">
<?
while( $char = mssql_fetch_row($query1) )
{
     echo "<option value=\"$char['CID']\">$char['Name']</option>";
}
?>
</select>
 
Upvote 0
That didnt work prolly because im using ODBC instead of MSSQL

Okay i edited it but it doesn't show my characters, i edited it so it will show AID 1's characters (my acc ID is 1)

PHP:
$rofltown = odbc_exec($connect,"SELECT CID, Name FROM Character WHERE AID = '1' AND CharNum != '-1'");
?>
<select name="charlist">
<?
while( $char = odbc_fetch_row($rofltown) )
{
     echo "<option value=\"$char['CID']\">$char['Name']</option>";
}
?>
</select>
 
Last edited:
Upvote 0
PHP:
$rofltown = odbc_exec($connect, "SELECT CID, Name FROM Character WHERE AID = '" . $_SESSION['AID'] . "' AND CharNum != '-1'");

<select name="charlist">
<?
while( odbc_fetch_row($rofltown) )
{
     echo "<option value=\"odbc_result($rofltown, 0)\">odbc_result($rofltown, 1)</option>";
}
?>
</select>
 
Upvote 0
PHP:
<?

$aid = ($_SESSION['AID'] == "") ? "1" : $_SESSION['AID'];

$rofltown = odbc_exec($connect, "SELECT CID, Name FROM Character WHERE AID = '$aid' AND CharNum != '-1'");

?>


<select name="charlist">
<?
while( $char = odbc_fetch_array($rofltown) )
{
     echo "<option value=\"$char[CID]\">$char[Name]</option>\n";
}
?>
</select>

 
Last edited:
Upvote 0
PHP:
<!--BEGIN CUSTOM HTML CODE-->

<script type=text/javascript>
var msg = "Right click disabled !"
if(document.layers) window.captureEvents(Event.MOUSEDOWN);

function no_click(e){
if (navigator.appName == 'Netscape' && ( e.which == 2 || e.which == 3))
{
alert(msg);return false;
}
if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
{
alert(msg);return false;
}
}
window.onmousedown=no_click;
document.onmousedown=no_click; </script> 
<div align="center">
  <p><strong><font color="#FFFFFF"></font></strong></p>
  <p>
    <?php
/*
This script was written by Wizkid.
All rights reserved. Any support can be requested via RageZone.

You're allowed to edit this script and modify the template.
However, you are NOT allowed to remove and/or edit my copyright.

Removing this copyright will be your death.
*/

//Edit to fit YOUR requirements.
$servername = "Abused-GunZ";
$accounttable = "Account";
$logintable = "Login";

//Edit these variables. If not, no regpage for you. (Or you're fuxpro with the same logins as me.)
$host = "host";
$user = "user";
$pass = "pass";
$dbname = "GunzDB";

$connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");

//The well-known antisql injection. Bad enough, it's needed.
function antisql($sql) {
return ( str_replace( "'", "''", $sql ) );
}

//My favorite function. Get The **** Off. (Nothing personally :].)
function gtfo($wut) {
echo "<center><table width='500' cellpadding='5' cellspacing='0' border='0' style='border: 1px ;'>
<tr>
<td align=center width='100%' style='border-bottom: 1px solid black;'><b>Message</b></td>
</tr>
<tr>
<td width='100%'><center>$wut</center></td>
</tr>
</table>";
die();
}

//Check email function. This to prevent fake emails. (Remember the time YOU doing that?)
function checkemail($address) {
list($local, $host) = explode("@", $address);
$pattern_local = "^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$";
$pattern_host  = "^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$";
$match_local = eregi($pattern_local, $local);
$match_host = eregi($pattern_host, $host);
if($match_local && $match_host) {
return 1;
}
else {
return 0;
}
}

//The num_rows() function for ODBC since the default one always returns -1.
function num_rows(&$rid) {

//We can try it at least, right?
$num= odbc_num_rows($rid);
if ($num >= 0) {
return $num;
}

if (!odbc_fetch_row($rid, 1)) {
odbc_fetch_row($rid, 0);
return 0;
}

if (!odbc_fetch_row($rid, 2)) {
odbc_fetch_row($rid, 0);
return 1;
}

$lo= 2;
$hi= 8192000;

while ($lo < ($hi - 1)) {
$mid= (int)(($hi + $lo) / 2);
if (odbc_fetch_row($rid, $mid)) {
$lo= $mid;
} else {
$hi= $mid;
}
}
$num= $lo;
odbc_fetch_row($rid, 0);
return $num;
}
?>
    <html>
<title>Abused-GunZ</title>
    <head>
    </p>
</div>
</head>
<body>
<center>
<?php
//Oh well. Let's create the variable $ip to start with.
$ip = antisql($_SERVER['REMOTE_ADDR']);

/*
An extra feature. This is NOT enabled before you remove this + the comment thingy's.

To ban 1 IP it will be:
if ($ip == "xxxxxx")
{
gtfo("Your IP is blacklisted.");
}

For multiple IP's, use this way:
if ($ip == "xxxxxx" OR $ip == "xxxxxx")
{
gtfo("Your IP is blacklisted.");
}
*/

//Get the AID out of the Login table (defined at the top of this file) where LastIP is the visitors IP.
$query1 = odbc_exec($connect,"SELECT AID FROM $logintable WHERE LastIP = '$ip'");

//Understable for the real people. Editing this without knowledge will be the death of your regpage.
$i=1;
while (odbc_fetch_row($query1, $i)){
$aid = odbc_result($query1, 'AID');

$query2 = odbc_exec($connect,"SELECT UGradeID FROM $accounttable WHERE AID = '$aid'");
odbc_fetch_row($query2);
$ugradeid = odbc_result($query2, 1);

if ($ugradeid == "253")
{
//Get the **** off.
gtfo("You're account is banned!");
}

$i++;
}
$rofltown = odbc_exec($connect, "SELECT CID, Name FROM Character WHERE AID = '1' AND CharNum != '-1'");
?>
<select name="charlist">
<?
while( $char = odbc_fetch_array($rofltown) )
{
     echo "<option value=\"$char[CID]\">$char[Name]</option>\n";
}
?>
</select>
<br>
<font size="1">Copyright © 2010 Wizkid & Abused Gamers - All rights reserved.</font>
</center>
</html>

<!--END CUSTOM HTML CODE-->

I took out a lot... (because this code was different)

I used to have a table with character: and then New character name:
It worked fine but i wanna do it this way, easier...
 
Last edited:
Upvote 0
Back