[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Transfer post information to next page

Posted on 2006-06-07
7
Medium Priority
?
733 Views
Last Modified: 2011-10-03
Hi,

There is probably a simple adjustment I need to make to resolve my problem....

I recently set up php 4.4.2 on my home IIS server.  I'm able to call php pages.  The problem I run into is when I set up a simple form on a regular htm page and try to pass that info to the next php page.  The info simply does not carry over.

I'm basing this on some very basic sample pages:

Form page:
<html>
 <head>
 <title>My Form</title>
 </head>
 <body>

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

 My name is:
 <br> <input type="text" name="YourName">

 <p> My favorite dirty word is:
 <br> <input type="text" name="FavoriteWord">
 <p>

 <input type="submit" name="submit" value="Enter My Data!">
 </form>

 </body>
 </html>

and the "bad_words.php" file/page:

<html>
<head>
<title>Perv!</title>

</head>

<body bgcolor="#FFFFFF" text="#000000">

<p>
Hi <?php print $YourName; ?>

<p>
You like the word <b> <?php print $FavoriteWord; ?> !?! </b>

<p>You oughta be ashamed of yourself!

</body>
</html>

I'm wondering if I missed something in the code or perhaps it's some php.ini setting I missed....

I'm very new to PHP, and am trying to set this server up to start exploring PHP further.




0
Comment
Question by:tomseay
  • 4
  • 2
7 Comments
 

Author Comment

by:tomseay
ID: 16858494
correction, i installed php 5.1.4.
0
 
LVL 1

Expert Comment

by:aot2002
ID: 16858498
use this not $YourName
>>Hi <?php print $YourName; ?>

echo $_REQUEST['YourName'];
0
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 16858500
In bad_words.php, you need to retrieve the values from the POST array.

$YourName = $_POST["YourName"];
$FavoriteWord = $_POST["FavoriteWord"];

Then you can use them as variables in the code.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Accepted Solution

by:
aot2002 earned 200 total points
ID: 16858531
<html>
<head>
<title>Perv!</title>

</head>

<body bgcolor="#FFFFFF" text="#000000">

<p>
Hi <?php echo $_REQUEST['YourName']; ?>

<p>
You like the word <b> <?php echo $_REQUEST['FavoriteWord']; ?> !?! </b>

<p>You oughta be ashamed of yourself!

</body>
</html>


Basically you cant reference variables until you receive them from the previous page
your trying to print out a variable from another page but you havent requested that variable
example
$temp = $_REQUEST['YourName'];
echo $temp;
print $temp;

notice i pass the previous page variable into a new variable
0
 
LVL 1

Expert Comment

by:aot2002
ID: 16858533
do you understand? if not ask what it is your missing what were telling you
0
 

Author Comment

by:tomseay
ID: 16858644
I believe I understand.  basically you have to request the variable before you can print it.  The code example I had was from a page that did not explain that.  What I provided was all I received.  Guess I should consider another source to learn PHP...any recommendations?

Thanks for your help...the example worked great.

0
 
LVL 1

Expert Comment

by:aot2002
ID: 16858986
yes i would recommend an ausome book which will show many real life examples
PHP and MySQL Web Development, Third Edition
By Luke Welling, Laura Thomson
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question