(Not my actual code)
Code: Select all
$result="SELECT * from players where name='$player' ";
$result2=mysql_query($result) or die("Could not retrieve info from table");
$result3=mysql_fetch_array($result2) or die("Could not retrieve array");
here is the code for the files I am having trouble with
reguser.php
Code: Select all
<?php
include_once 'connect.php';
?>
<?php
include 'logo.php';
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="reguser" align="center">
<?php
$player=$_GET['player'];
$password=$_GET['password'];
$pass2=$_GET['pass2'];
$email=$_GET['email'];
if($email == "")
{
echo "You did not enter an email!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
exit;
}
if($pass2 != $password)
{
echo "Your passwords did not match!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
exit;
}
if($player == "")
{
echo "You did not enter a username!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
exit;
}
if ($password == "")
{
echo "You did not enter a password!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
exit;
}
if($pass2 == "")
{
echo "You did not retype your password!?<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
exit;
}
if($password == $pass2)
{
$isplayer="SELECT * from players where name='$player'";
$isplayer2=mysql_query($isplayer) or die("Could not get players");
$isplayer3=mysql_fetch_array($isplayer2) or die("Could not get array");
}
if($isplayer3)
{
echo "There is already someone with that name!<br/><a href='register.php'><input type='submit' value='Go Back' name='submit' />";
exit;
}
else
{
$password=md5($password);
$mysql="INSERT into players(name, password, email, level, exper, hpoints, attack, defence, damage) VALUES ($name, $password, $email, 1, 0, 30, 5, 5, 5)";
mysql_query($mysql) or die("Could not update players");
echo "Thanks for registering!<br/><a href='login.php'><input type='submit' value='Login' name='submit' />";
}
?>authenticate.php
Code: Select all
<?php
include_once 'connect.php';
session_start()
?>
<link href="style.css" rel="stylesheet" type="text/css" />
<div id="authenticate" align="center">
<?php
include 'logo.php';
?>
<?php
if (isset($_POST['submit']));
{
$player=$_POST['name'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=strip_tags($password);
$query="SELECT name, password from players where name='$player' and password='$password'";
$result=mysql_query($query) or die("Could not get player information");
$result2=mysql_fetch_array($result) or die("Could not get player information query");
if($result2)
{
$_SESSION['player']=$player;
echo "Logged in succesfully!<br/><a href='index.php'><input type='submit' value='Enter the game' name='submit'>";
}
else
{
echo "Wrong username or password!<br/><a href='login.php'><input type='submit' value='Go back' name='submit'>";
}
}
?>