Topic: another poor attempt at my own script (Read 724 times)
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« on: Jan 06, 2006, 05:00:32 PM »
this is part of a larger script which i am piecing together, its a control panel for hosting accounts. the login system is complete, data is stored in mysql DB all in 1 table called "users". what im having trouble with is the page that will show their billing status. days left on current subscription, and how much they will owe when the subscription is up. i have done all the necessary math, and completed some of the actual code that figures out what a certain users info is based on the data that i manually enter into the table.. heres the code (the piece that is quoted out is the part where math is involved, as well as determining some variables that come from the DB based on what USER is logged in)
/* display results */ echo "You have "; echo $days_left; echo "days left until your next payment is due.<br>"; echo "You will owe the following amount: "; echo $total; echo ". Thank you!";
?>
the way its written, it will not display errors just blank results because it cant even determine what user is logged in first of all :S
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #1 on: Jan 06, 2006, 06:34:00 PM »
Aren't you missing something on your select statements? Shouldn't it be something like this: $dstart = mysql_fetch_field('select dstart from users WHERE USER = $CURUSR');
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #3 on: Jan 07, 2006, 11:20:33 AM »
ok i have made some progress. it now sucessfully connects to the DB and obtains the proper values. but still some errors, and ive lost and confused myself on how to show how many days are left in the subscription.. be sure to note the /* */ areas, as those are the parts that for some reason do not work, except in the middle which i have no idea how to write for $plan
Code:
<link rel=stylesheet href=style.css> <?php
//Start Billing Module ob_start();
//Prepare for Execution of Module require('config.php'); ini_set('display_errors', 1);
//Security check to be sure a valid user is logged into the CP /* if ($logged[username]) { */
//Define Variables, Load DB values, & Do some math :D $data = mysql_query("SELECT * from users where username = '$logged[username]'"); $data = mysql_fetch_array($data); $dstart = $data['dstart']; $subscription = $data['subscription']; $dplan = $data['dplan']; $days_in_subscription = 365 * $subscription; $dend = $days_in_subscription + $dstart ; $days_left = $dend - $dstart;
// Display the results of above functions and values.
echo "You have "; echo $days_left; echo " days left until your next payment is due.<br>"; echo "You will owe the following amount: "; echo $total; echo ". Thank you!";
// In case of session errors, or a person not logged in, display this
/* } else { echo "<center>Sorry but for some reason your session has expired. Please log out and then back in, and try again.<br>"; echo "You also may not be logged in, and tried to access this page directly. <br> echo "This attempt has been logged as well as the time, date, and your IP.</center>"; } */ ?>
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #5 on: Jan 08, 2006, 04:33:01 AM »
nonono i commented them out so u could see the part i need help with, heres how far i am now almost done just need help with $plan:
Code:
<link rel=stylesheet href=style.css> <?php
//Start Billing Module ob_start();
//Prepare for Execution of Module require('config.php'); ini_set('display_errors', 1);
//Security check to be sure a valid user is logged into the CP
if ($logged[username]) {
//Define Variables, Load DB values, & Do some math :D $data = mysql_query("SELECT * from users where username = '$logged[username]'"); $data = mysql_fetch_array($data); $dstart = $data['dstart']; $subscription = $data['subscription']; $dplan = $data['dplan']; $days_in_subscription = 365 * $subscription; $dz = date('z'); $dz2 = $dz + 1; $days_left = $days_in_subscription - $dz2;
/* $plan = if $dplan==1 ( then value of plan == plana } if $dplan==2 } value of plan == planb } else { value of plan == planc } */ $total = ($subscription * $plan); $plana = "19.99"; $planb = "29.99"; $planc = "39.99";
// Display the results of above functions and values. echo "You have "; echo $days_left; echo " days left until your next payment is due.<br>"; echo "You will owe the following amount: "; echo $total; echo ". Thank you!";
// In case of session errors, or a person not logged in, display this
} else { echo "<center>Sorry but for some reason your session has expired. Please log out and then back in, and try again.<br>"; echo "You also may not be logged in, and tried to access this page directly. <br> echo "This attempt has been logged as well as the time, date, and your IP.</center>"; }
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #6 on: Jan 08, 2006, 09:04:23 AM »
dont worry about it Nik, ive finaly wrote my own script all my own with no help just by taking time.. and reading crap on php.net and reading other scripts.. here is finished code that will show the user logged in to the CP their billing status.
Code:
<link rel=stylesheet href=style.css> <?php //Omega CP: Billing Status //Author: Justin Love of J Love Web Design //URL: http://www.justinlove.net //Copyright 2006
//Start Billing Module & Allow use of cookies in CP ob_start();
//Prepare for Execution of Module require('config.php'); include('omega.php');
//Security check to be sure a valid user is logged into the CP (Note A: Only needed if billing.php is called outside frame)
// In case of session errors, or a person not logged in, display this (refer to note A)
} else { echo "<center>Sorry but for some reason your session has expired. Please log out and then back in, and try again.<br>"; echo "You also may not be logged in, and tried to access this page directly. <br>"; echo "This attempt has been logged as well as the time, date, and your IP.</center>"; echo "<center>"; include('login.php'); echo "</center>"; } echo "<br><br><br><center>Billing Module Version: $billver </center>"; ?>