Click here to Skip to main content
15,887,135 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: OOP in PHP Pin
Member 127882035-Dec-16 6:30
Member 127882035-Dec-16 6:30 
QuestionRequest: Php 7 Tutorial/Course Recommendation From You Pin
Member 127834388-Oct-16 16:36
Member 127834388-Oct-16 16:36 
QuestionRun multiple PHP versions on same server Pin
manhfh7-Oct-16 6:14
manhfh7-Oct-16 6:14 
QuestionOnly Home page opening after going live Pin
Member 1275803925-Sep-16 20:28
Member 1275803925-Sep-16 20:28 
SuggestionRe: Only Home page opening after going live Pin
Richard Deeming26-Sep-16 2:07
mveRichard Deeming26-Sep-16 2:07 
AnswerRe: Only Home page opening after going live Pin
Richard MacCutchan26-Sep-16 2:48
mveRichard MacCutchan26-Sep-16 2:48 
AnswerRe: Only Home page opening after going live Pin
ZurdoDev26-Sep-16 3:18
professionalZurdoDev26-Sep-16 3:18 
QuestionI am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 7:08
samflex15-Sep-16 7:08 
Greetings experts.

I think I made this more complicated than it needs to be.

Users are required to log in to take a test.

If a user tries logging in, the system checks to see if the user has taken the test or not.

If the user has taken the test, s/he is redirected to a page called registered.php which displays benefits of membership.

If no record exists for this user, the user is taken to the called register.php so s/he can take the test.

The scenarios described above works fine.

However, we are running into a problem where if a user mistakenly enters incorrect username/password, the system assumes the user has logged in correctly but has not taken the test and redirects her to register.php.

We would like to modify the code to perform three checks.

If username/password is not correct, display a message to user that either username or password is incorrect.

If username/password is correct and the user has not taken the test, redirect to register.php.

If username/password is correct and the user has taken the test, redirect user to registered.php.

Any ideas how to modify the code below?

I have spent so much time trying to fix this but it is not working for me.

Thanks a lot in advance for your help.

PHP
   $strSQL = "SELECT u.empl_first, u.username, u.empl_first +' '+ empl_last as fullname, e.Department, e.UnitName, e.empnum FROM users u inner join Employee e on u.Employee_Id = e.EmpNum inner join tblTBA t on u.Employee_Id = t.Employee_Id WHERE USERNAME = '".ms_escape_string($_POST['user'])."'
	and PASSWORD = '".ms_escape_string($pass)."' ";
//	echo $strSQL;
	$sqll = sqlsrv_query($con, $strSQL);

if ($objResult = sqlsrv_fetch_array($sqll, SQLSRV_FETCH_ASSOC)) {
    $firstname = $objResult["empl_first"];
 	$_SESSION["username"] = $objResult["username"];
	header('location:registered.php?user=' . urlencode($firstname));
  }
  If ($user == $_SESSION["username"]) {
    header("location:register.php?user='".ms_escape_string($user)."'&pass='".ms_escape_string($pass)."' ");
  }
  else
  {
  echo "Username and Password Incorrect!";
  }

AnswerRe: I am really stumped on how to check if user exists and redirects. Pin
Richard Deeming15-Sep-16 7:27
mveRichard Deeming15-Sep-16 7:27 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 7:41
samflex15-Sep-16 7:41 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
Richard Deeming15-Sep-16 7:52
mveRichard Deeming15-Sep-16 7:52 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 9:10
samflex15-Sep-16 9:10 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 10:30
samflex15-Sep-16 10:30 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
Richard Deeming15-Sep-16 10:50
mveRichard Deeming15-Sep-16 10:50 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 11:14
samflex15-Sep-16 11:14 
QuestionButton working on second click and not first. Pin
Member 1189879629-Aug-16 4:51
Member 1189879629-Aug-16 4:51 
AnswerRe: Button working on second click and not first. Pin
Planet Thomas4-Jul-17 1:22
Planet Thomas4-Jul-17 1:22 
QuestionPassing Values to the next Page in PHP Pin
Androoidhotspot Hotspot19-Aug-16 2:28
Androoidhotspot Hotspot19-Aug-16 2:28 
AnswerRe: Passing Values to the next Page in PHP Pin
ZurdoDev19-Aug-16 3:26
professionalZurdoDev19-Aug-16 3:26 
QuestionBasic Join Not Working Pin
Django_Untaken19-Aug-16 0:43
Django_Untaken19-Aug-16 0:43 
SuggestionRe: Basic Join Not Working Pin
Richard MacCutchan19-Aug-16 2:00
mveRichard MacCutchan19-Aug-16 2:00 
GeneralRe: Basic Join Not Working Pin
Django_Untaken19-Aug-16 2:17
Django_Untaken19-Aug-16 2:17 
GeneralRe: Basic Join Not Working Pin
Richard MacCutchan19-Aug-16 3:14
mveRichard MacCutchan19-Aug-16 3:14 
GeneralRe: Basic Join Not Working Pin
johnjonny10-Oct-16 8:18
johnjonny10-Oct-16 8:18 
Questionassignment Pin
Eto'o3-Aug-16 12:15
Eto'o3-Aug-16 12:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.