Jump to content



Recommended Posts

hi, I have a page where you login to be getting to the account page.now I want to be able to use the

echo "Welcome:". $_SESSION['login'];

on the "order site. this is how my scripts looks like now:login.php

<body><form name="form1" action="checklogin.php" method="post"><span class="style1">Login: </span><input name="login" type="text" id="login"> <br><span class="style1">Password:</span><input name="pass" type="password" id="pass"> <br><input type="submit" name="Submit" value="Login"></form><br><br><span class="style1"><a href="createacc.php">Create Account</a></span></body>


<?phpsession_start();$_SESSION['login']=1;			  <------------------------------------------------------------------|||||||||||||||||||||||||||||||||||||||||||ob_start();$host="localhost"; // Host name$username="*******"; // Mysql username$password="***********"; // Mysql password$db_name="**********"; // Database name$tbl_name="**********"; // Table name// Connect to server and select databse.mysql_connect("$host", "$username", "$password")or die("cannot connect");mysql_select_db("$db_name")or die("cannot select DB");// Define $myusername and $mypassword$myusername=$_POST['login'];$mypassword=$_POST['pass'];$sql="SELECT * FROM $tbl_name WHERE login='$myusername' and pass='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername, $mypassword and redirect to file "login_success.php"session_register("login");session_register("pass");header("location: account.php");}else {echo "Wrong Username or Password";}ob_end_flush();?>


<html><head><title>Order</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!--yada yada--></style></head><body><?phpecho "Welcome:". $_SESSION['login'];		  <------------------------------------------------------------------|||||||||||||||||||||if (isset($_REQUEST['email']))bla bla...yada yada</body></html>

I made arrows to show you what I mean

Link to comment
Share on other sites

didnt work but it changed something :)gives me

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/planetzi/public_html/leveling/account.php:5) in /home/planetzi/public_html/leveling/account.php on line 50Welcome:1

and the "Welcome:1" should be "Welcome: Gatsu"and line 50 is:session_start();

Link to comment
Share on other sites

Is session_start() written in accound.php twice?And another thing:It says "Welcome: 1" because you wrote $_SESSION['login']=1 in your other file.So in checklogin.php you do this:Where it says if($count == 1) you can put

if($count==1) {$_SESSION['login']=$myusername;...

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...