Results 1 to 14 of 14
Thread: Passing form variables with PHP?
-
06-22-2005, 08:05 PM #1Retired Moderator
- Join Date
- Jun 2003
- Location
- Proud She-Geek
- Posts
- 1,723
Passing form variables with PHP?
For some reason I am having a total mental block and cannot seem to figure out how to pass form variables from one page to the next using PHP. I also am having trouble finding what I'm looking for when I google it as well.
Hope someone can help!<?php echo "Signature here"; ?>
-
06-22-2005, 09:41 PM #2Web Hosting Master
- Join Date
- Dec 2003
- Location
- Miami, FL
- Posts
- 3,262
Wouldn't a simple
$subject = $_POST['subject'];
work?
-
06-22-2005, 09:54 PM #3Retired Moderator
- Join Date
- Jun 2003
- Location
- Proud She-Geek
- Posts
- 1,723
That's what I thought but in the script I'm working on I have those at the top like
$cpuname = $_POST['uname'];
$cpurl = $_POST['url'];
Then referenced in a format like
PHP Code:$result = "http://'. $cpurl .'/'. $cpuname .'.html";
PHP Code:<input type=hidden name=uname value=<?php echo $cpuname; ?>
<?php echo "Signature here"; ?>
-
06-22-2005, 10:17 PM #4Web Hosting Master
- Join Date
- Dec 2003
- Location
- Miami, FL
- Posts
- 3,262
hmm
try
<?php echo("$cpuname"); ?>
or
<? echo "$cpuname"?>
-
06-24-2005, 12:52 PM #5Newbie
- Join Date
- Jun 2005
- Posts
- 21
You can easily carry them usin a GET method.
-
06-24-2005, 07:03 PM #6Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Kuja, what's the point passing them trough GET method when even POST method for some reason isn't working? Changing the method doesn't mean that problem will go away.
P-nut, try adding print_r($_POST) after issuing POST to see if $_POST was even created and filled.
There might be some weird case that you got redirected for some reason and thus lost all your posted variables.
Posting the code bit somewhere might help us track the problem.
-
06-24-2005, 09:33 PM #7Newbie
- Join Date
- Jun 2005
- Posts
- 21
It could perhaps be a case of the "IE enter key" bug.
-
06-25-2005, 02:21 AM #8Junior Guru Wannabe
- Join Date
- Mar 2005
- Location
- India
- Posts
- 68
Originally posted by P-nut
Then referenced in a format like
PHP Code:$result = "http://'. $cpurl .'/'. $cpuname .'.html";
-
06-25-2005, 05:07 AM #9Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Yes, $result isn't good but even though, $cpurl and $cpuname are within double quotes so they sould evaluate.
-
06-25-2005, 05:29 AM #10Junior Guru Wannabe
- Join Date
- Mar 2005
- Location
- India
- Posts
- 68
Thats true maxymizer, but I was just wondering . Why does he need that "single" quotes?
P-nut , like maxymizer said , print of _POST .. and I would like to see the "FORM" tag too. Lets catch it.
-
06-25-2005, 08:28 AM #11Web Hosting Master
- Join Date
- Jul 2003
- Location
- Kuwait
- Posts
- 5,104
iaef, use sessions.
-
06-25-2005, 07:37 PM #12Junior Guru Wannabe
- Join Date
- Feb 2005
- Posts
- 37
Usually i use echo to print the form, thus every variable is defined.
Try use something like this
<?php
echo "<form type='whatever' method='whatever'>";
echo "<input type='text' name='uname' value='" .$cpurl. "'>";
echo "</form>";
?>
-
06-26-2005, 02:26 AM #13Chief Penguin Chaser
- Join Date
- May 2004
- Location
- Milton, Florida
- Posts
- 786
Try Making a Hidden Input form option for the variables from the previous page..
As for the $result.. That looks perfectly fine.. It turns that line into something like
http://www.hisdomain.com/control_panel_page.html
The Double quotes are there to set $result to everything inside it.. Then the single quotes are there for a purpose aswell..
Just my .02 (BTW; this was my 250th post )
-
06-26-2005, 07:30 AM #14Web Hosting Evangelist
- Join Date
- Apr 2005
- Posts
- 522
Originally posted by platinumn23
As for the $result.. That looks perfectly fine.. It turns that line into something like
actually
That's why it's kinda wrong but that still isn't the reason why POST-ing doesn't work.