Passing data from html to php

everything dear I start in the world of PHP (PHP 5.3.5), my web server is IIS fastCGI on win xp I tried to transfer values ​​from an HTML form to php, but data is not transferred

this is my html file

<html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="fname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> 

and this is my php welcome.php file

 <html> <body> Welcome <?php echo $_POST["fname"]; ?>!<br /> You are <?php echo $_POST["age"]; ?> years old. </body> </html> 

After clicking the "Submit" button, the result was as

Welcome!
You are years old.

but it should be like

Greetings to John!
You are 28 years old.

Could you help me with this.

+6
php
source share
3 answers

when changing IIS in the form: method = "post" to method = "POST" <- UPPERCASE should solve your problem.

Anyway, what about Apache? and the php version is just 5, flat five :) 5.3.5 on IIS for a beginner? it sounds like getting Everest for a night without gloves

+3
source share

This is a fairly standard simple code and looks correct. One thing you can pay attention to is how PHP is configured on your server. Alternatively, try using $ _REQUEST instead of $ _POST on the welcome.php page and see if this all does the same.

Try naming your form as well.

0
source share

Looking at your code, it seems like this is a configuration issue.

Steps to solve this problem:

Firstly, this is the code that displays the page actually welcome.php

Secondly add the following to your php block

 var_dump($_POST); 

Click "Submit" and if it is still displayed

 array ( ) 

if so do

 var_dump($_REQUEST); 

and post the content to your post and show us.

0
source share

All Articles