Post and Get are not working, please help

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
shinyjoy
Forum Newbie
Posts: 2
Joined: Sat Jul 03, 2010 2:57 am

Post and Get are not working, please help

Post by shinyjoy »

Hi
I have set up php mysql and apache server by installing XAMPP on my pc which is windows xp sp2. And trying to get the following code run but i am not getting the variables through the post or get why, please help me.
Thanks in advance.

my code:
<body>
<H2>Search Results</H2>
<BR>
<FORM ACTION="result.php" METHOD="POST">
Enter name, or part of the name, of the shops you wanted:
<BR>
<INPUT NAME = "name" TYPE = TEXT>
<BR>
<INPUT TYPE= SUBMIT VALUE="Search">
</FORM>
</body>

php page code: result.php
<?
echo $_POST['name'];
?>

I tried every thing like $_REQUEST['name'] and http_Post_var
but nothing is working when i click on a submit, it displaying a blank page why? where is the problem;
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Post and Get are not working, please help

Post by requinix »

The page isn't blank - it just looks that way to you.

Code: Select all

<?php
echo $_POST['name'];
?>
shinyjoy
Forum Newbie
Posts: 2
Joined: Sat Jul 03, 2010 2:57 am

Re: Post and Get are not working, please help

Post by shinyjoy »

actually it's not passing any variable

even if wrote code like this, i couldn't get any thing. see below..

Code: Select all

<?php
$var = $_POST['name'];
echo $var;
?>  
User avatar
rolanddev
Forum Newbie
Posts: 9
Joined: Mon Jul 05, 2010 12:28 pm
Location: Bucharest

Re: Post and Get are not working, please help

Post by rolanddev »

Code: Select all

<body>
<H2>Search Results</H2>
<BR>
<FORM ACTION=<?php echo $_SERVER[PHP_SELF]; ?> METHOD="POST">
Enter name, or part of the name, of the shops you wanted:
<BR>
<INPUT NAME = "name" TYPE = TEXT>
<BR>
<INPUT TYPE= SUBMIT VALUE="Search">
</FORM>
</body>

<?php
echo $_POST["name"];
?>
Use this code, I corrected it!
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Post and Get are not working, please help

Post by internet-solution »

shinyjoy wrote:actually it's not passing any variable

even if wrote code like this, i couldn't get any thing. see below..

Code: Select all

<?php
$var = $_POST['name'];
echo $var;
?>  

Try dumping the $_POST array, and see its content

Code: Select all

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

Other option is to set form method to get and see what is passed in the result.php's url.
---------------
rolanddev wrote:

Code: Select all

<body>
<H2>Search Results</H2>
<BR>
<FORM ACTION=<?php echo $_SERVER[PHP_SELF]; ?> METHOD="POST">

Use this code, I corrected it!
You don't need ACTION=<?php echo $_SERVER[PHP_SELF]; ?> part. if action parameter is ommitted, the form is posted to the file containing the form (i.e. $_SERVER[PHP_SELF]).
Post Reply