How to call a file and pass details to it?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rajesh10071986
Forum Newbie
Posts: 1
Joined: Tue Jun 29, 2010 9:20 pm

How to call a file and pass details to it?

Post by rajesh10071986 »

Hello,
I'm a newbie. I tried to call file 2 from file 1 and tried to print the name and age, but I'm not able to do it. I think I'm right in code. Can someone help me?

File 1

Code: Select all

<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>
 
File 2

Code: Select all

<html>
<body>

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

</body>
</html> 
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: How to call a file and pass details to it?

Post by requinix »

Gee, I wonder what he meant when he said "not able to do it"...
amitdubey2
Forum Commoner
Posts: 48
Joined: Tue Apr 13, 2010 10:13 pm

Re: How to call a file and pass details to it?

Post by amitdubey2 »

hi rajesh10071986 ,

i don't know exactly but are you saving the second file with .php extension ...( in which you are using php tags) ??
(Even i read that in first file you are submitting the form to welcome.php page.)
this may be problem for you , as code seems fine.
So if not , save it with welcome.php name...!
And please specify what is coming as output when you submit it ..???



:drunk:
amit
Post Reply