Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

sessions problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
superman
Smarty Rookie


Joined: 08 Jul 2003
Posts: 11

PostPosted: Wed Jul 23, 2003 11:56 am    Post subject: sessions problem Reply with quote

i use this code to verify the username & password, but how to pass the username in every pages such as 'welcome andy' if andy login and 'welcome jack' if jack login.
this script is unsecure, what script should i include in every pages so when i enter http://localhost/payroll.php it will ask me to login first.


<?
session_start();
if ($username && $password)
{
$Connect = mysql_connect("localhost", "root", "");
mysql_select_db("mw");
$result = mysql_query("select * from account where username='$username' and password='$password'");

if (mysql_num_rows($result) > 0)
{
$valid_user = $username;
session_register("valid_user");
}
}
?>


<?
if (session_is_registered("valid_user"))
{

$_SESSION['valid_user'] = $_POST['username'];
echo "<center><br><br>You are logged in as: $valid_user <br><br>";
echo "<center><a href=\"logout.php\">Log out</a><br>";
}
else
{
if (isset($username))
{
echo "<center>Could not log you in";
}
else
{
echo "<center>You are not logged in.<br>";
}
echo "<form method=post action=\"login.php\">";
echo "<center><table>";
echo "<tr><td>Username:</td>";
echo "<td><input type=text name=username></td></tr>";
echo "<tr><td>Password:</td>";
echo "<td><input type=password name=password></td></tr>";
echo "<tr><td colspan=2 align=center>";
echo "<input type=submit value=\"Log In\"></td></tr>";
echo "</table></form>";
}
?>
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Wed Jul 23, 2003 12:29 pm    Post subject: Reply with quote

this forum is around the Smarty template engine. try the php-general mailinglist or some php-related forum.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP