Login | Register | FAQ
Anonymous

problem in passing variables with form

+ Post a reply

4 posts Page 1 of 1


problem in passing variables with form

by ravinder » Thu May 24, 2012 3:26 pm

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...
User avatar

ravinder

  • Posts: 3
  • Joined: Thu May 24, 2012 2:33 pm

Re: problem in passing variables with form

by ravinder » Fri May 25, 2012 7:36 am

plz someone help me regarding this.....
User avatar

ravinder

  • Posts: 3
  • Joined: Thu May 24, 2012 2:33 pm

Re: problem in passing variables with form

by ravinder » Fri May 25, 2012 9:25 am

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...
User avatar

ravinder

  • Posts: 3
  • Joined: Thu May 24, 2012 2:33 pm

Re: problem in passing variables with form

by XainPro » Sat May 26, 2012 12:08 pm

User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1