•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,973 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,819 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 748 | Replies: 8
![]() |
•
•
Join Date: Sep 2005
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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 />
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
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');
////////////////////
//page1///////////
if (*succesful entry)
{
session_start();
$_SESSION('userid')=*your userid;
header("Location:page2.php")
exit();
}
/////////////////////
//page2///////////
session_start();
echo "Welcome,";
echo $_SESSION('user_id');
////////////////////
Last edited by ryan_vietnow : Nov 22nd, 2007 at 2:38 am.
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
•
•
Join Date: Nov 2007
Posts: 183
Reputation:
Rep Power: 2
Solved Threads: 5
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>
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>
•
•
Join Date: Nov 2007
Posts: 183
Reputation:
Rep Power: 2
Solved Threads: 5
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>
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
next_page.php :
<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']; ?>
•
•
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation:
Rep Power: 3
Solved Threads: 68
Hey dude,you forgot your session_start()!
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
http://ryantetek.wordpress.com
<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']; ?>
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- Error message when running ASP login page (ASP)
Other Threads in the PHP Forum
- Previous Thread: How to take backup the database using PHP
- Next Thread: Need help with RSS feeds and importing form data


Linear Mode