bCourtney07 Posted October 31, 2007 Share Posted October 31, 2007 I have login information stored in an access database. I have a form where they enter information to put into the database. Each time they enter in new information it puts a new record with their information along with their ID's. Now my question is, if I have a login page where they put in their id, how can i get that information to stay, like a session id or something? What can i use? Sessions or cookies? I'm lost here ??? ha go figure. Basically i guess just keeping their id to the next page where they enter in additional information so that the id goes into the same record as the additional information if that makes any sense? I appologize if i confuse anyone. i'm pretty confused myself. If someone could point me in the right direction i would greatly appreciate it. Maybe a tutorial? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/75516-php-ms-access-login-question/ Share on other sites More sharing options...
aschk Posted October 31, 2007 Share Posted October 31, 2007 Google php sessions. You'll want to be using the $_SESSION superglobal. Quote Link to comment https://forums.phpfreaks.com/topic/75516-php-ms-access-login-question/#findComment-382018 Share on other sites More sharing options...
bCourtney07 Posted November 1, 2007 Author Share Posted November 1, 2007 Would this be the correct way to do it then? session_start(); if (empty($_SESSION['Employee_ID'])) { $_SESSION['Employee_ID'] = ($_POST['Employee_ID']); } Quote Link to comment https://forums.phpfreaks.com/topic/75516-php-ms-access-login-question/#findComment-382891 Share on other sites More sharing options...
revraz Posted November 1, 2007 Share Posted November 1, 2007 You may want to put a little more security before that. You can write the session after they are validated with their Username/PW, but overall, you have the right idea. Quote Link to comment https://forums.phpfreaks.com/topic/75516-php-ms-access-login-question/#findComment-382892 Share on other sites More sharing options...
bCourtney07 Posted November 1, 2007 Author Share Posted November 1, 2007 Thanks! I'll try that then. My next question is.. how could i validate that the user exists? Here is my code so far <?php session_start(); require("config.php"); if($_GET['action'] == 'check') { if(empty($_POST['Employee_ID']) || empty($_POST['Last_Name'])) { //if everything is not filled in than prints out error message error("blank"); exit; } $sql="SELECT * FROM $analyzer_query WHERE Employee_ID='$Employee_ID' and Last_Name='$Last_Name'"; $result=$db_conn->Execute($sql); //counting table row $count=$db_conn->$result->Fields->Count(); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("Employee_ID"); header("location:WellnessForm.php"); } else { echo "Wrong Employee ID or Password"; } } function error($error) { //if error is equal to blank if($error == 'blank') { echo "Please fill in all the required fields before submitting"; } //if error is equal to blank if($error == 'user') { echo "Please fill in the correct Employee ID"; } } ?> with this in the config.php file <?php $db_conn = new COM("ADODB.Connection"); $connstr = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=F:\Wellness Program\Copy of HR Employee Wellness Program.mdb;"; $db_conn->open($connstr); ?> Quote Link to comment https://forums.phpfreaks.com/topic/75516-php-ms-access-login-question/#findComment-382894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.