Page 1 of 1

PHP GET not grabbing ID [RESOLVED]

Posted: Wed Oct 08, 2014 6:40 am
by Epiales
Why is it not grabbing the users ID on the attack.php?

Main page that displays the <a href> that leads to attack.php where it should GET the id passed on.

Code: Select all

<?php
$sql2 = mysql_query("SELECT username, family, strength, id FROM users ORDER BY strength DESC $limit"); 
$outputList = '';
while($row = mysql_fetch_array($sql2)){

    $get_user = "SELECT `username` FROM `users` WHERE `id`='".$row['id']."'";
    $user_query1 = mysqli_query($db_conx, $get_user);
    $numrows = mysqli_num_rows($user_query1);
    $rank_name = mysqli_fetch_assoc($user_query1);
 
    $id = $row['id'];
    $firstname = $row["username"];
    $family = $row["family"];
    $strength = $row["strength"];
    
    $outputList .= '<table border="0" bgcolor="590c02" width="99%"><td width="15%"><b><font color="white">' . $firstname . '</td><td align="left" width="15%"><b><font color="white">' . $family  . '</td><td><b><font color="white"><img src="images/strength.png">' .number_format($strength) . '</td><td width="15%"><a href="attack.php?id=".$row[id]."\"><img src="images/Handgun.png" width="30" height="30"></a> <img src="images/notification.png" width="30" height="30"> <img src="images/mail.png" width="30" height="30"></td><td width="5%"><img src="images/robber.png" width="20" height="20"></td></b></table>';
?>
My attack.php... Not much there as I want to just try and get it to pass the ID over first

Code: Select all

<?php include_once("php_includes/check_login_status.php")?>
<?php include_once("leftbar.php")?>
<?php include_once("rightbar.php");  ?>  
<?php include_once("includes/functions.php");  ?>  

<?php

$username = $_SESSION["username"];

// Select the member from the users table
$sql = "SELECT * FROM users WHERE username='$username' AND activated='1' LIMIT 1";
$user_query = mysqli_query($db_conx, $sql);
// Now make sure that user exists in the table
$numrows = mysqli_num_rows($user_query);
if($numrows < 1){
header("location: filenotfound.php");
    exit();
}
?>

<div id="pageMiddle">
<link href="style/style.css" rel="stylesheet" type="text/css" />

<?php

        $id = protect($_GET['id']);
    
$user_check = "SELECT * FROM `users` WHERE `id`='".$id."'";
$user_query = mysqli_query($db_conx, $user_check);
        
if(mysqli_num_rows($user_query) == 0){
            echo "There is no user with that ID!";
       }else{
       
       echo "works";
       }
?>
Thanks for any help/assistance :)

Re: PHP GET not grabbing ID

Posted: Wed Oct 08, 2014 10:16 am
by MikuzA

Code: Select all

<a href="attack.php?id=".$row[id]."\">
Should be

Code: Select all

<a href="attack.php?id='.$row[id].'\">

Re: PHP GET not grabbing ID

Posted: Wed Oct 08, 2014 9:41 pm
by Epiales
MikuzA wrote:

Code: Select all

<a href="attack.php?id=".$row[id]."\">
Should be

Code: Select all

<a href="attack.php?id='.$row[id].'\">
Thanks! I put the 's around the id and it works :) I knew I'd missed something somewhere grrr.