Forum Moderators: coopster

Message Too Old, No Replies

post variable then what?

         

RogueDogg

7:32 pm on Jul 13, 2006 (gmt 0)

10+ Year Member



I have a variable that is passed via
$_POST[FirstName]
from apage1.php to apage2.php and now I do some edits to that page and submit that to apage3.php but the variable doesn't come across to the next page...how come?

Example:
db query to get firstname in a form then using the post method I submit that to another page. Then add some features ( not changing the firstname variable at all ) and submit that form ( 2 total forms now ) using the post method as well. So we've got 2 forms with a total of 3 php files. I've tried using hidden values on the 2nd php page to the 3rd php page 2nd form but that doesn't work ( unless I'm doing it wrong ). Any Ideas?

RogueDogg

8:14 pm on Jul 13, 2006 (gmt 0)

10+ Year Member



I got rid of one php page but no matter it's still the same issue. So what you do is click on the first submit button and it now displays the website that was query'd from the database, now add some new text to the text box and click on the second submit button, you will notice only the text box variable is being passed to the 3rd page. Here is the code for the 2 pages:

test2.php

<?
$db = mysql_connect ("localhost","dbuser","dbpword") or die(mysql_error());
$link = mysql_select_db ("cashflow_misc", $db) or die(mysql_error());
$query = "select website FROM websites";
$result = mysql_query($query);
$website = mysql_result ($result, 0);
?>
<form method="post" name="website" action="<? echo $_SERVER['PHP_SELF'];?>">
Database query complete press submit to see your website below:
<input type="hidden" name="website" value="<? echo "$website";?>" />
<input type="submit" name="add_website" value="submit" />
</form>
<br />
<br />
<form method="post" name="test" action="test3.php">
This is your website: <? echo $_POST['website'];?>
<br />
<br />

<input type="text" name="test" maxlength="18" value="blah test" />
<input type="submit" name="test2" value="submit" />
</form>

Here is the code for test3.php:

<? 
echo "$website";?> this should be your website <br />
<? echo "$test";?>

Hope that helps anyone understand my problem(s).

[edited by: coopster at 8:16 pm (utc) on July 13, 2006]
[edit reason]
[1][edit reason] removed url per TOS [webmasterworld.com] [/edit]
[/edit][/1]

henry0

8:48 pm on Jul 13, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unless I missed it I only see a query
what do you after insert? ... update?
How does look the sql code?

ref to your statement makes me think that (but I do not have the sql) you might only perfom an insert in lieu of an update

RogueDogg

10:17 pm on Jul 13, 2006 (gmt 0)

10+ Year Member



Ok what I wasn't doing was putting the variable in the 2nd form as a hidden atribute in order to echo it on the 3rd php page. I've got it figure out now.

* NOTE to admin's*

Sorry bout the URL I forgot...won't happen again. (cheers)