Jump to content

PHP and MySQLi


magcr23
Go to solution Solved by Ch0cu3r,

Recommended Posts

Hi guys, i have this code:

 

$sql="SELECT * FROM admin";

$resultado = mysqli_query($con, $sql);

$row=mysqli_fetch_array($resultado,MYSQLI_NUM);

 

<?php echo $row[0] ?>

 

It returns the first user of the table, but i want the user who's loged, someone can help me with that?

Link to comment
Share on other sites

I tried to do something like that:

 

$row=mysqli_fetch_array($resultado,MYSQLI_ASSOC);

$user = $row['user'];

echo $user;

 

But the result is the same.

Can you tell me what am i doing wrong? Or modify my code to do what i need? 

I need this problem solved to continue with my project, or i'll fail in my class xD

Link to comment
Share on other sites

I think that half of the problem is solved, with that i can see the right user who's logged.

 



$row=mysqli_fetch_array($resultado,MYSQLI_ASSOC);
$user2 = $_SESSION["user"];
echo $user2;


 

But how can i update an password?

 

I tryed with that:

 



$updatePW= "UPDATE admin SET password = sha1('$new') WHERE user = password = sha1('$old') ";


 

But it update all the equal passwords. So i tryed with that:

 



$updatePW= "UPDATE admin SET password = sha1('$new') WHERE user = $user2 && password = sha1('$old') ";


 

But it don't work... What can i do?
Link to comment
Share on other sites

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.