ajax call-if the user is login

Asked

Viewed 20 times

0

I started a new application in HTML5 and it recovers the data from the database by ajax I started with this code: it is an online scoring system and I liked to change it to recover the user_points column. For example, if the user is logged in I want to recover their points. This code calls all user points i would like to switch to recover only user data that is logged in.

The database is Composed By database publiadd_loginsx table users Columns user_email user_id user_name user_pass user_points

<?php
header('Access-Control-Allow-Origin: *');




$host="localhost"; // Host name 
$username="user"; // Mysql username 
$password="pass"; // Mysql password 
$db_name="database"; // Database name 
$tbl_name="users"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Retrieve data from database 
$sql="SELECT * FROM users ORDER BY user_points DESC LIMIT 10";
$result=mysql_query($sql);

// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
echo $rows['user_name'] . "|" . $rows['user_points'] . "|";

// close while loop 
}

// close MySQL connection 
mysql_close();
?>

  • Welcome to Stack Overflow at Português. Please translate your question.

  • I started a new application in HTML5 and I want to call the database data corresponding to the logged in user in this case user_points good this code it does this but tras me all the users available in that column and I wanted to call only the logged in user what I have to change so that you can only call user_points from that user?

  • Helder, translate the text of your question by clicking [Edit], so that it is not closed because it is in another language.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.