skatermike21988 Posted March 19, 2006 Share Posted March 19, 2006 i was wondering about something.i have a login script and ir runs on a frames page with a header and a contents.i am wondering if i can use an if statement to refresh the page when a user logs in/logs out.reson being that i want it to tell them if they are loggeg in at the header.this is my code:<? SESSION_START(); header("Cache-control:private"); INCLUDE('functions.php'); echo("<table align='center'> <form action='login.php?act=start' method='POST'> <tr><td>Username:</td><td><input type='text' name='username'></td></tr> <tr><td>Password:</td><td><input type='password' name='password'></td></tr> <tr><td><input type='submit' name='submit' value='Login'></td> </form> <td>Or Just Sign Up <a href=\"register.php\">Now!!!</a></td></tr></table>"); if($_GET['act'] == "start") { if(!$_POST['username'] || !$_POST['password']) { echo("<a href=\"javascript:history.go(-1)\">Go back and fill out all fields, correctly!"); } else { $passwordshow=$_POST['password']; $username=$_POST['username']; $password=$_POST['password']; $check=mysql_query("SELECT * FROM `users` WHERE username = '$username' && password = '$password'")or die(mysql_error()); $CNumb=mysql_num_rows($check); if($CNumb == '0') { echo("<center>The username/password was invalid! Please Fix The Errors And Try Again and try again!</center>"); } else { session_register('$username'); session_register('$password'); $_SESSION['username'] = $username; $_SESSION['password'] = $password; echo " <script language='javascript'> window.location = \"members1.php\"; </script>"; } } } ?> <body bgcolor="#000000" text="#FFFFFF"><center>LongSlong Productions Is Affiliated With LickMy9 And FishBoard Productions. All Rights Reserved Copyright 2006-2007</body>i am wonderin if i could have a:if ($submit)refresh here orhave it go in this code part here:else { session_register('$username'); session_register('$password'); $_SESSION['username'] = $username; $_SESSION['password'] = $password; echo " <script language='javascript'> window.location = \"members1.php\"; </script>Refresh's Here"; } } Please Help.Thanks In Advance Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/ Share on other sites More sharing options...
shortj75 Posted March 19, 2006 Share Posted March 19, 2006 yes you can do that but this code may work a little better[code]if(isset($_POST['submit'])){header("Location: members1.php");//or you can place your javascript here but his will do the same thing} [/code]i hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/#findComment-18763 Share on other sites More sharing options...
skatermike21988 Posted March 19, 2006 Author Share Posted March 19, 2006 [!--quoteo(post=356368:date=Mar 19 2006, 03:54 AM:name=shortj75)--][div class=\'quotetop\']QUOTE(shortj75 @ Mar 19 2006, 03:54 AM) [snapback]356368[/snapback][/div][div class=\'quotemain\'][!--quotec--]yes you can do that but this code may work a little better[code]if(isset($_POST['submit'])){header("Location: members1.php");//or you can place your javascript here but his will do the same thing} [/code]i hope this helps[/quote]how can i also make this refresh the page at the same time?also another questionbut now i am getting this error in my header:Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/mike/public_html/functions.php:11) in /home/mike/public_html/header.php on line 9Warning: Cannot modify header information - headers already sent by (output started at /home/mike/public_html/functions.php:11) in /home/mike/public_html/header.php on line 10this is the code in my header:[code]<?INCLUDE('functions.php'); //Main page for the login.//you must login to be able to view this pageSESSION_START(); header("Cache-control:private"); INCLUDE('functions.php'); if($_SESSION['username'] && $_SESSION['password']) { $username=$_SESSION['username']; $sql_check = mysql_query("SELECT datejoined FROM users WHERE username='$username'"); $sql_check_num = mysql_num_rows($sql_check); while($a_row = mysql_fetch_array($sql_check))$datejoined= $a_row["datejoined"];echo "Welcome Back $username!..<br>";echo "Member Since: $datejoined<br>";echo "<A href='logout.php?sid=".$sid."' target='main'>Log Out</a>";echo "<a href='/images.php' target='main'>Update Account Information</a>";} else { echo " You Are Not Logged In<br><a href='/login.php' target='main'>Login</a>";}$sql = @mysql_query("SELECT userid FROM users") or die (mysql_error());while($a_row = mysql_fetch_array($sql))$currentmembers= $a_row["userid"];echo "There Are Currently $currentmembers Registered Members<br>";$sql = @mysql_query("SELECT username FROM users") or die (mysql_error());while($a_row = mysql_fetch_array($sql))$latestuser= $a_row["username"];echo "Latest Member: $latestuser";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/#findComment-18776 Share on other sites More sharing options...
wildteen88 Posted March 19, 2006 Share Posted March 19, 2006 [code]if(isset($_POST['submit'])){header("Location: members1.php");//or you can place your javascript here but his will do the same thing} [/code]If you use the above code then it will redirect the user straight away to members1.php andy code after the header() fucntion will not be processed so you will not be able to make the page refresh! Why do you want the page to refresh? Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/#findComment-18778 Share on other sites More sharing options...
skatermike21988 Posted March 19, 2006 Author Share Posted March 19, 2006 [!--quoteo(post=356384:date=Mar 19 2006, 05:53 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Mar 19 2006, 05:53 AM) [snapback]356384[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]if(isset($_POST['submit'])){header("Location: members1.php");//or you can place your javascript here but his will do the same thing} [/code]If you use the above code then it will redirect the user straight away to members1.php andy code after the header() fucntion will not be processed so you will not be able to make the page refresh! Why do you want the page to refresh?[/quote]i am wanting the page to refresh beacuase i have a frame page and when the user is not logged in the header will display that they are not logged in. and if they are it will display that they are logged in. but when working with frame pages the header (top page) never refresh's as only the main page (inside) changes. I would like to have it all refresh when they log in or log out. Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/#findComment-18781 Share on other sites More sharing options...
skatermike21988 Posted March 19, 2006 Author Share Posted March 19, 2006 if this will help here is the link to my site [a href=\"http://www.longslongproductions.com\" target=\"_blank\"]http://www.longslongproductions.com[/a] don't mind the name as it is only a comedy site Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/#findComment-18783 Share on other sites More sharing options...
skatermike21988 Posted March 19, 2006 Author Share Posted March 19, 2006 this post is closed problem not resolved Quote Link to comment https://forums.phpfreaks.com/topic/5276-if-statements-for-submit/#findComment-18786 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.