Is it possible to have both get and post in one page?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ljCharlie
Forum Contributor
Posts: 289
Joined: Wed May 19, 2004 8:23 am

Is it possible to have both get and post in one page?

Post by ljCharlie »

I have a page that I have

Code: Select all

<? echo '<a href=$self?imageID=$picID&sectionID=$sectID class='submenu'>Home Pic</a>';?>
as a link and this by default is a get method. Now on the same page I have a form that I used the post method. On the result page, can I receive both post and get method? The link and the form button also goes to the same page carying different variable values. And according to which value the page passed, the result will display certain data or picture from the MySQL database. But it seemed that I can not retrieve both get and post variable value from the previous page. Is this possible?

ljCharlie
Last edited by ljCharlie on Fri Sep 17, 2004 12:34 pm, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

try

<form action="?foo=bar" method="post">
<input type="text" name="foo2" value="bar2" />
<input type="submit" />
</form>

<?php
echo "post"; print_r($_POST); echo "<br>";
echo "get"; print_r($_GET); echo "<br>";
echo "request"; print_r($_REQUEST); echo "<br>";
?>
Post Reply