Thats not really php but heres my actual php problem:
*edit* WHen the page is first loaded, everything is blank except for my debugging variables.. which at load only one of them is shown..
which is $_SESSION['status']==1 ... that determines what part of the script is being loaded, to the most part. Once I reload then the script is run properly, anyone see the problem?
CODE:
Code: Select all
<? session_start(); ?>
<link href="inc/css.css" rel="stylesheet" type="text/css">
<?
include("inc/connect.php");
//assigning empty variables
$missing = array();
//setting variables for which page should be loaded
if (isset($personal)){
$_SESSION['status']=2;
}else{
$_SESSION['status']=1;
}
$error=0;
//error checking
if ($_SESSION['status']==1 || $_SESSION['status']==2){
$missing = array();
if ($submit == 'Continue'){
if(!empty($_POST)) {
if ($status==1){
$required = array('hosting','timelicense'); }
elseif ($status==2){
$required = array('firstname','lastname','password','email','contact'); }
foreach($required as $req){
if(empty($_POST[$req])){
$missing[] = $req;
$error += 1;
}else{
$_SESSION['status']=0;
} } } } }
if (($_SESSION['status']==1 || $error==1 || $error==2) && (!$personal)){
//setting variables for filled in fields
if(!empty($_POST['submit'])){
if ($timelicense=="Life Time Licence"){ $timelicense1 = "checked"; }
elseif ($timelicense=="One Year License") { $timelicense2 = "checked"; }
if ($hosting=="Forum hosting package AB100"){ $hosting1 = "checked"; }
elseif ($hosting=="Forum hosting package AB150"){ $hosting2 = "checked"; }
if ($optional=="Copywright Removal"){ $optional1 = "checked"; }
}
include("form.php");
//when form is submitted and no errors
}elseif ($_SESSION['status']==0 && (!$personal)){
//assigning the sessions to variables
if (!isset($_SESSION['timelicense'])){ $_SESSION['timelicense'] = $timelicense; }
if (!isset($_SESSION['hosting'])){$_SESSION['hosting'] = $hosting; }
if (!isset($_SESSION['optional'])){$_SESSION['optional'] = $optional; }
//setting the query
$result = @mysql_query("SELECT * FROM prices");
if (!$result) {
echo("<p>Error performing query: ". mysql_error());
exit();
}
//getting the database information
while ( $row = mysql_fetch_array($result)) {
$lifetimeL = $row[0];
$oneyearL = $row[1];
$AB100 = $row[2];
$AB150 = $row[3];
$copywright = $row[4];
}
//if no optional copywright is false
if (empty($optional)){ $copywright="0"; }
if ($timelicense=="Life Time License"){ $licenseprice=$lifetimeL; }else{ $licenseprice=$oneyearL; }
if ($hosting=="Forum hosting package AB100"){ $hostingprice=$AB100; }else{ $hostingprice=$AB150; } ## GOTTO FIX THE PRICING
?>
<div align="center" class="text">Thank you for showing an interest in AG.</div>
<br>
<? //confirming the users order ?>
<table width="50%" border="0" align="center" cellpadding="0" cellspacing="0" class="error">
<tr>
<td class="steps">Step 2/3 - Confirming your License</td>
</tr>
</table>
<table class="text" align="center" width="50%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE">Your chosen Purchase Items: </td> </tr>
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE"> - <? echo $_SESSION['timelicense']; echo " $".$licenseprice; ?> </td> </tr>
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE"> </td> </tr>
<? if ($_SESSION['hosting'] != "None" || (isset($_SESSION['optional']))) { ?>
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE">Your Purchase Optional Items:</td> </tr>
<? } if ($_SESSION['hosting'] != "None"){ ?>
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE"> - <? echo $_SESSION['hosting']; echo " $".$hostingprice; ?> </td> </tr>
<? } if (!empty($optional)){ ?>
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE"> - <? echo $_SESSION['optional']; echo " $".$copywright; ?> </td> </tr>
<? } ?>
<tr> <td bordercolor="#EEEEEE" bgcolor="#EEEEEE">
<div align="right">Total: <? $total=$licenseprice+$hostingprice+$copywright; echo "$".$total; ?></div>
</td> </tr>
</table>
<? $_SESSION['total'] = $total; ?>
<br>
<div align="center">
<table width="50%" border="0" cellpadding="0" cellspacing="0">
<tr bgcolor="#EEEEEE">
<td width="50%" height="26"><input name="button" type="button" onClick="history.back()" value="Back"></td>
<form name="register" method="post" action="register.php">
<td> </td>
<td width="50%"> <div align="right"> <input name="submit" type="submit" id="submit" value="Continue"></div></td>
<input type="hidden" name="personal" value="2"/>
</form>
</tr>
</table>
</div>
<?
}elseif ($personal){
if (($personal == 2 && $error != 0) || $error==0){
if ($error != 0){
if ($email != $email2){
$errormessage='Your emails do not match, please go back and enter identical emails. Make sure your emails are correct as they are required for futur uses.';
$errormsg=1;
}elseif ($password != $password2){
$errormessage='Your passwords do not match, please go back and enter identical passwords.';
$errormsg=1;
}elseif (strlen($password) < 6 && (isset($password))){
$errormessage='Your password is too short, please enter a password of 6 or more characters.';
$errormsg=1;
}
include("form.php");
}elseif ($error=="0"){
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['contact'] = $contact;
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
$_SESSION['contact'] = $contact;
$_SESSION['comments'] = $comments;
?>
<table width="50%" border="0" align="center" cellpadding="0" cellspacing="0" class="steps">
<tr>
<td>Purchase Summary</td>
</tr>
</table>
<table width="50%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#EEEEEE" class="text">
<tr bordercolor="EEEEEE">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td class="subtitle2">LICENSE</td>
<td> </td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Type:</td>
<td><? echo $_SESSION['timelicense']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Hosting:</td>
<td><? echo $_SESSION['hosting']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Optional:</td>
<td><? echo $_SESSION['optional']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Total:</td>
<td>$<? echo $_SESSION['total']; ?> (USD)</td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td colspan="2" class="subtitle2">PERSONAL</td>
</tr>
<tr bordercolor="EEEEEE">
<td width="3%"> </td>
<td width="14%"> </td>
<td width="83%"> </td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Firstname: </td>
<td><? echo $_SESSION['firstname']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Lastname:</td>
<td><? echo $_SESSION['lastname']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Contact #:</td>
<td><? echo $_SESSION['contact']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td> </td>
<td>Email:</td>
<td><? echo $_SESSION['email']; ?></td>
</tr>
<tr bordercolor="EEEEEE">
<td height="20"> </td>
<td> </td>
<td> </td>
</tr>
</table>
<?
if ($confirmed==1)
$sql = "INSERT INTO users SET firstname='$firstname',lastname='$lastname',password='$password',email='$email',contact='$contact',comments='$comments'";
if (@mysql_query($sql)) {
echo("Your request for a license has be submitted to our database. Check your email to confirm your information and you will be contacted withen 48 business hours.");
} else {
echo ("Error adding your request, please try again later. " . mysql_error());
}
}
}
}
echo $_SESSION['status'];
if (!$_SESSION['status']){ echo "die"; }
?>