0

Hello experts!
I have login page, which take email ID n password. The user(which are already member)enter ID n password, after hitting submit button, welcome page showing there emailID should open. e.g Welcome pooja.j@xyz.com.

My prob. is that welcome page opens, but it shows only Welcome instead of welcome pooja.j@xyz.com... plz, help me to display emailID also..Here are my attachments.

Attachments
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fail</title>
</head>

<body>
<h1 align="center">Ooops! Bad email or password! Try again</h1>
</body>
</html>
<?php
	$con=mysql_connect("localhost","root","");
$db=mysql_select_db('webpage');
session_start();
	
	$submit=$_POST['submit']; 
	$email=$_POST['email'];
	$password=$_POST['password'];
	
	if(!empty ($submit))
	
	{	
		$query="select * from user where (email='$email' and password='$password')";
		$rs=mysql_query($query); 
		$row=mysql_fetch_array($rs);
		$count=mysql_num_rows($rs); 
		
		if($count > 0)
		{
			//session_start();
			  // $_SESSION['email'] = $email; 
			   header("Location:welcome.php");  
		} 
		else
		{
			 header("Location:fail.php");
				 
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login4</title>
</head>

<body>
   	  		  <form id="loginform" name="loginform" method="post" action="index.php">
   	  		    Email ID
   	  		          <input name="email" type="text" id="email" />
                      Password<input name="password" type="password" id="password" />
                                        <input name="submit" type="submit" id="submit" value="submit" />
                    
              </form>
              </body>
</html>
<?php
session_start();
$_SESSION['email'] = $_POST['email'];

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome page</title>
</head>

<body>
<h1 align="center">Welcome <?php echo $_SESSION['email']; ?></h1>
</body>
</html>
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by urtrivedi
0

in your index.php, change line no 14, pass connection resource and then try.


$rs=mysql_query($query, $con);

Edited by urtrivedi: n/a

0

I've edited it and uploaded one for you.
you may need a restrict access server behaviour.
i would also recommend attaching your mysql in an include once so it adds security.
you do not need to make your $_SESSION = $_POST
as that is reseting your session email to NULL as you are not posting. view my forum on displaying usernames. as it is basically the same idea

Attachments
<?php require_once('index.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$email = $_SESSION['email'];
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome page</title>
</head>

<body>
<h1 align="center">Welcome <?php echo $email; ?></h1>
</body>
</html>
0

Thanks....its working...now i m trying next step, that displaying private data of that particular login user...let's see what happened...thanks for help...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.