Current location: Hot Scripts Forums » Programming Languages » PHP » php sessions


php sessions

Reply
  #1 (permalink)  
Old 06-09-03, 07:10 PM
burningr burningr is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Question php sessions

can anybody help me with this problem?
I have this script, it should activate a session if i'm typing in "brukernavn" & "passord" correctly

Quote:
<?php

if($_POST["b"] == "Haavard" && $_POST["p"] == "bo") {

session_start();
session_register('innlogget');

?>

<html>
<head>
<title>Du er logget inn</title>
<link rel="stylesheet" href="../css/basic.css">
</head>
<body>
<hr>
<h1>Du er nå logget inn, <?php echo $_POST["b"]; ?></h1>
<hr>
<h2><a href="medlemsider.php" title="Medlemsider">Trykk Her</a></h2>
</body>
</html>

<?php
}
elseif($_POST["b"] == "Mathias" && $_POST["p"] == "bo") {

session_start();
session_register('innlogget');

?>

<html>
<head>
<title>Du er logget inn</title>
<link rel="stylesheet" href="../css/basic.css">
</head>
<body>
<hr>
<h1>Du er nå logget inn, <?php echo $_POST["b"]; ?></h1>
<hr>
<h2><a href="medlemsider.php" title="Medlemsider">Trykk Her</a></h2>
</body>
</html>

<?php

}




else {

echo "du er ikke logget inn";

}




?>
but i'm not shure it is because when i take it to this script :
Quote:
<?PHP
session_start();
if (!isset($_SESSION['innlogget']) || $_SESSION['innlogget']!= true)
{
header('Location: index.php');
}
?>
it sends me right back to index.php when it's supose to let me trough if i have the right session, can anyone help me pls?
__________________
Thanks for helping Me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-09-03, 07:27 PM
amailer's Avatar
amailer amailer is offline
_-*^# PHP Master #^*-_
 
Join Date: Jun 2003
Location: Canada
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, so this script above, the first one does it have to let both those names:
Mathias and Haavard to login? but if the password is wrong [ i think this is a login script.. ] they get redirected to index.php? or do they get the message: du er ikke logget inn
__________________
Amailer - Spam/Advertise/Have fun
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-09-03, 07:41 PM
burningr burningr is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
they get the message : du er ikke logget inn if they type the wrong password, but then i include script nr.2 in the pages i want to passwd protect end even if i have typed in right username & passwd & the session should have been registerd it sends me right back to index.php
__________________
Thanks for helping Me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-09-03, 07:44 PM
amailer's Avatar
amailer amailer is offline
_-*^# PHP Master #^*-_
 
Join Date: Jun 2003
Location: Canada
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
Ok... i don't know lol but see i made it work, i think.
oh 1 thing, not think lol, the sessions are no use really here but if you want me to make the use i could lol

PHP Code:

<?

if(!isset($b)) {
form();
} else {
if((
$_POST["b"] == "Haavard" && $_POST["p"] == "bo")
OR (
$_POST["b"] == "Mathias" && $_POST["p"] == "bo")) {

session_register("b""p");

?>

<html>
<head>
<title>Du er logget inn</title>
<link rel="stylesheet" href="../css/basic.css">
</head>
<body> 
<hr>
<h1>Du er nå logget inn, <?php echo $_POST["b"]; ?></h1>
<hr>
<h2><a href="medlemsider.php" title="Medlemsider">Trykk Her</a></h2>
<br>
<a href="<? echo "$PHP_SELF?login=logout&check=yes"?>" title="Logout?"> Log out </a>
</body>
</html>

<?php

} else {

//echo "du er ikke logget inn";
echo "Sorry, your username or password was incorrect, please try again.";

 }
}

