PHP newbie looking for some serious help.

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
jake007
Forum Newbie
Posts: 2
Joined: Fri Aug 20, 2004 12:48 pm

PHP newbie looking for some serious help.

Post by jake007 »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi, I'm new to this forum and also new to php (been learning for about 2 days)

I'm currently hosting a server for an online game and desperately seeking someone to help me to stripping out $_SESSION in the scripts and making an individual login form as I wanted to integrate the scripts with my site. I've spent the last 8 hours figuring a way but always failing with errors.

The codes are shown below:

index.php

Code: Select all

<?php
session_start();
function checkUser() {
	if (!isset($_SESSION['domu-user']) || $_SESSION['domu-user'] == "" || $_SESSION['domu-user'] == NULL) {
		return false;
	} else {
		return true;
	}
}
if (!isset($_GET['p']) || $_GET['p'] == "" || $_GET['p'] == NULL) {
	$p = "main";
} else {
	$p = $_GET['p'];
}
//echo $p;
if (!file_exists($p.".php")) {
	$page = "404.htm";
} else {
	$page = $p.".php";
}
//echo $page;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Psychic Punishment :: Welcome</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<BODY background=Leather3.jpg bgColor=#000000 bgProperties=fixed text=#b0c4de BODY>
<style type="text/css">
<!--
.smenu {
	font-family: Tahoma, Arial, Verdana;
	font-size: x-small;
	color: #b0c4de;
	text-decoration: none;
}
.content {
	font-family: Tahoma, Arial, Verdana;
	font-size: x-small;
	color: #b0c4de;
	text-decoration: none;
}
-->
A:visited {
	COLOR: #989292; TEXT-DECORATION: none
}
A:active {
	COLOR: #c0c0ff; TEXT-DECORATION: none
}
A:link {
	COLOR: #C0C0C0; TEXT-DECORATION: none
}

A:Hover {text-decoration: none; color: white; font-weight: bold; cursor: }
</style>
 
<CENTER> <tr valign="top">
	<td colspan=3 height=30></td>
	<tr><td style="padding-bottom: 5px;"><img src="pyschic.jpg" width="700"></td></tr>
	<td colspan=10 height=30></td>   <CENTER>

</head>
<TABLE align=center border=0  cellPadding=5 cellSpacing=5 width="100%" valign="top">
  <H1> </H1></TD></TR>

<body>
  <TR>
    <TD bgColor=#000033  BODY BACKGROUND=menu.jpg td  colSpan=2>

<CENTER>
<a href="?p=main" class="smenu"><font size="2"> Main </a> |
<a href="?p=login" class="smenu"><font size="2"> Login </a> |
<a href="?p=reguser" class="smenu"><font size="2">Register</a> <br>	
	<? if (checkUser()) : ?><a href="?p=charreset" class="smenu"><font size="2">Reset Character |</a><? endif; ?>
	<? if (checkUser()) : ?><a href="?p=clearred" class="smenu"><font size="2">Clear PK Status |</a><? endif; ?>
	<? if (checkUser()) : ?><a href="?p=logout" class="smenu"><font size="2">Logout</a><? endif; ?>  <br>
<a href="?p=top50" class="smenu"><font size="2">Top 50</a>
	<hr width="100" noshade color="#D0EEFC">
	</TD></TR>
<body>
<TR>
<td align="center"  valign="top" noshade color="#D0EEFC" class="content">

			<? include 'pep.php'; ?>
			<hr width="400" noshade color="#FFFFFF">
			</td></tr>

		<tr>
			<hr width="100" noshade color="#D0EEFC">
			</td>
			<td align="center"  valign="top" noshade color="#D0EEFC" class="content">
			<? include $page; ?>
			<hr width="544" noshade color="#FFFFFF">
			</td>
		</tr>
	</table></td></tr>
<H1 ALIGN=CENTER>
	<tr><td align="center"><font size="3">Site Coded by: Cyndre</font></TD></TR><br>	
	<tr><td align="center"><font size="3">Site Graphics by: PhroXen   | Site Layout by: Angel</font></td></tr>
