TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-28-2008, 06:55 AM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default 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>
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 04-28-2008, 07:19 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

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>'
delayedinsanity is offline  
Reply With Quote
Old 04-28-2008, 01:53 PM   #3 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default

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.
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:30 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design