whizzykid Posted May 6, 2009 Share Posted May 6, 2009 Hi i am having some problems with this code my $loginUsername is suppose to link the username entered to the account or welcome page if login success but it doesnt.It takes all of the success login to a particular page instead of indivduals pages. Helpppppp. if (isset($_POST['Customer_Number'])) { $loginUsername=$_POST['Customer_Number']; $password=$_POST['Sort_Code']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "welcome to.php"; $MM_redirectLoginFailed = "You are not logged in.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_ellen, $ellen); $LoginRS__query=sprintf("SELECT `Customer Number`, `Sort Code` FROM log WHERE `Customer Number`=%s AND `Sort Code`=%s", GetSQLValueString($loginUsername, "-1"), GetSQLValueString($password, "-1")); $LoginRS = mysql_query($LoginRS__query, $ellen) 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']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/ Share on other sites More sharing options...
Zhadus Posted May 6, 2009 Share Posted May 6, 2009 First, why is there a space in this: $MM_redirectLoginSuccess = "welcome to.php"; Additionally, change the following: if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } to this: if (isset($_SESSION['PrevUrl'])) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827712 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 Thanks but it still doesnt work. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827733 Share on other sites More sharing options...
Zhadus Posted May 6, 2009 Share Posted May 6, 2009 What is/are the pages you want to redirect people to if it's a successful login? Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827736 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 I want to redirect them To their Individual personal account page. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827741 Share on other sites More sharing options...
premiso Posted May 6, 2009 Share Posted May 6, 2009 I want to redirect them To their Individual personal account page. How is that page setup? You need to know what the page name is somehow...so how do you "personalize" their account page? Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827745 Share on other sites More sharing options...
w3evolutions Posted May 6, 2009 Share Posted May 6, 2009 The script you have will redirect to $MM_redirectLoginSuccess = "welcome to.php" if they are a valid user, or to $MM_redirectLoginSuccess = $_SESSION['PrevUrl'], which I'm assuming is the previous URL. You have to change the value of $MM_redirectLoginSuccess for each user based on who they login as. What are the page names for each user (you don't have to list them all just as an example)? Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827750 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 When they login it takes all to welcome.php Want it to take them to individual page or row from the table in the database. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827753 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 The script you have will redirect to $MM_redirectLoginSuccess = "welcome to.php" if they are a valid user, or to $MM_redirectLoginSuccess = $_SESSION['PrevUrl'], which I'm assuming is the previous URL. You have to change the value of $MM_redirectLoginSuccess for each user based on who they login as. What are the page names for each user (you don't have to list them all just as an example)? Ok hv got 2pages e.g profile1 and the 2nd page profile2 do i hv to list the pages e.g $MM_redirectLoginSuccess=profile1 and profile2 then i hv to set each value for each login and password? Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827766 Share on other sites More sharing options...
Zhadus Posted May 6, 2009 Share Posted May 6, 2009 You'll need to connect the profiles with the users somehow. I notice in the query you draw the customer number, use that. <?php if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } else { $profile = mysql_fetch_array($LoginRS); $MM_redirectLoginSuccess = "profile_" . $profile[0] . ".php"; } header("Location: " . $MM_redirectLoginSuccess ); ?> That will redirect people to profile_xx.php with xx begin their customer number. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827805 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 Hi thank you,i want to use the login id do i have to define the login id for each user? for example i have this code it if (isset($_POST['Login'])) { $loginUsername=$_POST['Login']; $password=$_POST['Password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "member-profile.php"; $MM_redirectLoginFailed = "login-failed.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_customer, $customer); $LoginRS__query=sprintf("SELECT Login, Password FROM log WHERE Login=%s AND Password=%s", GetSQLValueString($loginUsername, "int"), GetSQLValueString($password, "int")); $LoginRS = mysql_query($LoginRS__query, $customer) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; shud i specify each user login id and password?so that it cud link to each profile? Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827849 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 It would be best to redirect the user to a URL similar to - http://www.mydomain.com/profile.php?id=# where # is the user's id. And if you want flashy URLs, use http://www.mydomain.com/profile/#. That would require a mod_rewrite statement in your .htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827871 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 Hi thank you so much can i get a sample code on how to do this? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827890 Share on other sites More sharing options...
Ken2k7 Posted May 6, 2009 Share Posted May 6, 2009 $id = intval($_GET['id']); if (!empty($id)) { // run some SQL for $id } else { // run some default SQL } Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827894 Share on other sites More sharing options...
whizzykid Posted May 6, 2009 Author Share Posted May 6, 2009 Hi tried inserting it in my code but doesnt work,am a bit confused cud pls use my example to show me where to insert in?sorry thanks. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827901 Share on other sites More sharing options...
premiso Posted May 6, 2009 Share Posted May 6, 2009 I thought only cows chewed cud. Weird. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827903 Share on other sites More sharing options...
Maq Posted May 6, 2009 Share Posted May 6, 2009 I thought only cows chewed cud. Weird. Huh? Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827915 Share on other sites More sharing options...
premiso Posted May 6, 2009 Share Posted May 6, 2009 He was a bit confused [on] cud. I was explaining that I thought only cows chewed cud, to help clarify his confusion. Quote Link to comment https://forums.phpfreaks.com/topic/157112-solved-help-needed/#findComment-827919 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.