954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

login page

hi
i am new to php.i want the login page userid to get displayed in the next page as"welcome userid".....please do tell me the syntax for passing the userid to next page.....

lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 
hi i am new to php.i want the login page userid to get displayed in the next page as"welcome userid".....please do tell me the syntax for passing the userid to next page.....

Depending on the form method used (POST or GET) you can echo the userid variable using the following method:

Welcome <?php echo $_POST["userid"]; ?>.


OR

Welcome <?php echo $_GET["userid"]; ?>.
Shobhit
Newbie Poster
6 posts since Sep 2005
Reputation Points: 7
Solved Threads: 0
Infraction Points: 5
 

use a session variable to get the userid from the previous page. for example:

//page1///////////
if (*succesful entry)
{
session_start();
$_SESSION('userid')=*your userid;
header("Location:page2.php")
exit();
}
/////////////////////

//page2///////////
session_start();
echo "Welcome,";
echo $_SESSION('user_id');
////////////////////

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 



LOGIN PAGEName:


password




lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 



LOGIN PAGEName:


password




lydia21
Junior Poster
183 posts since Nov 2007
Reputation Points: 19
Solved Threads: 5
 

php page

<html>
<head></head>
<body>
<?php
$nam1= $_POST['name1'];
$pwd1= $_POST['pwd1'];
if ($nam1=="admin" && $pwd1=="jesus")
{
	print "<script language=\"JavaScript\">";
	print "window.location = 'http://splendor.007ihost.com/carrer-glitter/user.html'";
	print "</script>";
}
else
{
	$name1= $_POST['name1'];
	$pwd1 = $_POST['pwd1'];
	$hostname = "localhost";
	$username = "splendor_lydia";
	$password = "jesus";
	$dbid = "splendor_samp";
	$link = mysql_connect($hostname, $username, $password);
	mysql_select_db($dbid) or die("unable to connect"); 
	if (isset($_REQUEST['Submit'])) 
	{ 
		$res = mysql_query("SELECT uname FROM login WHERE uname = '$name1' AND pss = '$pwd1'");
		if(mysql_num_rows($res)>=0){
			$_SESSION('userid')=$name1;
			header("Location: next_page.php");
		}
		else echo "login failed..";
	}	
}

mysql_close($link);

}
?>
</body>
</html>


next_page.php :

<?
	echo "Welcome ".$_SESSION['userid'];
?>
black_ip82
Newbie Poster
15 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

Hey dude,you forgot your session_start()!

ryan_vietnow
Posting Pro
578 posts since Aug 2007
Reputation Points: 28
Solved Threads: 71
 
Hey dude,you forgot your session_start()!


oooh, yea..
thx 4 reminding..

black_ip82
Newbie Poster
15 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 
<html>
<head></head>
<body>
<?php
$nam1= $_POST['name1'];
$pwd1= $_POST['pwd1'];
if ($nam1=="admin" && $pwd1=="jesus")
{
	print "<script language=\"JavaScript\">";
	print "window.location = 'http://splendor.007ihost.com/carrer-glitter/user.html'";
	print "</script>";
}
else
{
	$name1= $_POST['name1'];
	$pwd1 = $_POST['pwd1'];
	$hostname = "localhost";
	$username = "splendor_lydia";
	$password = "jesus";
	$dbid = "splendor_samp";
	$link = mysql_connect($hostname, $username, $password);
	mysql_select_db($dbid) or die("unable to connect"); 
	if (isset($_REQUEST['Submit'])) 
	{ 
		$res = mysql_query("SELECT uname FROM login WHERE uname = '$name1' AND pss = '$pwd1'");
		if(mysql_num_rows($res)>=0){
			session_start();
			$_SESSION('userid')=$name1;
			header("Location: next_page.php");
		}
		else echo "login failed..";
	}	
}

mysql_close($link);

}
?>
</body>
</html>


next_page.php :

<?
	session_start();
	echo "Welcome ".$_SESSION['userid'];
?>
black_ip82
Newbie Poster
15 posts since Nov 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You