I am developing a Web page, which has corresponding users to cities, to be more precise it is built in the following way (and it is done in Postgres)
USER
┌────────────┬───────────┐ │ cv_usuario │ Password │ ├────────────┼───────────┤ │ 011 │ Ciudad1 │ │ 022 │ Ciudad2 │ └────────────┴───────────┘
And on the other hand I have the CITIES table
┌────────────┬───────────┬─────────────┐ │ cv_ciudad │ nombre │ Habitantes │ ├────────────┼───────────┼─────────────┤ │ 011 │ Del Valle │ 123823 │ │ 022 │ Madero │ 998337 │ └────────────┴───────────┴─────────────┘
Basically my website needs to do the following:
- Login (that you enter with the username corresponding to your city code)
- When you access, open a map that I have mounted with a Google API, which has the layers of the cities
- When you click on the SEE FILE button, you must upload all the data corresponding to that city (launch a query with the corresponding data), BUT, if you click on a different city, you should show a message:
¡No tiene permiso para acceder a los datos de esta ciudad!
Until now I have managed to access the click to the city with which I access but I have not been able to validate with a different city. I'm working with php
My php code of the Login where I build my valiable logon
session_start();
$_SESSION['varname'] = $userName;
echo "Welcome " . $userName;
header("Location: ../index.php"); //Me dirijo a index de mi página que contiene el mapa
In my map I show a small file with a link, which contains an xml where I manage a predator to direct to the information card with its corresponding key
<campo predato="CIUDAD|http://127.0.0.1/CIUDADES/verficha.php?varname=">
<nombre>clavegeo</nombre>
<alias>Ficha</alias>
</campo>
and in my information sheet I have the following: Reassign what is stored at the start of the session in another variable
$ciudad = $_SESSION['varname'];
and there my question comes as valid so that it only shows what corresponds to that city. at the moment I have something like that
if ($ciudad) {
$query="Select *
from ciudad
where cv_ciudad
in ($ciudad) )
;";
$result = pg_query($query) or die('Query failed: ' .
pg_last_error());
$rows = pg_num_rows ($result);
$i = pg_num_fields($result);
}
else {
echo "<br><center>¡No tiene permiso para acceder a los datos de esta ciudad!";
echo $ciudad;
}
However, if I click on another city and I give it in -show sign- it sends me perfectly the query of that city even if it does not correspond with the password with which I access in the login: (
I hope you can help my friends, thank you in advance