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

Linux, Apache, MySQL, PHP

 
AnswerRe: Only Home page opening after going live Pin
Richard MacCutchan26-Sep-16 3:48
mveRichard MacCutchan26-Sep-16 3:48 
AnswerRe: Only Home page opening after going live Pin
ZurdoDev26-Sep-16 4:18
professionalZurdoDev26-Sep-16 4:18 
QuestionI am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 8:08
samflex15-Sep-16 8:08 
AnswerRe: I am really stumped on how to check if user exists and redirects. Pin
Richard Deeming15-Sep-16 8:27
mveRichard Deeming15-Sep-16 8:27 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 8:41
samflex15-Sep-16 8:41 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
Richard Deeming15-Sep-16 8:52
mveRichard Deeming15-Sep-16 8:52 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 10:10
samflex15-Sep-16 10:10 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 11:30
samflex15-Sep-16 11:30 
Sorry Richard,

I tried doing it separately like you spec'ed it out and it is just not working.

The first part which validates username/password works but when I added the second part, then it doesn't matter whether I have correct username and password, it just takes me to login page.

The code you see here shows I am doing them together again with if...else but that's just what I am trying since separating them isn't working.

PHP
 $user = trim($_POST["user"]);
 $pass = trim($_POST["pass"]);

     // hash to sanitize the input further

//	$tsql = md5($pass);

   $tsql = "SELECT u.empl_first, u.username, u.empl_first +' '+ empl_last as fullname FROM users u WHERE u.USERNAME = ? and u.PASSWORD = ? ";
	//echo $strSQL;
	$params = array($user, $pass);
    $result = sqlsrv_query( $con, $tsql, $params, array(), array( "Scrollable" => 'static' ));

    $row_count = sqlsrv_num_rows($result);
    //echo $row_count;

    if ($row_count == 0){
       header('location:login.php?msg=1');
       exit;

}

else
{
   $tSQL = "SELECT u.empl_first, u.username FROM users u inner join tblTBA t on u.Employee_Id = t.Employee_ID WHERE USERNAME = '".ms_escape_string($user)."'
	and PASSWORD = '".ms_escape_string($pass)."' ";
	echo $strSQL;
    //$params = array($user, $pass);
	$sqll = sqlsrv_query($con, $tSQL);
}
if ($objResult = sqlsrv_fetch_array($sqll, SQLSRV_FETCH_ASSOC)) {
    $firstname = $objResult["empl_first"];
 	$_SESSION["username"] = $objResult["username"];
	header('location:donetba.php?user=' . urlencode($firstname));
  }
  else
    header("location:registered.php?user='".ms_escape_string($user)."'&pass='".ms_escape_string($pass)."' ");
   // header("location:register.php?user=. urlencode($user)&pass=. urlencode($pass)");

sqlsrv_close($con);

?>

GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
Richard Deeming15-Sep-16 11:50
mveRichard Deeming15-Sep-16 11:50 
GeneralRe: I am really stumped on how to check if user exists and redirects. Pin
samflex15-Sep-16 12:14
samflex15-Sep-16 12:14 
QuestionButton working on second click and not first. Pin
Member 1189879629-Aug-16 5:51
Member 1189879629-Aug-16 5:51 
AnswerRe: Button working on second click and not first. Pin
Planet Thomas4-Jul-17 2:22
Planet Thomas4-Jul-17 2:22 
QuestionPassing Values to the next Page in PHP Pin
Androoidhotspot Hotspot19-Aug-16 3:28
Androoidhotspot Hotspot19-Aug-16 3:28 
AnswerRe: Passing Values to the next Page in PHP Pin
ZurdoDev19-Aug-16 4:26
professionalZurdoDev19-Aug-16 4:26 
QuestionBasic Join Not Working Pin
Django_Untaken19-Aug-16 1:43
Django_Untaken19-Aug-16 1:43 
SuggestionRe: Basic Join Not Working Pin
Richard MacCutchan19-Aug-16 3:00
mveRichard MacCutchan19-Aug-16 3:00 
GeneralRe: Basic Join Not Working Pin
Django_Untaken19-Aug-16 3:17
Django_Untaken19-Aug-16 3:17 
GeneralRe: Basic Join Not Working Pin
Richard MacCutchan19-Aug-16 4:14
mveRichard MacCutchan19-Aug-16 4:14 
GeneralRe: Basic Join Not Working Pin
johnjonny10-Oct-16 9:18
johnjonny10-Oct-16 9:18 
Questionassignment Pin
Eto'o3-Aug-16 13:15
Eto'o3-Aug-16 13:15 
AnswerRe: assignment Pin
Richard MacCutchan3-Aug-16 23:02
mveRichard MacCutchan3-Aug-16 23:02 
QuestionGoogle Translate facility Pin
Member 1264382519-Jul-16 19:51
Member 1264382519-Jul-16 19:51 
AnswerRe: Google Translate facility Pin
Richard MacCutchan19-Jul-16 23:39
mveRichard MacCutchan19-Jul-16 23:39 
QuestionFor Linux Admin Fresher Pin
Abijith Ajayan12-Jul-16 19:05
Abijith Ajayan12-Jul-16 19:05 
AnswerRe: For Linux Admin Fresher Pin
Richard MacCutchan12-Jul-16 22:28
mveRichard MacCutchan12-Jul-16 22:28 

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.