</table>
</body>
</html>
login.php

Code: Select all

<?php
// login.php

    $conn = mssql_connect('localhost', 'sa', 'vivastar');
   mssql_select_db('MuOnline', $conn);
if (isset($_POST['acctid'], $_POST['pass'])) {
$query = mssql_query("SELECT * FROM MEMB_INFO WHERE memb___id = "$_POST[acctid]"");
$row = mssql_fetch_array($query);
if ($_POST['pass'] == $row['memb__pwd']) {
	
	header("Location: rank.php");
} else {
	echo "<font size="2">Bad login. <a href="".$_SERVER['PHP_SELF']."login1.php">Click Here</a>";
}
} else {
	echo "<form action="".$_SERVER['PHP_SELF']."login1.php" method="post"><table><tr><td><font size="2" face="Tahoma, Arial, Verdana">Account ID</td><td><input type="text" name="acctid"></td></tr>" .
				"<tr><td><font size="2" face="Tahoma, Arial, Verdana">Password</td><td><input type="password" name="pass"></td></tr><tr><td colspan="2" align="right">" .
				"<input type="submit" value="Login"></td></tr></table></form>";
}

?>
clearred.php

Code: Select all

<?php

$lvlreq = 6;

$newlvl = 3;
$newtime = -100;
		
