Example first page :
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32%" height="38"> </td>
<td width="23%" height="38"> </td>
<td width="26%" height="38"> </td>
<td width="19%" height="38">
<div align="right"><img src="../images/logowhite.gif" width="100" height="40"></div>
</td>
</tr>
<tr>
<td width="32%" height="19"> </td>
<td width="23%" height="19"> </td>
<td width="26%" height="19"> </td>
<td width="19%" height="19"> </td>
</tr>
<tr>
<td width="32%" height="20"> </td>
<td width="23%" height="20"> </td>
<td width="26%" height="20"> </td>
<td width="19%" height="20"> </td>
</tr>
</table>
<form method="post" action="adlog.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%"> </td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%"> </td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%"> </td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%"> </td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Username</b></font></td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%">
<input type="text" name="username">
</td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Password</b></font></td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%">
<input type="password" name="password">
</td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
<tr>
<td width="19%"> </td>
<td width="11%"> </td>
<td width="21%">
<div align="right">
<input type="image" onclick="submit""name="Submit" src="../images/fwd_arrow.gif" width="25" height="23">
</div>
</td>
<td width="14%"> </td>
<td width="32%"> </td>
<td width="3%"> </td>
</tr>
</table>
</form>
<p align="left"> </p>
<p align="left"> </p>
</div>
</body>
Example adlog.php
<?
require ("../user/validate.inc");
require ("../user/database.inc");
require ("../user/session.inc");
$link = dbconnect("localhost" , "root" , "jeetnahai");
if(authorize($username , $password,"adinfo" ,$link) )
{
sessionreg($username , $password);
?>
<script>
window.location.replace ("http://localhost/saurabh/jeetnahai/ad/adinfo.php?<?SID?>");
</script>
<?
}
else
{
header("Location: http://localhost/saurabh/jeetnahai/adhome.htm");
exit();
}
?>
Database.inc
<?
/ this function is for connection to database /
function dbconnect($hostname ,$user , $db)
{
if(mysql_pconnect($hostname , $user) && mysql_select_db($db)){
$link = mysql_pconnect($hostname , $user);
$conn=mysql_select_db($db);
}
else {
//include ("error.inc");
exit();
}
return ($link);
}
/ valtostring function is for converting form data which
have been gathered in array $name into string format so
that instead of putting values in the value field just the
function could be used /
function valtostring($name) {
$num = count($name);
for ($i = 0 ; $i < $num - 1; ++$i) {
$x = $x . ("'$name[$i]',");
}
$z = $num - 1 ;
$y = $y . ("'$name[$z]'");
$tabval = ($x . $y);
return ($tabval);
}
?>
Session.inc
<?
function sessionreg($username , $password) {
session_register("username" , "password");
}
function sessionstart() {
session_start();
}
?>
Validate.inc
<?
function email ($email) {
$regex = '([.a-z0-9-]+[.a-z0-9-])@(([a-z0-9-]+.)([a-z0-9-]+)(.[a-z]{2,3}))$';
$act = 0;
if (!eregi($regex,$email)) {
$act = 1;
}
return ($act);
}
// end of function email
function zipval ($zip) {
$regey = '[0-9]+$';
$strx = strlen($zip);
if(!eregi($regey,$zip) || $strx >= 7 || $strx <= 4) {
$actnum = 1 ;
}
else {
$actnum = 0 ;
}
return ($actnum);
}
//end of function zipval
function checkusername($cusername ,$id ,$tablecheck , $field) {
//mysql_pconnect("localhost" , "root");
//mysql_select_db("jeetnahai");
$qstr = "select * from $tablecheck where $field = '$cusername'";
$result1 = mysql_query($qstr);
$sam = mysql_fetch_row($result1);
if($sam[0] != "") {
$uservalue =1;
echo ("<font color='#000099' face='Verdana, Arial, Helvetica, sans-serif' size='2'><b><i>This $id is already in use ,</i></b></font> ");
}
else {
$uservalue = 0;
}
return ($uservalue);
}
//end of function checkusername
function authorize ($username , $password,$table ,$link) {
$passwordenc = md5($password);
$authstring = "SELECT username , password FROM $table WHERE username = '$username' and password = '$passwordenc'";
$authresult = mysql_query($authstring);
$resultarray = mysql_fetch_row($authresult);
if($resultarray[0] != "" && $resultarray[1] != "" ) {
$authval = 1;
}
else {
$authval = 0;
}
return ($authval);
}
// end of function authorize
function delcookie () {
setcookie("cookie_uname" ,"");
setcookie("cookie_pwd" , "");
}
function phoneval ($phone) {
$regey = '[0-9]+$';
if(!eregi($regey,$phone)) {
$actph = 1 ;
}
else {
$actph = 0 ;
}
return ($actph);
}
function checkusernameedit($cusername ,$id ,$tablecheck , $field) {
//mysql_pconnect("localhost" , "root");
//mysql_select_db("jeetnahai");
$qstr = "select * from $tablecheck where $field = '$cusername'";
$result1 = mysql_query($qstr);
$sam = mysql_fetch_row($result1);
if($sam[0] == "" || $sam[0] == $cusername ) {
$uservalue =0;
}
else {
$uservalue = 1;
echo ("<font color='#000099' face='Verdana, Arial, Helvetica, sans-serif' size='2'><b><i>This $id is already in use ,</i></b></font> ");
}
return ($uservalue);
}
//end of function checkusernameedit
?>
Main Page Example
<?
include("../user/database.inc");
require ("../user/validate.inc");
require("../user/session.inc");
$sess = sessionstart();
$link = dbconnect("localhost" , "root" , "jeetnahai");
if(authorize($username , $password,"adinfo" ,$link) ) {
$stmt1 = "select adname from addisplay where username = '$username'";
$stmt = "select viewpurchased , viewed FROM adview where adname = '$adname'";
$query = mysql_query($stmt);
$query1 = mysql_query($stmt1);
$viewlist = mysql_fetch_row($query);
$viewleft = $viewlist[0] - $viewlist[1];
?>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="right">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="32%" height="38"> </td>
<td width="23%" height="38"> </td>
<td width="26%" height="38"> </td>
<td width="19%" height="38">
<div align="right"><img src="../images/logowhite.gif" width="100" height="40"></div>
</td>
</tr>
<tr>
<td width="32%" height="19"> </td>
<td width="23%" height="19"> </td>
<td width="26%" height="19"> </td>
<td width="19%" height="19"> </td>
</tr>
<tr>
<td width="32%" height="20"> </td>
<td width="23%" height="20"> </td>
<td width="26%" height="20"> </td>
<td width="19%" height="20"> </td>
</tr>
</table>
<form action="displayad.php" name="detail">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#CCCCFF">
<td colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Campaign
List</b></font></td>
</tr>
<tr>
<td colspan="2">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><i>Select
campaign to view detail</i></b></font></div>
</td>
</tr>
<tr valign="middle">
<td height="36" colspan="2">
<div align="center">
<?
$affect = mysql_affected_rows($link);
echo("<select name='adname'>");
for($i = 0; $i < $affect; ++$i) {
$result[$i] = mysql_fetch_row($query1);
echo("<option>" . $result[$i][0] . "</option>");
}
echo("</select>");
?>
<input type="submit" name="Submit" value="view">
</div>
</td>
</tr>
</table>
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" bgcolor="#CCCCFF"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Details</b></font></td>
</tr>
<tr>
<td height="23" colspan="2"> </td>
</tr>
<tr>
<td height="23" width="23%"><i><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Adname</font></b></i></td>
<td height="23" width="77%"><b><i><font face="Verdana, Arial, Helvetica, sans-serif" size="2">: <? echo($adname); ?></font></i></b></td>
</tr>
<tr>
<td height="23" width="23%"><font color="#FFFFFF"><i><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></b></i></font></td>
<td height="23" width="77%"><b><i><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></i></b></td>
</tr>
<tr>
<td height="23" width="23%"><i><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">View
Purchased</font></b></i></td>
<td height="23" width="77%"><b><i><font face="Verdana, Arial, Helvetica, sans-serif" size="2">: <? echo($viewlist[0]); ?></font></i></b></td>
</tr>
<tr>
<td height="23" width="23%"><font color="#FFFFFF"><i><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></b></i></font></td>
<td height="23" width="77%"><b><i><font face="Verdana, Arial, Helvetica, sans-serif" size="2"></font></i></b></td>
</tr>
<tr>
<td height="23" width="23%"><i><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">View
Left</font></b></i></td>
<td height="23" width="77%"><b><i><font face="Verdana, Arial, Helvetica, sans-serif" size="2">: <? echo($viewleft); ?></font></i></b></td>
</tr>
</table>
<p align="left"> </p>
</div>
</body>
<?
}
else {
echo("sorry check CODE");
}
?>
Logout Example
<?
session_start();
session_unset("username" , "password");
echo("LOGED OUT");
?>