Jump to content

if statements for submit


skatermike21988

Recommended Posts

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

or

have 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
Link to comment
Share on other sites

[!--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 question
but 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 9

Warning: 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 10

this is the code in my header:
[code]
<?
INCLUDE('functions.php');

  
//Main page for the login.
//you must login to be able to view this page


SESSION_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]
Link to comment
Share on other sites

[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?
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.