problem in passing variables with form
4 posts Page 1 of 1
problem in passing variables with form
hello....i am using xampp for php files. i have some problem in the same example as given here.
i have made the handler & html file as given in example as follow;
HTML file:
<html>
<head>
<title> its cool </title>
</head>
<body>
<h1>Enter your name</h1>
<form method="post" action="handler.php">
<input type="text" name="username">
<input type="submit">
</form>
</body>
</html>
PHP(handler) file:
<html>
<head>
<title>Form</title>
</head>
<body>
<?php
echo "<h1>Hello " . $_POST["username"] . "</h1>";
?>
</body>
</html>
and when i put ma name "Ricky" in the submit area then instead of getting "Hello Ricky" it displays "Hello " . $_POST["username"] . ""; ?>" on the screen. i tried ma best to solve this but m failed.plz help me...
Re: problem in passing variables with form
plz someone help me regarding this.....Re: problem in passing variables with form
hello... finally i got solution for my problem. but still i am little bit confused.<html>
<head>
<title>Form</title>
</head>
<body>
<h1>Enter your name</h1>
<form method="post" action="handler.php">
<input type="text" name="username">
<input type="submit">
</form>
</body>
</html>
firstly i saved this as a html file and thats why it was showing that problem that i asked earlier. but now i saved it as a php file and it runs properly. but here you have written "The page that contains the form doesn't need to be a PHP file (but it can be)" but when i saved it as HTML file it shows error. so does that mean we can't save it as a HTML file. plz help me and clear my dought...
Re: problem in passing variables with form
by default in your xampp settings the page which can execute the php code is only .php files but its optional you can configure your xampp server or any other server to display execute the php code either it is in .html or .asp or .phpthat's why its written that its nor necessary that page should be saved in php it could be in any extension or file type i hope you understand what i am talking about
for further reading follow this link
Run php from .html file
- Code: Select all
http://php.about.com/od/advancedphp/p/html_php.htm
Page 1 of 1