Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing data from html to php

Tags:

php

dear all I am a beginer in PHP world (PHP 5.3.5) my web server is IIS fastCGI on win xp I tried to pass values from the HTML form to the php but the data are not passed

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 file welcome.php

<html>
<body>

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

</body>
</html> 

After pressing submit the output was like this

Welcome!
You are years old.

but it should be like this

Welcome John!
You are 28 years old.

Can you please help me with this.

like image 945
ali Avatar asked Feb 28 '11 23:02

ali


People also ask

Can HTML pass information to PHP?

PHP and HTML interact a lot: PHP can generate HTML, and HTML can pass information to PHP.

Which method is used to pass data from HTML to PHP?

PHP $_POST is a PHP super global variable which is used to collect form data after submitting an HTML form with method="post". $_POST is also widely used to pass variables.

How can I pass form data from one page to another by POST in PHP?

Open your web browser and type your localhost address followed by '\form1. php'. Output: It will open your form like this, asked information will be passed to the PHP page linked with the form (action=”form2. php”) with the use of the POST method.


1 Answers

on IIS change in the form: method="post" to method="POST" <-- UPPERCASE should solve your issue.

Anyway what about the apache? and PHP version around just 5, flat five :) 5.3.5 on IIS for the beginner? sounds like to get the Mount Everest by night without gloves

like image 121
Daniel Barucha Avatar answered Oct 20 '22 00:10

Daniel Barucha