php how to pass value

abhi4u

New Member
I have created admin page where admin see all the users username and i have made the username list as link to process the details of the user but when i click it should pass the username to the processing page. the code -

members list- members_detail.php
<?php
if(!mysql_connect("localhost","root","admin"))
{
echo "<h2>".$TEXT['product-error to connect']."</h2>";
die();
}
echo "<h5>Users:-</h5><br>";
$link = mysql_connect("localhost", "root", "admin");
mysql_select_db("jc214330", $link);
$i=0;
$sql = mysql_query("SELECT * FROM users");
while($members = mysql_fetch_array($sql))
{
echo "<p><a href=\"members_process.php\">".$members[username] ."</a></p>";
echo "<p>Name - ".$members[first_name] ." ".$members[last_name] ."<br><br><br></p>";
}

?>


members process to get full details, edit and delete users - members_process.php

<?php
$username = $_REQUEST['$username'];
if(!mysql_connect("localhost","root","admin"))
{
echo "<h2>".$TEXT['product-error to connect']."</h2>";
die();
}
echo "<h5>Users:-</h5><br>";
$link = mysql_connect("localhost", "root", "admin");
mysql_select_db("jc214330", $link);
$sql = mysql_query("SELECT * FROM users where username = 'username'");
while($membersdtl = mysql_fetch_array($sql))
{
echo "<p>Name - ".$membersdtl[first_name] ." ".$membersdtl[last_name] ."<br><br><br></p>";
}
?>


how do i pass $username from members_detail.php to members_process.php
 

paragkale

New Member
hiiiii
In PHP u can pass value in two ways or we can say 2 methods POST and GET

1)POST method is simply declare post method in form tag <form method="post">
<input value=""> through this u can pass
2) by passing query string

ex->

<a href="pagename.php?userid=".<?=$usernameid?>><?=$username?></a>

through u can pass the id

i hope this 2 method help u

thanks
 

bozy12v

New Member
one link should be
echo "members_process.php?username=$members[username]";

and in members_process.php tou should get the username like this

$username=$_GET['username'];
 
Top