Jump to content

Recommended Posts

Hi. I'm trying to make a simple website for a game called assassin. I have a mysql table called players which includes the columns playeralias, playertarget, playerpass, and playerword. Each player has a target that they have to kill and they have to make that target say a certain word to do so. I am trying to make a simple php script that will check a password with one in the database (plaintext, I know it's not secure but I'm just messing around. Same goes for messy code, I'm a beginner), then get the player's target and the word from that target's row. The script works fine in returning the error for an incorrect password or alias, but when I run it in a situation where it should work for returning the player's target etc. the variables do not show up. It simply returns

"Your current target is  and you must use the word  to eliminate them"

Is there an obvious error I'm missing?

 

<?php
include 'includes/config.php';
include 'includes/opendb.php';

//Define Variables
$playeralias = $_POST['alias'];
$password = $_POST['password'];

//Access SQL data for specified alias
$query = "SELECT playerpass FROM players WHERE playeralias = '$playeralias'";
$result = (mysql_query($query));

//Access password and compare it
$storedpass = mysql_fetch_row($result);
$storedpass = $storedpass[0];

if ($storedpass == $password)

{
$query = "SELECT * FROM players WHERE playeralias = '$playeralias'";
$result = (mysql_query($query));
$target = mysql_fetch_row($result);
$finaltarget = $target['playertarget'];

$query = "SELECT * FROM players WHERE playeralias = '$finaltarget'";
$result = (mysql_query($query));
$word = mysql_fetch_row($result);
$finalword = $word['playerword'];

echo "Your current target is ".$finaltarget." and you must use the word ".$finalword." to eliminate them";}

else {exit("<font color=\"white\">Error: Alias or password was incorrect");}

include 'includes/closedb.php';
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.