Download presentation
Presentation is loading. Please wait.
Published byKristin Powell Modified over 9 years ago
1
PC SHOP by: Hussein Zahr ECE 3553: Multifarious Final Project
2
Description It’s a commercial webpage selling computer hardware. Every User has to log and create an account. There is an administrator space where the owner of the website can add products. First steps: - Connect to a database - Login Page - Make a quote
3
What is missing ? Shopping Cart More dynamic pages (Java and flash code) More Professional Look
4
How it works ? Entering.htm Userlogin.php Newuserform.htm Member ?New user ? Firstpage.htm Newconfirm.php
5
How it works ? (administrator) Adminlogin.htm Addcase.htm Case.php Adminconfirm.php
6
Mysql Database Database on my home PC Use ip:68.205.112.34 Command Prompt
7
Mysql code create table user1 ( email varchar(40), password varchar(20), fname varchar(15), lname varchar(15), address varchar(30),city varchar(30), state varchar(10), zip int, phone int); create table admin ( admin varchar (10),password varchar(10)); create table cases ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table motherboard ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table amdcpu ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table intelcpu ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table memory ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table graphiccard ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table soundcard ( brand varchar (15), model varchar (15), descript varchar (15), price int); create table hdd ( brand varchar (15), model varchar (15), descript varchar(15), price int); create table build ( scase varchar (15), smotherboard varchar (15), scpu varchar(15), smemory varchar(15), sgraphiccard varchar (15), ssoundcard varchar (15), shdd varchar (15), sprice int) ;
8
PHP CODE (add product) <?php $query = "INSERT into amdcpu( brand, model, descript, price) VALUES ( ' ".$inputbrand."','".$inputmodel."','".$inputdescription."','".$inputprice."')"; if ( !( $database = mysql_connect("68.205.112.34", "zahr","") )) { die( " could not connect to database" ); } if ( !mysql_select_db( "pcshop", $database) ) die( "could not open pcshop database" ); if (!( $result = mysql_query( $query, $database ))) { print(" could not execute query !" ); die ( mysql_error() ); } else { ?> Added Successfully Go back to Administrator Space <?php } ?>
9
PHP Code (admin confirm 1/3 ) <?php $query = "select password from admin where admin = '".$adminname."'"; if ( !( $database = mysql_connect("68.205.112.34", "zahr","") )) { die( " could not connect to database" ); } if ( !mysql_select_db( "pcshop", $database) ) die( "could not open pcshop database" ); if (!( $result = mysql_query( $query, $database ))) { print(" could not execute query !" ); die ( mysql_error() ); } ?> <?php if ( !$adminname || !$adminpass ) { fieldsblank(); die(); } function fieldsblank() { ?>
10
PHP Code (admin confirm 2/3 ) <?php } $row = mysql_fetch_row($result); $password = $row[0]; if ($password ==$adminpass){ ?> your password is correct Enter The Administrator Space What would you like to Add ? Case Motherboard AMD Processor INTEL Processor Memory Grapahic Card Sound Card
11
PHP Code (admin confirm 3/3 ) <?php } else { ?> you have entered a Wrong Password Please enter the correct password <?php } ?>
12
PHP code (display parts) <? $query = "SELECT * FROM amdcpu"; if ( !( $database = mysql_connect("68.205.112.34", "zahr","") )) { die( " could not connect to database" ); } if ( !mysql_select_db( "pcshop", $database) ) die( "could not open pcshop database" ); if (!( $result = mysql_query( $query, $database ))) { print(" could not execute query !" ); die ( mysql_error() ); } while ($val = mysql_fetch_array($result)){ $brand = $val["brand"]; $model = $val["model"]; $descript = $val["descript"]; $price = $val["price"]; print ( " $brand $model $descript $price "); }?>
13
PHP code (New User Confirmation) <?php $query = "INSERT INTO user1 ( email, password, fname, lname, address, city, state,zip, phone) VALUES ( ' ".$email."','".$password."','".$fname."','".$lname."','".$address."','".$city."','".$state."','".$zip."','".$phone."')"; if ( !( $database = mysql_connect("68.205.112.34", "zahr","") )) die( " could not connect to database" ); if ( !mysql_select_db( "pcshop", $database ) ) die( "could not open pcshop database" ); if (!( $result = mysql_query( $query, $database ))) { print(" could not execute query !" ); die ( mysql_error() ); } if (!$email || !$password || !$fname || !$lname || !$address || !$city || !$state || !$zip || !$phone) { fieldsblank(); die();} function fieldsblank() {print( "Please fill all cases remaining blank"); } if ( !ereg( "^\([0-9]{3}\)[0-9]{3}-[0-9]{4}$",$phone)){ print( "Invalid phone number Phone number should be in the form (XXX)XXX-XXXX Reload the form page and correct the error."); die();} ?> Welcome <?php print( "$fname" ); print(" "); print( "$lname"); ?>
14
PHP Code (user login) <?php $query = "select email from user1 where password = '".$userpassword."'"; if ( !( $database = mysql_connect("68.205.112.34", "zahr","") )) die( " could not connect to database" ); if ( !mysql_select_db( "pcshop", $database ) ) die( "could not open pcshop database" ); if (!( $result = mysql_query( $query, $database ))) { print(" could not execute query !" ); die ( mysql_error() ); } if (!$email || !$userpassword){ fieldsblank(); die();} function fieldsblank(){ print( "Please fill all cases remaining blank"); } $row = mysql_fetch_row($result); $email = $row[0]; if (!($email ==$useremail)) { ?> Welcome Dear Member PCSHOP TEAM is happy to see you again Main page <?php} else{ ?> Your Login parameters are incorrect, Please check and try again ! <?php} ?>
15
Frames code 2 Frames : left and top controlled by a main frame. Both frames are targetting the mainframe.htm Code
16
Demontration Log: my.fit.edu/~hzahr/pcshop
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.