Hi Paul
I agree. I am not a web developer but an Accountant trying to do my IT Managers job!
I have started to design an online customer site which users can access using their username & password. From here they can view their call usage & historical invoices & payments & also personal details.
This is my full code:
<?php
session_start();
if ($SESSION['logged_in'] != "true"){
$username = $POST['username'];
$password = $POST['password'];
}
else {$username = $SESSION['username'];
$password = $_SESSION['password'];
}
$self = $_SERVER['PHP_SELF'];
$referer = 'login.php';
if( ( !$username ) or ( !$password ) )
{ header( "Location:$referer" ); }
$conn = @mysql_connect( "localhost", "xxxx", "xxxx" )
or die ( "Could not connect" );
$rs = @mysql_select_db( "rates", $conn )
or die( "Could not select database" );
$sql="select * from custs_uk where username = '" . $username . "'
and password = '". $password . "'";
$rs = mysql_query( $sql, $conn )
or die(mysql_error() . "Could not execute query" );
$num = mysql_numrows( $rs );
if( $num != 0 ){
$SESSION['logged_in'] = "true";
$SESSION['username'] = $username;
$_SESSION['password'] = $password;
$rs = @mysql_select_db( "rates", $conn )
or die( "Could not select database" );
$sql = "select * from cdruk where username = '" . $username . "'";
$rs = mysql_query( $sql, $conn )
or die(mysql_error() . "Could not execute query" );
$list = "<table border=\"0\" cellpadding=\"5\">";
$list .= "<tr><th>Cli</th>";
$list .= "<th>Date</th>";
$list .= "<th>Time</th>";
$list .= "<th>Number</th>";
$list .= "<th>Destination</th>";
$list .= "<th>Duration</th>";
$list .= "<th>Cost</th></tr>";
$total_duration = 0;
$total_cost = 0;
while( $row = mysql_fetch_array( $rs ) )
{
$total_duration += $row['duration'];
$total_cost += $row['cost'];
$list .= "<tr>";
$list .= "<td>".$row["cli"]."</td>";
$list .= "<td>".$row["date"]."</td>";
$list .= "<td>".$row["time"]."</td>";
$list .= "<td>".$row["number"]."</td>";
$list .= "<td>".$row["destination"]."</td>";
$list .= "<td>".$row["duration"]."</td>";
$list .= "<td>".$row["cost"]."</td>";
$list .= "</tr>";
$list .= "</tr>";
}
$list .= "</table>";
}
else{
header("Location: login.php");
}
?>
<html>
<!-- DW6 -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link rel="stylesheet" href="emx_nav_left.css" type="text/css">
<script type="text/javascript">
<!--
var time = 3000;
var numofitems = 7;
//menu constructor
function menu(allitems,thisitem,startstate){
callname= "gl"+thisitem;
divname="subglobal"+thisitem;
this.numberofmenuitems = 7;
this.caller = document.getElementById(callname);
this.thediv = document.getElementById(divname);
this.thediv.style.visibility = startstate;
}
//menu methods
function ehandler(event,theobj){
for (var i=1; i<= theobj.numberofmenuitems; i++){
var shutdiv =eval( "menuitem"+i+".thediv");
shutdiv.style.visibility="hidden";
}
theobj.thediv.style.visibility="visible";
}
function closesubnav(event){
if ((event.clientY <48)||(event.clientY > 107)){
for (var i=1; i<= numofitems; i++){
var shutdiv =eval('menuitem'+i+'.thediv');
shutdiv.style.visibility='hidden';
}
}
}
// -->
</script>
<style type="text/css">
<!--
body {
background-color: #808080;
}
.style4 {font-size: x-small}
.style7 {font-size: x-small; color: #21536A; }
.style8 {color: #21536A}
-->
</style>
</head>
<body onmousemove="closesubnav(event);">
<div class="skipLinks">skip to: <a href="#content">page content</a> | <a href="pageNav">links on this page</a> | <a href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a> </div>
<div id="masthead">
<h1 id="siteName">Customer - cPanel </h1>
<!-- end globalNav -->
<div id="subglobal1" class="subglobalNav">
<a href="#">subglobal1 link</a> | <a href="#">subglobal1 link</a> | <a href="#">subglobal1
link</a> | <a href="#">subglobal1 link</a> | <a href="#">subglobal1 link</a> | <a href="#">subglobal1
link</a> | <a href="#">subglobal1 link</a>
</div>
<div id="subglobal2" class="subglobalNav">
<a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2
link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2
link</a> | <a href="#">subglobal2 link</a>
</div>
<div id="subglobal3" class="subglobalNav">
<a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3
link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3
link</a> | <a href="#">subglobal3 link</a>
</div>
<div id="subglobal4" class="subglobalNav">
<a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4
link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4
link</a> | <a href="#">subglobal4 link</a>
</div>
<div id="subglobal5" class="subglobalNav">
<a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5
link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5
link</a> | <a href="#">subglobal5 link</a>
</div>
<div id="subglobal6" class="subglobalNav">
<a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6
link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6
link</a> | <a href="#">subglobal6 link</a>
</div>
<div id="subglobal7" class="subglobalNav">
<a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7
link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7
link</a> | <a href="#">subglobal7 link</a>
</div>
<div id="subglobal8" class="subglobalNav">
<a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8
link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8
link</a> | <a href="#">subglobal8 link</a>
</div>
</div>
<!-- end masthead -->
<div id="pagecell1">
<!--pagecell1-->
<img alt="" src="tl_curve_white.gif" height="6" width="6" id="tl"> <img alt="" src="tr_curve_white.gif" height="6" width="6" id="tr">
<div id="breadCrumb">
</div>
<div id="pageName">
<h2>Welcome</h2>
</div>
<div id="pageNav">
<div class="style4" id="sectionLinks"><a href="invoices.php">Invoices</a><a href="/cview/payments.php">Payments</a><a href="/cview/personal.php">Personal</a><a href="logoff.php">Log Off</a></div>
</div>
<div id="content">
<div class="story">
<p>Call Usage (current month) </p>
<p><span class="style7">Duration</span> <?php echo $total_duration; ?> <span class="style8">Cost</span> <?php echo $total_cost; ?> </p>
<p class="story">*Note > Any discounts & credits will be calculated at the end of month (if applicable).</p>
<p>
<font face="Arial, Helvetica, sans-serif"><?php
echo( $list );
?></font> </p>
</div>
</div>
</div>
<!--end pagecell1-->
<br>
<script type="text/javascript">
<!--
var menuitem1 = new menu(7,1,"hidden");
var menuitem2 = new menu(7,2,"hidden");
var menuitem3 = new menu(7,3,"hidden");
var menuitem4 = new menu(7,4,"hidden");
var menuitem5 = new menu(7,5,"hidden");
var menuitem6 = new menu(7,6,"hidden");
var menuitem7 = new menu(7,7,"hidden");
// -->
</script>
</body>
</html>