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.....

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"]; ?>.<br />

OR

Welcome <?php echo $_GET["userid"]; ?>.<br />

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');
////////////////////

hi....how to do tat
this is my html page

<html>
<head></head>
<body>
<form method="post" action="start1.php"> 
<table>
<tr><td> LOGIN PAGE</td></tr>
<tr><td>Name:</td> 
<td><input type="text" name="name1" size="20"></td>
<td></td>
</tr>
 <tr> 
<td>password</td> 
<td><input type="password" name="pwd1" size="20"></td>
<td></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table> 
</form> 
</body> 
</html> 

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'])) 
{ 
mysql_query("SELECT uname FROM login WHERE uname = '$name1' AND pss = '$pwd1'");

print "<script language=\"JavaScript\">";
            print "window.location = 'http://splendor.007ihost.com/carrer-glitter/care.html'";
            print "</script>";
}

}

mysql_close($link);

}
?>
</body>
</html>

hi....how to do tat
this is my html page

<html>
<head></head>
<body>
<form method="post" action="start1.php"> 
<table>
<tr><td> LOGIN PAGE</td></tr>
<tr><td>Name:</td> 
<td><input type="text" name="name1" size="20"></td>
<td></td>
</tr>
 <tr> 
<td>password</td> 
<td><input type="password" name="pwd1" size="20"></td>
<td></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table> 
</form> 
</body> 
</html> 

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'])) 
{ 
mysql_query("SELECT uname FROM login WHERE uname = '$name1' AND pss = '$pwd1'");

print "<script language=\"JavaScript\">";
            print "window.location = 'http://splendor.007ihost.com/carrer-glitter/care.html'";
            print "</script>";
}

}

mysql_close($link);

}
?>
</body>
</html>

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'];
?>

Hey dude,you forgot your session_start()!

Hey dude,you forgot your session_start()!

oooh, yea..
thx 4 reminding..

<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'];
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.