I've got this in index.php
<?php
include_once '..\connect.php';
session_start();
if (isset($_SESSION['username'])){
$player_name = $_SESSION['username'];
} else {
header( 'Location: http://localhost/Inventory/index.php' ) ;
exit;
}
?>
and im making a ajax request to request.php
<?php
//connect to databate and check for errors
$con = mysql_connect ("localhost","root","");
if (!$con) {
die ('Could not connect to database: ' . mysql_error());
}
//select database and check selection
if (!mysql_select_db ("GotA", $con)) {
die ('Could not select database: ' . mysql_error());
}
//I have to create this if not it doesnt find the sessions $player_name variable
$player_name = $_POST['name'];
//***Create Player Array**//
$player_info = "SELECT * from players where id = $player_name";
$player_info2 = mysql_query($player_info) or die ('Couldnt get players name');
$player_info3 = mysql_fetch_array($player_info2);
Well it just seems unsecure to retrive data from the databe using a variable sent with javascript isnt there a way to directly use the variable from the index.php (session part)? or is it safe to just pass the information with javascript?