garethhall Posted August 30, 2008 Share Posted August 30, 2008 Hello Guys any help that anyone could provide would be awesome I have a mysql database with a table containing clientId clientName clientEmail clientPassword What I want should be pretty easy or so I thought. Here is what I need, When a client logs in he should be taken to client.php page but the url must contain the relevant clientId for the relevant client. I cant's seem to get it right. Now to start there is an error with the following variable "$MM_redirectLoginSuccess" I dont know whats wrong with it? Many Thanks <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['name'])) { $loginUsername=$_POST['name']; $password=$_POST['pass']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "clientPage.php?clientId=<?php echo $_GET['clientId']; ?>"; $MM_redirectLoginFailed = "index.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_connClient, $connClient); $LoginRS__query=sprintf("SELECT client Id clientEmail, clientPassword FROM clients WHERE clientEmail=%s AND clientPassword=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $connClient) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Link to comment https://forums.phpfreaks.com/topic/122038-solved-log-in-help-please-trouble-passing-a-variable/ Share on other sites More sharing options...
pocobueno1388 Posted August 30, 2008 Share Posted August 30, 2008 Change $MM_redirectLoginSuccess = "clientPage.php?clientId=<?php echo $_GET['clientId']; ?>"; To $MM_redirectLoginSuccess = "clientPage.php?clientId=" . $_GET['clientId']; Link to comment https://forums.phpfreaks.com/topic/122038-solved-log-in-help-please-trouble-passing-a-variable/#findComment-629989 Share on other sites More sharing options...
garethhall Posted August 31, 2008 Author Share Posted August 31, 2008 I changed it now it logs in but the clientId is null Here is the url when it is passed pixelFileManagment/clientPage.php?clientId= as you can see no clientId thanks Link to comment https://forums.phpfreaks.com/topic/122038-solved-log-in-help-please-trouble-passing-a-variable/#findComment-630224 Share on other sites More sharing options...
JasonLewis Posted August 31, 2008 Share Posted August 31, 2008 You wouldn't know the clients ID yet. Try this code: <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['name'])) { $loginUsername=$_POST['name']; $password=$_POST['pass']; $MM_fldUserAuthorization = ""; $MM_redirectLoginFailed = "index.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_connClient, $connClient); $LoginRS__query=sprintf("SELECT client Id clientEmail, clientPassword FROM clients WHERE clientEmail=%s AND clientPassword=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $connClient) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; $data = mysql_fetch_assoc($loginRS); $id = $data['clientId']; $MM_redirectLoginSuccess = "clientPage.php?clientId=".$id; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Link to comment https://forums.phpfreaks.com/topic/122038-solved-log-in-help-please-trouble-passing-a-variable/#findComment-630229 Share on other sites More sharing options...
garethhall Posted August 31, 2008 Author Share Posted August 31, 2008 Hey thanks for all your help, I got it working now for any one that is interested here is the updated code <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['name'])) { $loginUsername=$_POST['name']; $password=$_POST['pass']; $MM_fldUserAuthorization = ""; $MM_redirectLoginFailed = "index.php"; $MM_redirecttoReferrer = true; mysql_select_db($database_connClient, $connClient); $LoginRS__query=sprintf("SELECT clientId, clientEmail, clientPassword FROM clients WHERE clientEmail=%s AND clientPassword=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $connClient) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); $returnClientId = mysql_fetch_assoc($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; $clientId = $returnClientId['clientId']; $MM_redirectLoginSuccess = "clientPage.php?clientId=".$clientId; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && true) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> Link to comment https://forums.phpfreaks.com/topic/122038-solved-log-in-help-please-trouble-passing-a-variable/#findComment-630250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.