Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,172 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,245 people online right now. Registration is fast and FREE... Join Now!




form action problem

 
Reply to this topicStart new topic

form action problem

hadi_php
30 Aug, 2008 - 10:43 PM
Post #1

New D.I.C Head
*

Joined: 23 Aug, 2008
Posts: 22

CODE
<html>
<body>

<form action = "t2.php" method = "post">

Name : <Input type = "text" name = "first_name" />

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

</form>
</body>
</html>


And in t2.php

CODE
<html>
<body>
<?php
echo "Your Name is $first_name";
?>
</body>
</html>


Output will be what i worte is 1st form text box.

It runs on PHPtried And it outputs what i type in text box.........

But it is not running in XAMPP1.6.7! . Any 1 Plz help me..........(if u donnt understand then reply here......i will describe...)

This post has been edited by hadi_php: 30 Aug, 2008 - 10:44 PM
User is offlineProfile CardPM
+Quote Post

hadi_php
RE: Form Action Problem
30 Aug, 2008 - 11:04 PM
Post #2

New D.I.C Head
*

Joined: 23 Aug, 2008
Posts: 22

OK...I FOUND MY SOLUTION ..........
IN T2.PHP CODE WILL BE

CODE
<html>
<body>
<?php
$first_name = $_POST['first_name'];
echo "Your Name is $first_name";
?>
</body>
</html>

User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Form Action Problem
30 Aug, 2008 - 11:14 PM
Post #3

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,166



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
You can also do some error checking :

CODE

<html>
<body>
<?php
  if(isset($_POST['first_name'])) echo "Your Name is $first_name";
  else echo "You need to enter your first name";
?>
</body>
</html>

User is offlineProfile CardPM
+Quote Post

jonesa01
RE: Form Action Problem
31 Aug, 2008 - 12:03 AM
Post #4

New D.I.C Head
Group Icon

Joined: 18 Feb, 2007
Posts: 39


Dream Kudos: 25
My Contributions
QUOTE(hadi_php @ 30 Aug, 2008 - 11:43 PM) *

CODE
<html>
<body>

<form action = "t2.php" method = "post">

Name : <Input type = "text" name = "first_name" />

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

</form>
</body>
</html>


And in t2.php

CODE
<html>
<body>
<?php
echo "Your Name is $first_name";
?>
</body>
</html>


Output will be what i worte is 1st form text box.

It runs on PHPtried And it outputs what i type in text box.........

But it is not running in XAMPP1.6.7! . Any 1 Plz help me..........(if u donnt understand then reply here......i will describe...)


Ok I use xampp and I would suggest you use the following code in t2.php:

CODE

<html>
<body>
<?php
echo "Your Name is ".$_POST["first_name"];
?>
</body>
</html>

User is offlineProfile CardPM
+Quote Post

chili5
RE: Form Action Problem
31 Aug, 2008 - 06:03 AM
Post #5

D.I.C Addict
****

Joined: 28 Dec, 2007
Posts: 763



Thanked: 4 times
My Contributions
Why would you use:

php

<?php
echo "Your Name is ".$_POST["first_name"];
?>


? That just looks really messy. Not very secure either.

It looks a lot neater to write it as:

php

<?php
$first_name = $_POST['first_name'];
echo "Your name is $first_name";
?>


It's quite a bit neater this way, and you can add some functions to provide some security, without a messy echo statement mixed with different functions and the concatenation operator.
User is offlineProfile CardPM
+Quote Post

hadi_php
RE: Form Action Problem
31 Aug, 2008 - 06:33 AM
Post #6

New D.I.C Head
*

Joined: 23 Aug, 2008
Posts: 22

thanks all for ur opinion...............thanks a lot.
User is offlineProfile CardPM
+Quote Post

jonesa01
RE: Form Action Problem
31 Aug, 2008 - 07:19 AM
Post #7

New D.I.C Head
Group Icon

Joined: 18 Feb, 2007
Posts: 39


Dream Kudos: 25
My Contributions
QUOTE(chili5 @ 31 Aug, 2008 - 07:03 AM) *

Why would you use:

php

<?php
echo "Your Name is ".$_POST["first_name"];
?>


? That just looks really messy. Not very secure either.

It looks a lot neater to write it as:

php

<?php
$first_name = $_POST['first_name'];
echo "Your name is $first_name";
?>


It's quite a bit neater this way, and you can add some functions to provide some security, without a messy echo statement mixed with different functions and the concatenation operator.


In some servers it doesn't work if you include it in the "", doesn't work on my version of xampp
User is offlineProfile CardPM
+Quote Post

chili5
RE: Form Action Problem
31 Aug, 2008 - 07:21 AM
Post #8

D.I.C Addict
****

Joined: 28 Dec, 2007
Posts: 763



Thanked: 4 times
My Contributions
That works on my version of XAMPP. Then you probably have a setting wrong or something. It should work like that. smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:21AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month