Project Report
Project Report
on
ULTIMATECOURIERS.COM
Developed in
PHP And My SQL
Synopsis
Submitted in
the Partial Fulfillment
Of
PHP Certification
To
CMC Academy
Supervised by:
Cherry Mam
Submitted by:
Sonal Maheshwari
Acknowledgement
With regard to my project with CMC Academy, I would like to thank each and every one who offered help,
guideline and support whenever required.
First and foremost I would like to express gratitude to our teacher Miss Cherry and other staffs for their
support and guidance in the project work. I am extremely grateful to my supervisor for her valuable guidance
and timely suggestions. I would like to thanks to all those teachers who have given their valuable time and
responses during the project work, to complete my project work successfully.
Sonal Maheshwari
Table of Contents
(i) Certificate
(ii) Acknowledgment
1. Introduction
2. Project Profile
1. Snapshots
2. Coding
Introduction
The concept of this project is to develop a website which provides online courier service to its users. Here
registered users can upload their digital data like photos and printable documents, then we will courier these
data to the destination. We are even providing different options with photos and files like kind of framing and
binding required. We are trying to provide all these services at the minimum cost so that users can upload
their data on our site and then we’ll courier it to the destination at local cost. In this manner, the purpose of
this site is to cheap, easy, convenient and compatible courier services to its customers.
PROJECT PROFILE
SNAPSHOTS
Home Page
Registration Page
Upload Page
Status Page
CODING
Courier_fns.php
CODE:
<?php
function db_connect()
{
$result = new mysqli('localhost', 'root', '', 'courier');
if (!$result)
{
return false;
}
$result->autocommit(TRUE);
return $result;
}
function db_result_to_array($result)
{
$res_array = array();
for ($count=0; $row = $result->fetch_assoc(); $count++)
{
$res_array[$count] = $row;
}
return $res_array;
}
function display_status($emailid)
{
//query databse to get the current status of the logged in user
$conn=db_connect();
$query="select * from orderdet where email='".$emailid."'";
$result = @$conn->query($query);
if (!$result)
{
return false;
}
$num_orders = @$result->num_rows;
if ($num_orders== 0)
{
echo "You have not placed any order till date.";
}
$str="<table>";
for($i=0;$i<$num_orders;$i++)
{
$row=$result->fetch_assoc();
$str.="<tr><td>".$row['oid']."</td>";
$str.="<td>".$row['odt']."</td>";
$str.="<td>".$row['ddt']."</td>";
$str.="<td>".$row['amt']."</td>";
$str.="<td>".$row['raddr']."</td>";
$str.="</tr>";
}
$str.="</table>";
echo $str;
}
function generate_orderid()
{
$conn=db_connect();
$query="select * from orderdet";
$result=$conn->query($query);
$no=$result->num_rows;
if($no>0)
{
return ($no+1);
}
else
{ return 1;}
}
function get_pricep($sz)
{
$conn=db_connect();
$query="select * from photopl where size='".$sz."'";
$result=@$conn->query($query);
$row=db_result_to_array($result);
foreach ($row as $arr)
{
$pc=$arr['price'];
}
return ($pc);
}
function get_priced($ty)
{
$conn=db_connect();
$query="select * from docpl where binding='".$ty."'";
$result=$conn->query($query);
$row=db_result_to_array($result);
foreach ($row as $arr)
{
$pc=$arr['price'];
}
$pc=$row['price'];
return ($pc);
}
function filled_out($form_vars)
{
// test that each variable has a value
foreach ($form_vars as $key => $value)
{
if ((!isset($key)) || ($value == ''))
{
return false;
}
}
return true;
}
function valid_email($address)
{
// check an email address is possibly valid
if (ereg("^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $address))
{
return true;
}
else
{
return false;
}
}
function process_card()
{
// connect to payment gateway or
// use gpg to encrypt and mail or
// store in DB if you really want to
return true;
}
function register($email, $passwd,$addr,$phno)
{
// register new person with db
// return true or error message
// connect to db
$conn = db_connect();
// check if username is unique
$result = $conn->query("select * from userdet where email='".$email."'");
if (!$result) {
throw new Exception('Could not execute query');
}
if ($result->num_rows>0) {
throw new Exception('That email is already taken - go back and choose another one.');
}
// if ok, put in db
$result = $conn->query("insert into userdet values
('".$email."', sha1('".$password."'), '".$addr."', '".$phno."')");
if (!$result) {
throw new Exception('Could not register you in database - please try again later.');
}
return true;
}
// connect to db
$conn = db_connect();
if (!($_SESSION['valid_user']==$email)){
// check if username is unique
$result = $conn->query("select * from userdet
where email='".$email."'
and password = sha1('".$password."')");
if (!$result) {
throw new Exception('Could not log you in.');
}
if ($result->num_rows>0) {
return true;
} else {
throw new Exception('Could not log you in.');
}
}
}
function check_valid_user() {
// see if somebody is logged in and notify them if not
if (isset($_SESSION['valid_user'])) {
// echo "Logged in as ".$_SESSION['valid_user'].".<br />";
return true;
} else {
// they are not logged in
// echo 'Problem:';
echo 'You are not logged in.<br />';
echo '<br /><a href="signinfo.php">Login</a><br />';
return false;
}
}
function reset_password($email) {
// set password for username to a random value
// return the new password or false on failure
// get a random dictionary word b/w 6 and 13 chars in length
$new_password = "password";