Page 1 of 1

Passing variable data between php pages

Posted: Sun Feb 08, 2009 12:02 am
by Xyle
I have 1 php page that when a user clicks an image it opens a new php page and passes a variable to the new page. The Problem Im having is that the variable is not getting passed.

Heres the code...

Code: Select all

            
$gCreatorArray[$tCnt] = $gCreator;
echo "<div style='Z-INDEX: 101; LEFT: 265px; WIDTH: 800px; POSITION: absolute; TOP: ".$tMarg2."px; HEIGHT: 20px'>";
echo "<form name='myform' action='http://localhost:8060/NWTTT/NWTTTClient2.php' method='POST'>";
echo "<input type='image' src='images/InvsBar500x20Red.png' name='image' value='".$gCreatorArray[$tCnt]."' width='500' height='20'>";
echo "GameCreator: ".$gCreatorArray[$tCnt];
echo "</form>";
echo "</div>";
 
I am tagging the image with "value = '".$gCreatorArray[$tCnt]."' but I dont understand why this isnt working, I even tried replacing the variable with 'woohoo' just to see if it would pass an actual string, but that didnt work either.

Any help would be greatly appreciated!!

Re: Passing variable data between php pages

Posted: Sun Feb 08, 2009 3:03 am
by deejay
have you tried to var_dump the $_POST on the receiving page.

Code: Select all

 
var_dump($_POST);
 
what results does i give or is it null?

Re: Passing variable data between php pages

Posted: Sun Feb 08, 2009 3:11 am
by dheeraj
why didn't u try anchor tag.....

here is the code

Code: Select all

$gCreatorArray[$tCnt] = $gCreator;
echo "<div style='Z-INDEX: 101; LEFT: 265px; WIDTH: 800px; POSITION: absolute; TOP: ".$tMarg2."px; HEIGHT: 20px'>";
echo "<a href='http://localhost:8060/NWTTT/NWTTTClient2.php?var1=$gCreatorArray[$tCnt]'><img src='images/InvsBar500x20Red.png' /></a>";
 
then in 2nd page receive value like below..

Code: Select all

$creater=$_GET['var1'];
tht's solve..

Re: Passing variable data between php pages

Posted: Sun Feb 08, 2009 9:55 am
by Xyle
dheeraj wrote:why didn't u try anchor tag.....

here is the code

Code: Select all

$gCreatorArray[$tCnt] = $gCreator;
echo "<div style='Z-INDEX: 101; LEFT: 265px; WIDTH: 800px; POSITION: absolute; TOP: ".$tMarg2."px; HEIGHT: 20px'>";
echo "<a href='http://localhost:8060/NWTTT/NWTTTClient2.php?var1=$gCreatorArray[$tCnt]'><img src='images/InvsBar500x20Red.png' /></a>";
&nbsp;
then in 2nd page receive value like below..

Code: Select all

$creater=$_GET['var1'];
tht's solve..
Worked like a charm! Thank you very much!! I really appreciate the help. Deejay, thank you for your post, I didn't try the var_dump solution so I dont know if that would work or not, but thank you for the help also.

Re: Passing variable data between php pages

Posted: Sun Feb 08, 2009 11:37 am
by sharad99088
your variable is not getting passed to next page because you form is not getting submitted. you can use the get method to pass the variable to next page on onclick event.