antiblock
Rodnia | Alpha & Omega
  • Chatbox

    Did you check out our Discord? https://discord.gg/FFdvMjk9xA
    You don't have permission to chat.
    Load More
Sign in to follow this  
Silvaa

Php Show Data From User

3 posts in this topic

Boas gente,

 

Tenho auqi um problemazinho que é..

O objetivo deste codigo seria mostrar os registos do user em sessao, apenas dos dele...

Mas nao esta dando certo... Se alguem souber solucionar agradecia.

		$user_id = SearchUser($_SESSION['user']['id']);
		$ok = true;
		
		//Check user function "SearchUser"
		if(SearchUser($user_id)) {
			
			$dbh = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
			$procurarUser = $dbh->prepare("SELECT ID_Article,ID_Utilizador, Data_Compra, Price, Cred_Depois FROM reg_log ORDER BY Data_Compra WHERE id='$user_id'");
			$procurarUser->execute();		
			$checkUser = $procurarUser->fetchAll();
			  
			  foreach($checkUser as $User)
			  {
			  echo "<table>";
			  echo "<tr>";
			  echo "<td><b>Artigo</b></td>";
			  echo "<td><b>ID</b></td>";
			  echo "<td><b>Preço</b></td>";
			  echo "<td><b>Creditos Anteriores</b></td>";
			  echo "<td><b>Data & Hora</b></td>";
			  echo "</tr>";
			  echo "<br /><tr><td>" . $User['ID_Article'] . "</td><td>". $User['ID_Utilizador'] . "</td><td>" . $User['Price'] . "</td><td>". $User['Cred_Depois'] . "</td><td>" . $User['Data_Compra'] . "</td></tr> " ;
			  echo "</table>";
			  }
			
				$ok = true;
				$dbh = null; //close db
		
		} else {
				echo "You have no purchases.";
				$ok = false;
		}

Share this post


Link to post
Share on other sites
antiblock
Rodnia | Alpha & Omega

Para começar isso tá vulnerável

testa

function getUserdataByID($id){
            $procurarUser = $dbh->prepare("SELECT ID_Article,ID_Utilizador, Data_Compra, Price, Cred_Depois FROM reg_log ORDER BY Data_Compra WHERE id= :uid");
            $procurarUser->BindValue(':uid', $userid, PDO::PARAM_INT);
            $procurarUser->execute();        
            while($checkUser = $procurarUser->fetch(PDO::FETCH_ASSOC)):
                  $userinfo[] = $checkUser;
            endwhile;
return $userinfo;
}
             foreach(getUserdataByID($userid) as $User)
             {
             echo "<table>";
             echo "<tr>";
             echo "<td><b>Artigo</b></td>";
             echo "<td><b>ID</b></td>";
             echo "<td><b>Preço</b></td>";
             echo "<td><b>Creditos Anteriores</b></td>";
             echo "<td><b>Data & Hora</b></td>";
             echo "</tr>";
             echo "<br /><tr><td>" . $User['ID_Article'] . "</td><td>". $User['ID_Utilizador'] . "</td><td>" . $User['Price'] . "</td><td>". $User['Cred_Depois'] . "</td><td>" . $User['Data_Compra'] . "</td></tr> " ;
             echo "</table>";
             }
 
 

Share this post


Link to post
Share on other sites

WOWWWWWWWWWWWWWWWWWWWWW!

 

Conseguiste fazer uma script vulnerável com PDO.

 

Isto é algo sem precedentes. Parabéns, és lendário.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this