function 
form() {
global 
$PHP_SELF;

?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
  <tr>
    <td width="100%">
    <p align="center"><font face="Courier"><b>Admin Login:</b></font></td>
  </tr>
</table>
<form method="POST" action="<?=$PHP_SELF?>">
 <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    <tr>
      <td width="32%">&nbsp;</td>
      <td width="11%"><font size="2" face="Courier New">Username:</font></td>
      <td width="60%"><font size="2">
      <input type="text" name="b" size="20" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"> </font></td>
    </tr>
    <tr>
      <td width="32%">&nbsp;</td>
      <td width="11%"><font size="2" face="Courier New">Password:</font></td>
      <td width="60%"><font size="2">
      <input type="password" name="p" size="20" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"></font></td>
    </tr>
  </table>
  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%">
    <tr>
      <td width="43%">&nbsp;</td>
      <td width="11%">
      <input type="submit" value="Submit" name="B3" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"></td>
      <td width="46%">
      <input type="reset" value="Reset" name="B4" style="font-family: Courier New; font-size: 8pt; border: 1px solid #FFFFFF; background-color: #C0C0C0"></td>
    </tr>
  </table>
</form>
<?php
}
if(isset(
$login)) {

function 
logout() {
global 
$ub$p$PHP_SELF$check;

if(
$check == "yes") {
   
session_unregister("p");
   
session_unregister("b");
   
echo 
"<p align=\"center\"><b>You have successfully logged out</b></p>";
echo 
"<p align=\"center\"><a href=\"index.php\" style=\"text-decoration: none\">";
echo 
"<font color=\"#071378\">Please click here to return to index.php.</font></a></p>";
} else {
echo 
"<h2>UNKNOWN URL</h2>";
 }
}




switch (
$login) {
case 
"logout":
logout();
break;
 }
}
?>
__________________
Amailer - Spam/Advertise/Have fun

Last edited by amailer; 06-09-03 at 07:47 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-09-03, 07:51 PM
amailer's Avatar
amailer amailer is offline
_-*^# PHP Master #^*-_
 
Join Date: Jun 2003
Location: Canada
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
Ok, i must tell you im a noob @ php, but i got another login [ i made its very cheap!, its used for amailer lol, Btw amailer is my script ] it uses MYSQL to store the DB, only for 1 user, the admin, im working on makign it for multiple users, but later, i gatta finish my site, if you want to see it, i would be glad to show you
__________________
Amailer - Spam/Advertise/Have fun
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 06-09-03, 08:55 PM
burningr burningr is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
im not shure i understan what you mean, but thats alright
I guess I'll figure it out somehow

Thanks
__________________
Thanks for helping Me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 06-09-03, 08:58 PM
amailer's Avatar
amailer amailer is offline
_-*^# PHP Master #^*-_
 
Join Date: Jun 2003
Location: Canada
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
hehe i was not sure what the script had to do, so i just did what i thought it needed to do lol, but anyway
__________________
Amailer - Spam/Advertise/Have fun
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 06-09-03, 09:00 PM
burningr burningr is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
i need a script that cheks if the session['innlogget'] exists and if it exists, do nothing but if it don't exists send it back to index.php
__________________
Thanks for helping Me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 06-09-03, 09:02 PM
amailer's Avatar
amailer amailer is offline
_-*^# PHP Master #^*-_
 
Join Date: Jun 2003
Location: Canada
Posts: 237
Thanks: 0
Thanked 0 Times in 0 Posts
ohhh! omg LOL! well i jsut thoughyou needed a login!
so, ill just use the login to do what you want it to do, check if the nnlogget exists, and etc etc, hehe sorry i just did not get it at first
__________________
Amailer - Spam/Advertise/Have fun
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 06-09-03, 09:04 PM
burningr burningr is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
I'll just be happy if someone can help me
__________________
Thanks for helping Me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 02:22 PM
Custom PHP Scripts BdSBB Job Offers & Assistance 3 12-07-03 10:49 AM
PHP Triad/Upload form eddyvlad PHP 6 10-07-03 12:17 AM
PHP & sessions, why won't it work? TinnyFusion PHP 1 10-04-03 02:51 PM


All times are GMT -5. The time now is 08:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.