Page 1 of 1

Variables go poof...

Posted: Sun Apr 18, 2004 6:10 pm
by Steveo31
Sup-

Have a little issue with variables passed from one if() statement to the other. The situation here is that the user can sign up for an appointment, and then once it is submitted, the URL changes and it is then dealt with from there, based on the GET vars.

Up to this point it works ok. Here's the code:

Code: Select all

<?php
if(isset($_GET['status'])){
if($_GET['status']=='addlesson'){
$date = '2004-'.$_POST['month'].'-'.$_POST['day'];
$stime = $_POST['hour'].':'.$_POST['minute'];
$etime = $_POST['ehour'].':'.$_POST['eminute'];

?>


<table width="50%">
//all the above variables are successfully echoed.
</table>


<?php
}//end status
}else{ //end if GET == status
?>
<form action="members.php?action=setappt&status=addlesson" method="post">
//form stuff
</form>
So once the user submits that form, the url goes to members.php?action=setappt&status=addlesson. That just shows the data, letting the user see what they entered, and from there can make changes or confirm.

To confirm, I have a hyperlink:

<a href="members.php?action=setappt&status=addlesson&valid=1>Click if Okay</a>

Now, I can't get it to recognize the variables are still there once that link is clicked. The page stays there, but the echoed variables disappear, and 0000-00-00 is entered in the database.

I've tried

Code: Select all

if(isset($_GET['valid'])){
    if($_GET['valid'] == '1'){
        echo "DATE:  ".$date;
    }
}
Above the initial if(isset($_GET['status'])), but the variables are empty.

....

Posted: Sun Apr 18, 2004 8:20 pm
by John Cartwright
try this:

Code: Select all

<?php 
if(isset($_POST['status'])){ 
if($_POST['status']=='addlesson'){ 
$date = '2004-'.$_POST['month'].'-'.$_POST['day']; 
$stime = $_POST['hour'].':'.$_POST['minute']; 
$etime = $_POST['ehour'].':'.$_POST['eminute']; 

<table width="50%"> 
//all the above variables are successfully echoed. 
</table> 


<?php 
}//end status 
}else{ //end if GET == status 

<form action="members.php" method="post"> 
<input type="hidden" name="setappt" value="addlesson">
<input type="hidden" name="status"  value="addlesson">
//form stuff 
</form>

Posted: Sun Apr 18, 2004 11:36 pm
by Steveo31
For some reason that makes a textbox... weird. But no, that wasn't it. ARGH!!