selectin data from the database with a session
Moderator: General Moderators
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
well i have a member page where i start the session
like this
then i have a link which should carry the user name and password,
the user enter his/ her info if it match then i takes them to the member page the problem is that i have a like named update so when they click there, i t should take the session that i want to update but in order to update the password and user name has to match and that is the reason i need the session for but it is not carrien the password and user info on the session
like this
Code: Select all
<?php
session_start();
$_SESSION['User_Name'] = $_POST['User_Name'];
$_SESSION['Password'] = $_POST['Password'];
?>
<html>
<head>
<title>Member Session</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>the user enter his/ her info if it match then i takes them to the member page the problem is that i have a like named update so when they click there, i t should take the session that i want to update but in order to update the password and user name has to match and that is the reason i need the session for but it is not carrien the password and user info on the session
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Code: Select all
<?php
if ( !isset($_POST['User_Name'], $_POST['Password']) ) {
echo '<pre>POST: ', print_r($_POST, true), "</pre>\n";
echo '<pre>REQUEST: ', print_r($_REQUEST, true), "</pre>\n";
die('missing POST parameter User_Name or Password');
}
session_start();
$_SESSION['User_Name'] = $_POST['User_Name'];
$_SESSION['Password'] = $_POST['Password'];
?>- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Just for clarification. You have a form where the user enteres its credentialsa script that processes the login and starts a new session if the login is successfuland another script that uses the session datacorrect so far?
Code: Select all
<form action="login.php" method="post">
<input name="username"
<input name="password"Code: Select all
if ( login($_POST['username'], $_POST['password']) ) {
session_start();
session_regenerate_id();
$_SESSION = array('username'=>$_POST['username']);
}Code: Select all
<?php
session_start();
if ( !isset($_SESSION['username'])) {
die('<html><head><meta http-equiv="refresh" content="5; URL=http://lala.la/login.php" /></head>
<body>you need to log-in first</body></html>');
}
?><html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$host = "localhost";
$username = "fgyfhg";Ok i did some changes and i got a little improvement base on what u said. Yes the way u have it set up that is the logic i have.
but here is the change i made
also it is still not carrin the User_Name onto the next page
but is defenely and improvement
this line is displaying this..<pre>_SESSION:<?php print_r($_SESSION); ?></pre>
_SESSION:Array
(
[User_Name] => franklin
)
the problem is that i should also display the password and it is only displaying the user
but here is the change i made
Code: Select all
<?
if ( isset($_POST['User_Name']) && isset ( $_POST['Password']) ) {
session_start();
session_regenerate_id();
$_SESSION = array('User_Name'=>$_POST['User_Name']);
}
?>but is defenely and improvement
this line is displaying this..<pre>_SESSION:<?php print_r($_SESSION); ?></pre>
_SESSION:Array
(
[User_Name] => franklin
)
the problem is that i should also display the password and it is only displaying the user