if (!isset($_SESSION['domu-user']) || $_SESSION['domu-user'] == "" || $_SESSION['domu-user'] == NULL) {
	echo "Not Logged In";
} else {
	if (!isset($_POST['user']) || $_POST['user'] == "" || $_POST['user'] == NULL) {
?>
<p><font size="2">Clear Pk Status removes Phonomania from your character and has a cost of 25,000,000 zen.</p>
<center><form action="<?=$_SERVER['PHP_SELF']?>?p=clearred" method="post">
<font size="2">Character Name: <input type="text" name="user" maxlength="15">&nbsp;<input type="submit" value="Reset">
</form></center>
<?php
	} else {
		    $conn = mssql_connect('servername', 'account name', 'password');
   mssql_select_db('MuOnline', $conn);
		if (mssql_num_rows(mssql_query("SELECT * FROM Character WHERE Name = '".$_POST['user']."' AND AccountID = '".$_SESSION['domu-user']."'")) > 0) {
			$row = mssql_fetch_array(mssql_query("SELECT * FROM Character WHERE Name = '".$_POST['user']."' AND AccountID = '".$_SESSION['domu-user']."'"));
			if ($row['PkLevel'] == $lvlreq) {
				if ($row['Money'] > $row['Pk_Reset']) {
					$query = mssql_query("UPDATE Character SET PkLevel = ".$newlvl.", 
										Money = Money - Pk_Reset,
										PkTime = ".$newtime." WHERE Name = '".$_POST['user']."' AND AccountID = '".$_SESSION['domu-user']."'");
					if (!$query) {
						echo "<font size="2">PkReset could not be properly preformed. Database threw an error.";
					} else {
						echo "<font size="2">Done.";
					}
				} else {
					echo $row['Money'];
					echo "<font size="2">PkReset could not be preformed. Not enough zen.";
				}
			} else {
				echo "<font size="2">PkReset could not be preformed. Your not a Phonomania.";
			}
		} else {
			echo "<font size="2">PkReset could not be preformed. Character ".$_POST['user']." does not exist.";
		}
	} // End if username was posted
} // End if user was logged in
?>
charreset.php

Code: Select all

<?php

$lvlreq = 350;

$newlvl = 1;
$newexp = 0;
$connected = 0;
$price = "";

$stats = array("str" => array(0 => 18, 1 => 18, 16 => 28, 17 => 28, 32 => 22, 33 => 22, 48 => 26), 
				"agi" => array(0 => 18, 1 => 18, 16 => 20, 17 => 20, 32 => 25, 33 => 25, 48 => 26),
				"vit" => array(0 => 15, 1 => 15, 16 => 25, 17 => 25, 32 => 20, 33 => 20, 48 => 26),
				"nrg" => array(0 => 30, 1 => 30, 16 => 10, 17 => 10, 32 => 15, 33 => 15, 48 => 26));
				
$loc = array("mapno" => array(0 => 0, 1 => 0, 16 => 0, 17 => 0, 32 => 3, 33 => 3, 48 => 0),
			"mapx" => array(0 => 140, 1 => 140, 16 => 140, 17 => 140, 32 => 175, 33 => 175, 48 => 140),
			"mapy" => array(0 => 120, 1 => 120, 16 => 120, 17 => 120, 32 => 100, 33 => 100, 48 => 120));
				
			
if (!isset($_SESSION['domu-user']) || $_SESSION['domu-user'] == "" || $_SESSION['domu-user'] == NULL) {
	echo "<font size="2">Not Logged In";
} else {
	if (!isset($_POST['user']) || $_POST['user'] == "" || $_POST['user'] == NULL) {
?>
<font size="2">Character Reset costs 100,000,000 zen, and sets your character to level 1 with 150 stat points per reset.
<center><form action="<?=$_SERVER['PHP_SELF']?>?p=charreset" method="post">
<font size="2">Character Name: <input type="text" name="user" maxlength="15"> <input type="submit" value="Reset">
</form></center>
<?php
	} else {
		    $conn = mssql_connect('servername', 'account name', 'password');;
   mssql_select_db('MuOnline', $conn);
		if (mssql_num_rows(mssql_query("SELECT * FROM MEMB_STAT WHERE memb___id = '".$_SESSION['domu-user']."'")) > 0) {
			$row = mssql_fetch_array(mssql_query("SELECT * FROM MEMB_STAT WHERE memb___id = '".$_SESSION['domu-user']."'"));
			if ($row['ConnectStat'] == $connected) {
			if (mssql_num_rows(mssql_query("SELECT * FROM Character WHERE Name = '".$_POST['user']."' AND AccountID = '".$_SESSION['domu-user']."'")) > 0) {
			$row = mssql_fetch_array(mssql_query("SELECT * FROM Character WHERE Name = '".$_POST['user']."' AND AccountID = '".$_SESSION['domu-user']."'"));
			if ($row['cLevel'] == $lvlreq) {
				if ($row['Money'] > $row['Gold_Reset']) {
					$query = mssql_query("UPDATE Character SET cLevel = ".$newlvl.", Strength = ".$stats['str'][$row['Class']].", Dexterity = ".$stats['agi'][$row['Class']].", Vitality = ".$stats['vit'][$row['Class']].", Energy = ".$stats['nrg'][$row['Class']].", 
										Money = Money - Gold_Reset, MapNumber = ".$loc['mapno'][$row['Class']].", MapPosX = ".$loc['mapx'][$row['Class']].", MapPosY = ".$loc['mapy'][$row['Class']].", Resets = Resets + 1, LevelUpPoint = (Resets + 1)* Reset_Points, 
										Experience = ".$newexp." WHERE Name = '".$_POST['user']."' AND AccountID = '".$_SESSION['domu-user']."'");
					if (!$query) {
						echo "<font size="2">Reset could not be properly preformed. Database threw an error.";
					
					} else {
						echo "<font size="2">Reset was completed succesfully.";
					}
				} else {
					echo "<font size="2">You need ";
					echo $row['Gold_Reset'];
					echo "<font size="2"> to pay for the cost of reset.  You only have ";
					echo $row['Money'];
					echo "<font size="2">. Because you do not have enough zen, the reset could not be performed.";
					
				}
			} else {
				echo "<font size="2">You need to be level 350, you are level ";
				echo $row['cLevel'];
				echo "<font size="2">.  ";
				echo "<font size="2"> Reset could not be preformed because your level was too low.";
			}
		} else {
			echo "<font size="2">Reset could not be preformed. Character ".$_POST['user']." does not exist.";
		}
		} else {
						echo "<font size="2">Reset could not be performed because your account is logged into the game.  Please log out and try again.";
					}
	} // End if username was posted
} // End if user was logged in
}
?>
P.S permissions are given by the creator for any alteration to the scripts, as long credits are given.


feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Post Reply