Ryflex Posted December 8, 2010 Share Posted December 8, 2010 Hi Everyone, I'm trying to make an userlist where I have a button (or better a picture with a hyperlink) which if I click it I will be forwarded to a new page where the user name is send as a $_Post variable. The code below is what I have this far. In some way when I click the send button it always gives the last username in the table in the $_Post variable. Can anyone help me please. Thnx Ryflex <?php require_once('auth.php'); require_once('config.php'); $global_dbh = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die("Could not connect to database"); mysql_select_db(DB_DATABASE, $global_dbh) or die("Could not select database"); $user_query = "SELECT * FROM members"; $user_result = mysql_query($user_query); ?> <form ID="gotoresource" NAME="gotoresource" METHOD="POST" ACTION="resource_compose.php"> <table width="500" border="1" align="center" cellpadding="2" cellspacing="0"> <tr> <td><b>User</b></td> <td><b>Resource</b></td> </tr> <?php while($row = mysql_fetch_assoc($user_result)) { echo "<tr>"; echo "<td>"; echo $row['login']; $user = $row['login']; ?> <input name="User" type="hidden" maxlength="15" id="user" value="<?php echo $user; ?>"/> </td> <td> <input type="submit" name="Submit" value="Send" /> </td> <?php echo "</tr>"; } ?> <html> <head> <title>Userlist</title> <link href="loginmodule.css" rel="stylesheet" type="text/css" /> </head> <body> </body> </html> Link to comment https://forums.phpfreaks.com/topic/221027-userlist-with-button-to-nextpage-with-_post-variable/ Share on other sites More sharing options...
sasa Posted December 8, 2010 Share Posted December 8, 2010 move open an close form tag inside while loop Link to comment https://forums.phpfreaks.com/topic/221027-userlist-with-button-to-nextpage-with-_post-variable/#findComment-1144575 Share on other sites More sharing options...
Ryflex Posted December 9, 2010 Author Share Posted December 9, 2010 Thnx it works like a charm. Ryflex Link to comment https://forums.phpfreaks.com/topic/221027-userlist-with-button-to-nextpage-with-_post-variable/#findComment-1145082 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.