shop.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php session_start(); if (isset($_SESSION["username"])) { $username = $_SESSION["username"]; session_write_close(); } else { // since the username is not set in session, the user is not-logged-in // he is trying to access this page unauthorized // so let's clear all session variables and redirect him to index session_unset(); session_write_close(); $url = "./index.php"; header("Location: $url"); } ?> |
member.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
<?php namespace Phppot; class Member { private $ds; function __construct() { require_once __DIR__ . '/../lib/DataSource.php'; $this->ds = new DataSource(); } /** * to check if the username already exists * * @param string $username * @return boolean */ public function isUsernameExists($username) { $query = 'SELECT * FROM tbl_member where username = ?'; $paramType = 's'; $paramValue = array( $username ); $resultArray = $this->ds->select($query, $paramType, $paramValue); $count = 0; if (is_array($resultArray)) { $count = count($resultArray); } if ($count > 0) { $result = true; } else { $result = false; } return $result; } /** * to check if the email already exists * * @param string $email * @return boolean */ public function isEmailExists($email) { $query = 'SELECT * FROM tbl_member where email = ?'; $paramType = 's'; $paramValue = array( $email ); $resultArray = $this->ds->select($query, $paramType, $paramValue); $count = 0; if (is_array($resultArray)) { $count = count($resultArray); } if ($count > 0) { $result = true; } else { $result = false; } return $result; } /** * to signup / register a user * * @return string[] registration status message */ public function registerMember() { $isUsernameExists = $this->isUsernameExists($_POST["username"]); $isEmailExists = $this->isEmailExists($_POST["email"]); if ($isUsernameExists) { $response = array( "status" => "error", "message" => "Username already exists." ); } else if ($isEmailExists) { $response = array( "status" => "error", "message" => "Email already exists." ); } else { if (! empty($_POST["signup-password"])) { // PHP's password_hash is the best choice to use to store passwords // do not attempt to do your own encryption, it is not safe $hashedPassword = password_hash($_POST["signup-password"], PASSWORD_DEFAULT); } $query = 'INSERT INTO tbl_member (username, password, email) VALUES (?, ?, ?)'; $paramType = 'sss'; $paramValue = array( $_POST["username"], $hashedPassword, $_POST["email"] ); $memberId = $this->ds->insert($query, $paramType, $paramValue); if (! empty($memberId)) { echo "successfully"; } } } public function getMember($username) { $query = 'SELECT * FROM tbl_member where username = ?'; $paramType = 's'; $paramValue = array( $username ); $memberRecord = $this->ds->select($query, $paramType, $paramValue); return $memberRecord; } /** * to login a user * * @return string */ public function loginMember() { $memberRecord = $this->getMember($_POST["username"]); $loginPassword = 0; if (! empty($memberRecord)) { if (! empty($_POST["login-password"])) { $password = $_POST["login-password"]; } $hashedPassword = $memberRecord[0]["password"]; $loginPassword = 0; if (password_verify($password, $hashedPassword)) { $loginPassword = 1; } } else { $loginPassword = 0; } if ($loginPassword == 1) { // login sucess so store the member's username in // the session session_start(); $_SESSION["username"] = $memberRecord[0]["username"]; session_write_close(); $url = "./home.php"; header("Location: $url"); } else if ($loginPassword == 0) { $loginStatus = "Invalid username or password."; return $loginStatus; } } } |
accessarios1.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
<html> <head> <title> accessories1 </title> <link rel="stylesheet" href="css/accessories (1).css" > </head> <body> <div class="div1"> <font class="f1">E</font> <font class="f2">shop </font> <input class="form1" type="placeholder" > <input class="form2" type="button" value="Search" > <font class="f3" ><a href="user-registration.php" style="text-decoration:none;color:white;">Sign up</a></font> <font class="f4" ><a href="logout.php" style="text-decoration:none;color:white;">Log out </a></font> <font class="f5" ><a href="http://localhost/myphp/FYP/order.php" style="text-decoration:none;color:white;">Order Now</a></font> <br><img src="images/download.png" class="img1"> </div> <div style="width:100%;height:8%;background-color:orange;margin-top:-21px;"> <p class="p2"><a href="http://localhost/myphp/FYP/final year project.php" style="text-decoration:none;color:white;">Home</a>    <a href="http://localhost/myphp/FYP/mobile.php" style="text-decoration:none;color:white;">Mobile</a>     <a href="http://localhost/myphp/FYP/laptop.php" style="text-decoration:none;color:white;">Laptop</a>     <a href="http://localhost/myphp/FYP/printer.php" style="text-decoration:none;color:white;">Printer</a>     <a href="http://localhost/myphp/FYP/pc.php" style="text-decoration:none;color:white;">PC</a>     <a href="http://localhost/myphp/FYP/led.php" style="text-decoration:none;color:white;">LED</a>     <a href="http://localhost/myphp/FYP/Accessories.php" style="text-decoration:none;color:white;">Accessories</a>     <a href="http://localhost/myphp/FYP/watches.php" style="text-decoration:none;color:white;">Watches</a>     <a href="http://localhost/myphp/FYP/ipad.php" style="text-decoration:none;color:white;">Ipad</a> </p> </div> <div class="div2"> <img class="img2" src="images/accessories1.jpg"> <div style="width:200px;height:60px;background-color: green;border-radius: 30px;margin-left: 550px;margin-top:30px;"><a href="http://localhost/myphp/FYP/order.php" style="text-decoration: none;"><p class="p1">Shop Now</p></a></div> <p style="margin-left:100px;margin-top:-500px;"><font style="font-size:22px;font-weight:bold;">Specifications</font><br><br>- Conditions <br>- Layout Type<br>- Color <br>- Backlit <br>- Numpad <br>- Warranty<br>- Brand <p> <p style="margin-left:1020px;margin-top:-170px;"><font style="font-size:22px;font-weight:bold;">Specifications</font><br><br>- 100% brand new<br>- US<br>- Black<br>- Yes<br>- Yes<br>- 10 Days<br>- Dell <p> </div> <div class="div13"> <p style="margin-left: 30px;font-size:22px;color:white;padding-top: 20px;font-weight:bold; "> Top Brands </p> <p style="margin-left: 90px;font-size:18px;color:white;font-weight:bold;"> Mobile </p> <p style="margin-left: 90px;font-size:12px;color:white;"> Samsung </p> <p style="margin-left: 90px;font-size:12px;color:white;"> Iphone </p> <p style="margin-left: 90px;font-size:12px;color:white;"> Huawei </p> <p style="margin-left: 90px;font-size:12px;color:white;"> Infinix </p> <p style="margin-left: 90px;font-size:12px;color:white;"> Nokia </p> <p style="margin-left:210px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">Laptop </p> <p style="margin-left:210px;font-size:12px;color:white;"> Lenovo </p> <p style="margin-left:210px;font-size:12px;color:white;"> Hp </p> <p style="margin-left:210px;font-size:12px;color:white;"> Acer </p> <p style="margin-left:210px;font-size:12px;color:white;"> Dell </p> <p style="margin-left:210px;font-size:12px;color:white;"> Apple </p> <p style="margin-left:340px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">LED </p> <p style="margin-left:340px;font-size:12px;color:white;"> Toshiba </p> <p style="margin-left:340px;font-size:12px;color:white;"> LG </p> <p style="margin-left:340px;font-size:12px;color:white;"> Samsung </p> <p style="margin-left:340px;font-size:12px;color:white;"> Panasonic </p> <p style="margin-left:340px;font-size:12px;color:white;"> Song </p> <p style="margin-left:450px;font-sicze:18px;color:white;font-weight:bold;margin-top:-174px;">Camera </p> <p style="margin-left:450px;font-size:12px;color:white;"> LG </p> <p style="margin-left:450px;font-size:12px;color:white;"> Panasonic </p> <p style="margin-left:450px;font-size:12px;color:white;"> Sony</p> <p style="margin-left:450px;font-size:12px;color:white;"> Samsung </p> <p style="margin-left:450px;font-size:12px;color:white;"> Apple </p> <p style="margin-left:590px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">Watches </p> <p style="margin-left:590px;font-size:12px;color:white;"> Timex Expedition</p> <p style="margin-left:590px;font-size:12px;color:white;"> Hamilton khaki </p> <p style="margin-left:590px;font-size:12px;color:white;"> Suunto Core</p> <p style="margin-left:590px;font-size:12px;color:white;"> Tissot </p> <p style="margin-left:590px;font-size:12px;color:white;"> Casio </p> <p style="margin-left:760px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">Printer</p> <p style="margin-left:760px;font-size:12px;color:white;"> Lenovo </p> <p style="margin-left:760px;font-size:12px;color:white;"> Hp </p> <p style="margin-left:760px;font-size:12px;color:white;"> Acer </p> <p style="margin-left:760px;font-size:12px;color:white;"> Dell </p> <p style="margin-left:760px;font-size:12px;color:white;"> Apple </p> <p style="margin-left:880px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">Ipad</p> <p style="margin-left:880px;font-size:12px;color:white;"> Lenovo</p> <p style="margin-left:880px;font-size:12px;color:white;"> Hp </p> <p style="margin-left:880px;font-size:12px;color:white;"> Acer </p> <p style="margin-left:880px;font-size:12px;color:white;"> Dell </p> <p style="margin-left:880px;font-size:12px;color:white;"> Apple </p> <p style="margin-left:990px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">Accessories</p> <p style="margin-left:990px;font-size:12px;color:white;"> Lenovo</p> <p style="margin-left:990px;font-size:12px;color:white;"> Hp </p> <p style="margin-left:990px;font-size:12px;color:white;"> Acer </p> <p style="margin-left:990px;font-size:12px;color:white;"> Dell </p> <p style="margin-left:9900px;font-size:12px;color:white;"> Apple </p> <p style="margin-left:1140px;font-size:18px;color:white;font-weight:bold;margin-top:-174px;">Customer Services</p> <a href="http://localhost/myphp/FYP/contact%20us.php" style="text-decoration: none;"><p style="margin-left:1140px;font-size:12px;color:white;"> contact us</p> <p style="margin-left:1140px;font-size:12px;color:white;"> About us</p> <p style="margin-left:1140px;font-size:12px;color:white;"> Delivery policy</p> <p style="margin-left:1140px;font-size:12px;color:white;"> Customer feedback</p> </a> </div> </body> </html> |