Good evening, I'm doing an ATM on php with mysql and I have the following question:
use the username and password system of agustin ramos (on the internet you can find it)
which works as follows:
You have the enter.php where you get to enter the username and password
then the action of that form is called login and has all the comparisons to verify that they exist in the database
Then it sends you to the home where you have the options of connected
I have in my case instead of the user table with user and password I have the card table associated with it and it asks for card number and card code
I would like then that:
that card number (num_tar) will be saved in a variable and it will arrive to home.php and then use it, I thought of placing it in the login.php (where the functions are) but I get it in home.php not defined.
HERE THE LOGIN.php CODES
<?php
if(!empty($_POST)){
if(isset($_POST["num_tar"]) &&isset($_POST["cod_tar"])){
if($_POST["num_tar"]!=""&&$_POST["cod_tar"]!=""){
include "conexion.php";
$user_id=null;
$sql1= "select * from tarjeta where (num_tar=\"$_POST[num_tar]\" and cod_tar=\"$_POST[cod_tar]\")";
$query = $con->query($sql1);
while ($r=$query->fetch_array()) {
$user_id=$r["num_tar"];
break;
}
if($user_id==null){
print "<script>alert(\"Acceso invalido.\");window.location='../index.php';</script>";
}else{
session_start();
HERE I TRY TO PASS IT BUT I DO NOT KEEP IT
global $num;
$num=$_POST['num_tar'];
$_SESSION["conectado"]=$user_id;
print "<script>window.location='../home.php';</script>";
}
}
}
}
?>
I think the problem is that the system would have to pass it to login.php first and then to home.php but in home.php I will not declare the variables