php form handling problem

i have problem in retrieveing file.

Page 1 of 1

7 Replies - 1288 Views - Last Post: 02 December 2009 - 10:26 AM Rate Topic: -----

#1 jaanvi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 20-July 09

php form handling problem

Post icon  Posted 27 July 2009 - 12:10 AM

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


<html>
<body>
welcome <?php echo $_post["name"]; ?>.<br/>
you r <?php echo $_post["age"]; ?>years old.
</body>
</html>

i have save second file with name welcome.php but on running first file it is giving me the error :blankwelcome.php though i have stored these two files in same folder.
pls help me where i am lagging.

Is This A Good Question/Topic? 0
  • +

Replies To: php form handling problem

#2 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: php form handling problem

Posted 27 July 2009 - 12:19 AM

use isset function:
if(isset($_POST['name']) && isset($_POST['age'])){
          echo "Welcome ".$_POST['name'];
          echo "You are ".$_POST['age']." years old";
}

Was This Post Helpful? 0
  • +
  • -

#3 abhishek25  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 25-February 09

Re: php form handling problem

Posted 01 December 2009 - 04:51 AM

Me too having the same problem . Using isset() makes the program do not show any error. but still the program do not works fine because the posted values are not shown.The php file is not processing the forms variable or they are not receiving the form values at all .

Any help will be greatly appreciated .
Was This Post Helpful? 0
  • +
  • -

#4 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: php form handling problem

Posted 01 December 2009 - 10:42 PM

Could you please past some of your code? :)
Was This Post Helpful? 0
  • +
  • -

#5 abhishek25  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 25-February 09

Re: php form handling problem

Posted 01 December 2009 - 11:34 PM

View Postnoorahmad, on 1 Dec, 2009 - 09:42 PM, said:

Could you please past some of your code? :)




The code is same as above
Was This Post Helpful? 0
  • +
  • -

#6 codewalkz  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 6
  • Joined: 01-December 09

Re: php form handling problem

Posted 02 December 2009 - 05:35 AM

I think you should name the "SUBMIT" button as submit. Something like:

<input type="submit" name="submit" value="Submit">


And then use isset:

if(isset($_POST['submit']){
		  echo "Welcome ".$_POST['name'];
		  echo "You are ".$_POST['age']." years old";
}


Hope it works.

This post has been edited by codewalkz: 02 December 2009 - 05:36 AM

Was This Post Helpful? 0
  • +
  • -

#7 hadi_php  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 10
  • View blog
  • Posts: 382
  • Joined: 23-August 08

Re: php form handling problem

Posted 02 December 2009 - 08:17 AM

 <form action="<?php $PHP_SELF ?>" method="post">
	Name : <input type="text" name="name"  />
	Age : <input type="text" name="age"  />
	<input type="submit" name="submit" value="go" />
</form>

<?php
echo "Your name is - ".$_POST['name'];
echo " and you are ".$_POST['age']." years old";

if(isset($_POST['submit']))
	{
		echo "<hr />-------------Submit validation------------------<br />";
		echo "Your name is - ".$_POST['name'];
		echo " and you are ".$_POST['age']." years old";
	}
?>


save it as php and run hope this is enough to understand :D ;)
Was This Post Helpful? 0
  • +
  • -

#8 s-grind  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 86
  • Joined: 20-November 09

Re: php form handling problem

Posted 02 December 2009 - 10:26 AM

View Postjaanvi, on 26 Jul, 2009 - 11:10 PM, said:

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


<html>
<body>
welcome <?php echo $_post["name"]; ?>.<br/>
you r <?php echo $_post["age"]; ?>years old.
</body>
</html>

i have save second file with name welcome.php but on running first file it is giving me the error :blankwelcome.php though i have stored these two files in same folder.
pls help me where i am lagging.


The reason your code isn't working is because you use $_post.
That won't work.
It's case sensitive; use for this kind of variable $_POST and your code is working like it should.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1