PDA

View Full Version : passing value to other page



flagbarton
February 18th, 2007, 01:05 PM
is there another way of passing a variables in another page
because if im using session it'll not work because im using session_register


<?
session_start ();
$txtuser = $_POST['txtlogin'];
$txtpass = $_POST['txtuserpass'];

mysql_connect ("localhost", "root", "") or die ("could not connect to database");
mysql_select_db ("productdb") or die ("Database does not exist");

if ($_POST['submit']) {

$query="SELECT * FROM user where username='$txtuser' and password='$txtpass'";
$result=mysql_query($query);
$ctr=mysql_num_rows($result);

if($ctr>0)
{
session_register("txtlogin");
session_register("txtuserpass");
header('Location: page2.php'); exit;

}
else
{

}
ob_end_flush();
}
?>

what i want is to get the value of $txtuser so i can easily execute query and for the other page can u give some suggestion about it? thnx a lot

bwh2
February 18th, 2007, 01:41 PM
a few things that are really important to note:

you should be storing the md5 or sha1 hash values of passwords, not the actual passwords.
the above script is vulnerable to sql injection because you don't scrub the data at all. you should [d-php]addslashes[/d-php] to any variables that are going into the query
with most php installs (>4.2), register_globals is disabled because it's a security risk. this means that [d-php]session_register[/d-php] won't work.