transfering the variables to another page

Links for php scripts

Moderators: macek, egami, gesf

User avatar
bezmond
Moderator
Moderator
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK
Contact:

Postby bezmond » Tue Jan 13, 2004 10:06 am

is this the whole pages code? If so, you are missing the <form> tags and so on...

Andrew

sigix
php-forum Active User
php-forum Active User
Posts: 364
Joined: Mon Jul 14, 2003 9:39 pm
Location: /Earth/Xion

Postby sigix » Tue Jan 13, 2004 10:43 am

Code: Select all

<?php
echo "<form action=\"validate.php\" method=\"post\">";

srand((double)microtime()*1000000);
    $rnd1=rand(1,3);
    $x1=$rnd1;

  echo "<INPUT TYPE=\"hidden\" NAME=\"x1\" VALUE=\"$x1\">";
  echo '<input type=submit value=go>';
  echo '</form>';
?>


Code: Select all

#validate.php page
echo "The value received x1:".$_POST['x1'];

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Tue Jan 13, 2004 10:48 am

The hidden form field method only works if you're using forms. If not, you should be using Sessions.


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest