TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   trying to post from one page to another and wont work (http://www.talkphp.com/general/2723-trying-post-one-page-another-wont-work.html)

sarmenhb 04-28-2008 06:55 AM

trying to post from one page to another and wont work
 
i have a table that displays the existing user names

Code:

<?php

include("config.php");


?>


<html>
<head>
<title>
</title>
<link href="stylesheets/style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<form method="post" action="update_user.php">
<a href="adduser.php">Add User</a> <br>
<br>
<br>
<br>
<br>
<br>

<table>
<thead>
<tr>
<th>&nbsp;</th>
<th>Last Name</th>
<th>First Name</th>
<th>User Name</th>
<th>Level</th>
<th>Active</th>
</tr>
</thead>

<tbody>

<?php

#================================
#        populate all users names
#================================
$user_sql = mysql_query("select * from tbl_users order by id");

while($row = mysql_fetch_assoc($user_sql)) {
echo "<tr>";
echo "<td><input type=\"radio\" name=\"rowid\" value=\"{$row['id']}\"></td>";
echo "<td>{$row['lname']}</td>";
echo "<td>{$row['fname']}</td>";
echo "<td>{$row['username']}</td>";
echo "<td>{$row['level']}</td>";
echo "<td>{$row['active']}</td>";
echo "</tr>";
}
?>

</tbody>
</table>
<input type="submit" name="btn_edit" value="Edit"> &nbsp; <input type="submit" name="btn_delete" value="Delete"><br>
<input type="hidden" name="txt_id" value="<?php echo $_POST['rowid']; ?>">


</form>
</body>
</html>

so when i make a selection and click on edit the next page doesnt show anything, how do request the post on the other page? i mean $_POST['value'] should do the trick but its not working what am i doing wrong??

here is the code for the other page

Code:

<?php

include("config.php");

$row_id = $_POST['rowid'];


$sql = mysql_query("select * from tbl_users where id = '$row_id'");

?>







<html>
<head>
<title>
</title>
<link href="stylesheets/style.css" type="text/css" rel="stylesheet" />
</head>
<body>


<p>Last Name: </p>
<?php

while($row = mysql_fetch_assoc($sql)) {
?>
<p><input type="text" name="txt_lname" value="<?php echo $row['lname']; ?>"></p>

<p>First Name</p>
<p><input type="text" name="txt_fname" value="<?php echo $row['lname']; ?>"></p>
<p>User Name</p>
<p><input type="text" name="txt_username" value="<?php echo $row['lname']; ?>"></p>
<p>Level: <select><option>will do later</option></select></p>
<p>Active: <input type="checkbox" name="chk_active" <?php if($row['active'] == TRUE) { echo "checked"; } else { } ?> ></p>
<?php } ?>

<p><input type="submit" name="submit" value="Save"></p>


</body>
</html>


delayedinsanity 04-28-2008 07:19 AM

Try adding this to the top of your page, and see if it's receiving any information from the form at all;

PHP Code:

echo '<pre>';
print_r($_POST);
echo 
'</pre>'


sarmenhb 04-28-2008 01:53 PM

thanks, i found that in my code the forms method was GET and in this forum i put the method to POST witout changing my code.


All times are GMT. The time now is 09:20 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0