session problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

session problem

creating system for tracking the device ,every device has a device number , i linked all tables using the device_no but when i want to insert the device_no in another table it is not insert , itried using session to pass the variable of the device number but also not working, i already have a session file use it to save the user name and work. i even tried to check if the session is carrying the value but it is seems null i don't know what is the problem

14th Jun 2017, 8:23 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
11 Answers
+ 1
btw it is working now the problem was i using html and php for action so i made the whole page php and using get id i could pass the id and insert it wjth other info to the data base thanks
26th Jun 2017, 2:12 PM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
0
Provide some code, and tell us: a) what you want that code to do, and b) what is not working.
14th Jun 2017, 8:46 AM
Bogdan Sass
Bogdan Sass - avatar
0
what i want is to pass the device number for specific device that i clicked on the its link the device number is appear in the url but how i can this device number? $dept_name = $_POST['dept_name']; //$device_no = $_SESSION['device_no'] ; $type_device = $_POST['type_device']; $maintenance = $_POST['maintenance']; $date=$_POST['date']; /*//$dept_id=mysql_real_escape_string( $dept_id); the code is for sql injuction*/ $dept_name = mysql_real_escape_string( $dept_name); $device_no= mysql_real_escape_string( $device_no); $type_device=mysql_real_escape_string( $type_device); $maintenance= mysql_real_escape_string( $maintenance); $date = mysql_real_escape_string( $date ); /* the insertion statement */ $query = "insert into periodic_main ( dept_name,device_no,type_device,maintenance,date) VALUES ('$dept_name', '$device_no','$type_device','$maintenance','$date')"; mysql_query($query); $query = (isset($_GET['query']) ? $_GET['query'] : null); $status = "New Record Inserted Successfully.";
14th Jun 2017, 8:58 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
0
i tried use session but it is not working for me this the session code <?php // Establishing Connection with Server by passing server_name, user_id and password as a parameter $connection = mysql_connect("localhost", "root", ""); // Selecting Database $db = mysql_select_db("test", $connection); session_start();// Starting Session $_SESSION['device_no']=$device ; $device= mysql_query("select device_no from data_store where device_no= '$device'" ) ; $rows =mysql_fetch_array($device) ; $_SESSION['device_no']=$rows['device_no'] ; echo "sucess" .$_SESSION['device_no'] ; if(!empty($_SESSION['device_no'])) { echo("null") ; } ?>
14th Jun 2017, 8:59 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
0
send me freind request on facebook [email protected]
14th Jun 2017, 10:23 AM
mohamed alnour abdellah
mohamed alnour abdellah - avatar
0
It's not clear how you pass the value to your script. Because first you say "device number appears in the URL" (which implies GET), but then you try to get it via POST (in which case it would not appear in the URL). How do you send the device number to the script? (what does the link that you click on before getting to this script look like?)
14th Jun 2017, 10:59 AM
Bogdan Sass
Bogdan Sass - avatar
0
first i look for the device by it is number or the device number then appear screen with the basic device information the page include link related the device consist of more deatils about the device what i am tryin to do to link all the information for each device making record ti the device but i could't make them link i couldn't pass the device number to save it in another table to use it later in the reports., that it iwant to pass the device number from on e table to another table trying using the seeion but i think there is something wrong.i couldn't find you on facebook try to search for me [email protected]
15th Jun 2017, 8:40 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
0
i click on the link to get to the particular device from the list search so the device number for the device is appear
16th Jun 2017, 8:16 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
0
i tried to use get method but it is not working because i have to pass info from the form so i used post method beside i wnat mkre than the device number to get pass like device type and the model which are saved in another table so for every device which has device number i want to pass the device number and the model and the type(pc or printer) to another table also using device number use it to link the tables
16th Jun 2017, 8:20 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar
0
If you used POST, you will need the $_POST variable in the receiving php code...
16th Jun 2017, 8:34 AM
Bogdan Sass
Bogdan Sass - avatar
0
i already use that in php code what i mean i try to pass the required values usinf session but the session array didn't take the value i pass saind inidefine index so if there any other way tell me but please not cookies
17th Jun 2017, 7:56 AM
Esraa Awad Alhaj Naem
Esraa Awad Alhaj Naem - avatar