PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Mon Jul 19, 2004 2:15 am
How can I bring the value of $ID to another page??
Code: Select all
<?php
<?
include("database.php");
function get_user()
{
$user = $_POST['user'];
$query = "SELECT * FROM employee WHERE username = '$user'";
$result = mysql_query($query);
$row_array = mysql_fetch_array($result);
return $row_array;
}
?><font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif"><?
$row_array=get_user();
$ID=$row_array['username'];
$Pass=$row_array['password'];
$Access=$row_array['AccType'];
if(!$_POST['user'])
{
echo"<br><br><br><center><h3>ERROR: No username entered.<h3></center>";
?> <form action="viewuser.php" method="post">
<center><input type="submit" value="BACK" name="back"></center></form>
<? exit();
}
if(!$row_array)
{
echo"<br><br><br><center><h3>ERROR: Username doesn't exist.<h3></center>";
?> <form action="viewuser.php" method="post">
<center><input type="submit" value="BACK" name="back"></center></form>
<? exit();
}
else
{
echo"<center>Below is the <b><i>$ID</b></i> information:";
?>
<hr>
<font color="#671247" size="3" face="Verdana, Arial, Helvetica, sans-serif">
<table border="0" cellspacing="4" cellpadding="0">
<tr><td><b>Password:</td><td><input type="text" name="password" value="<? echo $Pass; ?>" ></td></tr>
<tr><td><b>Acces Type:</td><td><input type="text" name="AccType" value="<? echo $Access; ?>" ></td></tr>
?>
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Mon Jul 19, 2004 2:36 am
Help me plizz.. What shoul I call at other page??
Skittlewidth
Forum Contributor
Posts: 389 Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK
Post
by Skittlewidth » Mon Jul 19, 2004 4:04 am
create a hidden field in your form:
Code: Select all
<input type='hidden' name='id' value='<?php echo $id;?>' />
After your form is submitted you can access the id variable on the next page with $_POST['id'] or $id if register globals is on.
(The next page is the page you name in your form "action" parameter)
g3ckO
Forum Contributor
Posts: 117 Joined: Mon Jul 12, 2004 2:57 am
Location: Malaysia
Contact:
Post
by g3ckO » Mon Jul 19, 2004 4:10 am
tq.. I forgot about the hidden field
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Mon Jul 19, 2004 5:06 am
Code: Select all
#not something nesecesary but.. saves you from typing things 2 times.
$user = $_POST['user'];
$query = "SELECT * FROM employee WHERE username = '$user'";
#can easely be this
$query = "SELECT * FROM employee WHERE username = '".$_POST['user']."'";