User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Help login page

  #1  
Nov 22nd, 2007
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.....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2005
Posts: 2
Reputation: Shobhit is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Shobhit Shobhit is offline Offline
Newbie Poster

Solution Re: login page

  #2  
Nov 22nd, 2007
Originally Posted by lydia21 View Post
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 />
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: login page

  #3  
Nov 22nd, 2007
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');
////////////////////
Last edited by ryan_vietnow : Nov 22nd, 2007 at 2:38 am.
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: login page

  #4  
Nov 22nd, 2007
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>
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: login page

  #5  
Nov 22nd, 2007
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>
Reply With Quote  
Join Date: Nov 2007
Location: Indonesia
Posts: 15
Reputation: black_ip82 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
black_ip82's Avatar
black_ip82 black_ip82 is offline Offline
Newbie Poster

Solution Re: login page

  #6  
Nov 22nd, 2007
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'];
?>
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: login page

  #7  
Nov 22nd, 2007
Hey dude,you forgot your session_start()!
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Nov 2007
Location: Indonesia
Posts: 15
Reputation: black_ip82 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
black_ip82's Avatar
black_ip82 black_ip82 is offline Offline
Newbie Poster

Re: login page

  #8  
Nov 22nd, 2007
Originally Posted by ryan_vietnow View Post
Hey dude,you forgot your session_start()!

oooh, yea..
thx 4 reminding..
Reply With Quote  
Join Date: Nov 2007
Location: Indonesia
Posts: 15
Reputation: black_ip82 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
black_ip82's Avatar
black_ip82 black_ip82 is offline Offline
Newbie Poster

Re: login page

  #9  
Nov 22nd, 2007
<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'];
?>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC