Re: mixture of GET and POST
| From: | tg-php at gryffyndevelopment dot com | Date: | Tue, 03 Apr 2007 14:50:45 +0000 |
| Subject: | Re: mixture of GET and POST | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-251985@lists.php.net to get a copy of this message | ||
As mentioned, this isn't a PHP issue really, except a little bit on the receiving end.
Why not use multiple 'submit' buttons instead of using HREF links?
<input type="submit" name="action" value="Add">
<input type="submit" name="action" value="Edit">
<input type="submit" name="action" value="Remove">
In PHP, you'd just check the value of $_POST['action']
You can also do it with image submit buttons, just have to change the name of each one:
<input type="image" name="action_add" src="images/add.jpg">
<input type="image" name="action_edit" src="images/edit.jpg">
<input type="image" name="action_remove"
src="images/remove.jpg">
In PHP, you'd check for the existance of $_POST['action_add.x'] or
$_POST['action_add.y'] or the corresponding X and Y for edit and remove. It sends the
coordinates of where on the image the user clicked but works just like a submit button, so
you'll get your radio data too.
If you're dead set on using HREF links, then you're going to have to use some Javascript
to probably set some values (possibly in a hidden form element) and submit the form.
-TG
= = = Original message = = =
I have 3 'action' buttons and I am trying to send the $id from the radio
button and the action to the same page so I can either, Add Edit or Remove
the property from the database.
Any ideas how I can get this to work? I can either POST the id's or GET the
action but I can't seem to return both to the browser.
Ta,
R.
--------------------------------------
<form id="form1" name="form1" method="post" action="">
<div id="button_holder">
<a href="?action=add&id=<?=$id;?>">Add Property</a>
<a href="?action=remove">Remove Property</a>
<a href="?action=edit">Edit Property</a>
</div>
<div id="table_header">
</div>
<table id="properties_table">
<?php
$query = "SELECT * FROM properties";
$result= mysql_query($query);
while ($row = @mysql_fetch_array($result, MYSQL_ASSOC))
?>
<tr><td class="col_one"> <input type="radio" name="id"
value="<? echo
$row['property_id'];?>"></td>
<td class="col_two"><?php echo $row['property_id'];?></td>
<td class="col_one"><?php echo $row['address'];?></td>
<td class="col_two"><?php echo $row['postcode'];?></td>
<td class="col_one">~500</td>
<td class="col_two">Live</td>
</tr>
<?
?>
</table>
</form>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.