?
Solved

Form Post variales are coming as empty in the submitted PHP page.

Posted on 2004-09-23
6
Medium Priority
?
240 Views
Last Modified: 2011-09-20
Hi!

I have a problem getting form/post variables from HTML page to PHP page. For example:

in HTML page I am writing :

<form action="testres.php" method="POST">
      <input type="text" name="samplevar"><br>
      <input type="submit"><br>
</form>


In testres.php I am writing

echo $_POST['samplevar'];

samplevar variable is getting as null in the above PHP page ....I checked the settings in php.ini file and register_globals = On
always_populate_raw_post_data = Off.....I don't know how to resolve this issue... .I am running PHP V 4.3.8 on Linux Apache server.

Can anybody please help me fixing this issue?

Thanks in advance.


 
0
Comment
Question by:prsupriya
5 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 12131492
As you use $_POST['samplevar'] it actually doesn't matter wether register_globals is on. You propably should turn it off again because of the security issues.

What is the value of $_SERVER['REQUEST_METHOD'] and what happens when you var_export some stuff:

echo '<pre>'.var_export(array('POST' => $_POST, 'GET' => $_GET, 'REQUEST' => $_REQUEST),true).'</pre>';

regards

-r-
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12131663
A simple test to try:

<?php
if (count($_POST) > 0) {
 echo "Post array contains: <br>";
 print_r($_POST);
}
else {
 echo "The post array is empty";
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 <input type="text" name="test" value="test value"><br>
 <input type="submit" value="submit">
</form>

I would also advise turing globals off immediately.

Instead of $_POST you can also try $HTTP_POST_VARS although in your version of php there is no reason why $_POST shouldn't work.
0
 
LVL 1

Expert Comment

by:Codeit1978
ID: 12199464
At the top of your code when the postback happends type in print_r($_REQUEST);  That will print out all of the $_GET $_POST vars that are being passed.

Hope that helped.
0
 
LVL 5

Author Comment

by:prsupriya
ID: 12219517
Hi! All,

Thank you so much for all your replies. The problem was with the my Plesk control Panel "View Site" issue. I could figure out and it's fine now.

Regards,
S:

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12522457
PAQed, with points refunded (125)

modulo
Community Support Moderator
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month16 days, 12 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question