Page 1 of 1

Help needed please

Posted: Tue Jun 03, 2008 5:15 am
by jjl
I have a page with two input buttons - Button1 retreives info from a database and shows it on screen. If the data is correct I press button two and it saves more info to another file. This is done using php & POST
like this

Code: Select all

 
<?php
if ($_POST['getdetails']) 
    { GetDetails(); }
 
if ($_POST['approve']) // 
       { DoSomethingElse();  // Using the details I retrieve in POST['getdetails'] hopefully
}
 
ApproveForm();
 
function ApproveForm () {
    global  $username, $email;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"
>
<html>
  <head>
   <body>
    <FORM method="POST" action="<?= $_SERVER['PHP_SELF'] ?>">
      <input type="text" name="username" value="<?= $username ?>" SIZE=25 MAXLENGTH=50 />
      <input type="submit" value="Get User Details" name = "getdetails" />
      <input type="submit" value="Approve New User" name = "approve"/>
      <?php 
      echo "Username:  ".$_SESSION[user_name]. "<br />";
      echo "Email:     ".$_SESSION[email]. "<br />";
    </FORM>
  </body>
</html>
<?php
}
?>
 
The trouble I am having is keeping the variable information when the page reloads after pressing Button1.
I need some of the information I retreive from button1 (without having to retreive it again when I press button2.

I get a bit lost with the scope of global variables and am not sure if they are the best way of handling it, maybe cookies will do (but what if they are turned off). If Someone could help me here I would appreciate it. I have made it work Ok, but only by getting the details twice and I was hoping to avoid that. I have a feeling this has something to do with session duration but have not worked it out yet.
Thanks

Re: Help needed please

Posted: Tue Jun 03, 2008 6:04 am
by panic!
an ambiguous title such as 'help needed please' will mean less people will read your thread. Try renaming it to something more descriptive. Everyone on here is looking for help so 'help needed please' is redundant.