GsXtAsY Posted July 31, 2008 Share Posted July 31, 2008 I just installed the PHP Login script and what I am wanting to do is based on the username of the person logging in it will automatically add the username to the end of the redirect page...for example... if someones username is Goofy then i want the page to redirect to http://www.website.com/index.php?name=goofy How would I go about doing this...I have it setup right now as on the redirect go to http://www.website.com/index.php?name=$username but it will not carry it over to that page it just goes to http://www.website.com/index.php?name= and then nothing for the username Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/ Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 can you post your code? Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604647 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 Here is the login.php file...as you see "username" is what I want to save in the session and autofill the end of the url as i posted in my first post...I am guessing this is the file you will need. <?php require_once ( 'settings.php' ); if ( array_key_exists ( '_submit_check', $_POST ) ) { if ( $_POST['username'] != '' && $_POST['password'] != '' ) { $query = 'SELECT ID, Username, Active, Password FROM ' . DBPREFIX . 'users WHERE Username = ' . $db->qstr ( $_POST['username'] ) . ' AND Password = ' . $db->qstr ( md5 ( $_POST['password'] ) ); if ( $db->RecordCount ( $query ) == 1 ) { $row = $db->getRow ( $query ); if ( $row->Active == 1 ) { set_login_sessions ( $row->ID, $row->Password, ( $_POST['remember'] ) ? TRUE : FALSE ); header ( "Location: " . REDIRECT_AFTER_LOGIN ); } elseif ( $row->Active == 0 ) { $error = 'Your membership was not activated. Please open the email that we sent and click on the activation link.'; } elseif ( $row->Active == 2 ) { $error = 'You are suspended!'; } } else { $error = 'Login failed!'; } } else { $error = 'Please use both your username and password to access your account'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>NationLink VIP</title> <link href="css/styles.css" rel="stylesheet" type="text/css" /> <!-- ____ __ /\ _`\ __ /\ \__ _ __ ___\ \,\L\_\ ___ _ __ /\_\ _____\ \ ,_\ ____ /\`'__\/ __`\/_\__ \ /'___\/\`'__\/\ \/\ '__`\ \ \/ /',__\ \ \ \//\ \L\ \/\ \L\ \/\ \__/\ \ \/ \ \ \ \ \L\ \ \ \_/\__, `\ \ \_\ \____/\ `\____\ \____\ \_\ \ \_\ \ ,__/\ \__\/\____/ \/_/ \/___/ \/_____/\/____/ \/_/ \/_/\ \ \/ \/__/\/___/ \ \_\ \/_/ Making your world easy --> </head> <body> <div id="log"> <?php if ( isset( $error ) ) { echo ' <p class="error">' . $error . '</p>' . "\n";}?> </div> <div id="container" style="width:230px;"> <form class="form" action="<?=$_SERVER['PHP_SELF']?>" method="post"> <input type="hidden" name="_submit_check" value="1"/> <div style="margin-top:12px; margin-bottom:10px"> <img src="images/username.gif" alt="username" border="0" /> <input class="input" type="text" name="username" id="username" size="25" maxlength="40" value="" /> </div> <div style="margin-bottom:6px"> <img src="images/password.gif" alt="password" border="0" /> <input class="input" type="password" name="password" id="password" size="25" maxlength="32" /> </div> <?php if ( ALLOW_REMEMBER_ME ):?> <div style="margin-bottom:6px"> <input type="checkbox" name="remember" id="remember" /> <label for="remember">Remember me</label> </div> <?php endif;?> <input type="image" name="Login" value="Login" class="submit-btn" src="images/btn.gif" alt="submit" title="submit" /> <br class="clear" /> <a href="register.php">Register</a> / <a href="forgot_password.php">Password recovery?</a> </form> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604887 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 I just added $smarty->assign('username', $username); into my index.php file also Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604890 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 I don't see where you are doing this as mentioned: http://www.website.com/index.php?name=$username Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604907 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 define ( "REDIRECT_AFTER_LOGIN", "http://www.nationlinkvip.com/index.php?name=$username" ); that is in the settings file...but i dont know how to carry over the username to put it in the url...even after adding $smarty->assign('username', $username); to the index.php file it still doesnt do anything...i also added session_start(); on the login.php and the index.php files Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604910 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 Take the $username out of define such as define ( "REDIRECT_AFTER_LOGIN", "http://www.nationlinkvip.com/index.php?name=" ); Then try this: header ( "Location: " . REDIRECT_AFTER_LOGIN . $username); Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604917 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 where do i need to be putting that code you just added? to the index.php file? Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604930 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 I put it in the index page and I got a 404 error The requested URL /REDIRECT_AFTER_LOGIN was not found on this server. Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604933 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 in the login.php file where you are doing a redirect: header ( "Location: " . REDIRECT_AFTER_LOGIN . $username); Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604935 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 still nothing...im so lost on why this will not fill in the = part...any more ideas? Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604945 Share on other sites More sharing options...
GsXtAsY Posted July 31, 2008 Author Share Posted July 31, 2008 i just went ahead and put $_POST['username'] in replacement of $username and that worked!! Thank you for your help! Link to comment https://forums.phpfreaks.com/topic/117561-solved-php-login-help/#findComment-604946 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.