scottreid1974 Posted January 26, 2007 Share Posted January 26, 2007 HiI am still having probles with this, i know it is only a simple call the correct field and set it as a location, but i cant get it to work, my code is below.I want to be able to have a user log on and then have a website automatically open that is specific to them, (one i have attached to their user name and password in a mysql database). I have ID, password, username,url stored in database rows.All I can do at the minute is a normal logon script which automatically takes all accounts to the same page after logon-on.For example, when user fred12, password - werryu logs on, i want to send him to www.yahoo.co.uk, and when user jane34, password - aserwg logs on, i want to send her to www.yell.com, and so on. I cant get the forwarding bit of the logon to work.<?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['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = "access"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_testconn1, $testconn1); $LoginRS__query=sprintf("SELECT username, password, url, access FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"),GetSQLValueString($url, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $testconn1) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result ($LoginRS,0,'access'); $result = mysql_query("select url from users");while( $usersURL = mysql_fetch_array ( $query ) )$url=$usersURL["url"]; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header('Location: '.$usersURL); } else { header("Location: ". $MM_redirectLoginFailed ); }}?>plllzzz helpThanks Link to comment https://forums.phpfreaks.com/topic/35848-solved-problem-with-header-location-on-user-logon/ Share on other sites More sharing options...
genericnumber1 Posted January 26, 2007 Share Posted January 26, 2007 Not sure if this is your only problem but the following line obviously isn't correct...[code]$LoginRS__query=sprintf("SELECT username, password, url, access FROM users WHERE username=%s AND password=%s",GetSQLValueString($loginUsername, "text"),GetSQLValueString($url, "text"), GetSQLValueString($password, "text")); [/code]you're sticking in the URL for the passwordyou're also doing this...[code]$url=$usersURL["url"]; [/code]but later doing[code]header('Location: '.$usersURL);[/code]it probably should be[code]header('Location: '.$url);[/code] Link to comment https://forums.phpfreaks.com/topic/35848-solved-problem-with-header-location-on-user-logon/#findComment-170027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.