passing post in htm as variable into another form

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
gjwolf1
Forum Newbie
Posts: 1
Joined: Sat Feb 26, 2011 1:50 pm

passing post in htm as variable into another form

Post by gjwolf1 »

I have an hml page that uses option values and lets the user select values. the values are php pages which when they submit pass the chosen value to the next page I show a snip below. I wanted to have the form action grab the formVar passed to it- but I can't seem to get it going. I figure I just may not be putting the post in correctly- any help appreciated

I have two pages page1 and page 2 page 1 does the following. since I have a page i want to call (page2_test_html) with all 3 options
I want page2 to be passed the option value(another page) so when a user fills out page2 they will hit submit and get to the page.


page1 is as follows:

<html>
<select onchange="document.myform.formVar.value=this.value">
<option value="newtest.php">poe</option>
<option value="newtest1.php">non poe</option>
<option value="newtest2.php">non poe 24/option>
</select>
<form method=post name="myform" action="page2_test.html">
<input type="hidden" name="formVar" value="">
<input type="submit" value="Send form!">
</form>


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
page 2 part that im having issues w/ as follows:


<head><title>page2</title></head>
<body>
<form action="<?php $_POST['formVar']; ?>" method="POST">

which doesnt work- I've also tried to pass it to this in these ways as someone else suggesting giving it a try but still doesnt work

tried this way
<form action="<?php echo{$_POST['formVar']}; ?>" method="POST">

and this way w/ no luck

<form action="<?php echo($_POST['formVar']); ?>" method="POST">



any help is greatly greatly appreciated
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: passing post in htm as variable into another form

Post by social_experiment »

Code: Select all

<input type="hidden" name="formVar" value="">
I suspect your problem is here, the javascript passes the value but it's not written to the html page (I could be wrong though, my javascript knowledge is need-to-know-more at the moment). Try hard coding an example value in and see what happens.
You 'select' element isn't wrapped in a form element. Try putting it inside a form.

Code: Select all

<form action="<?php $_POST['formVar']; ?>" method="POST">
// should be
<form action="<?php echo $_POST['formVar']; ?>" method="POST" >
// try this option first ^^
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply