Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE>
- <html>
- <head>
- <title>Echobuild</title>
- <link rel="stylesheet" href="http://demos.jquerymobile.com/1.4.5/css/themes/default/jquery.mobile-1.4.5.min.css" />
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile.structure-1.4.5.min.css" />
- <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
- <script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.js"></script>
- </head>
- <div id="page1" data-role="page">
- <div data-role="header">Welcome to Echobuild!</div>
- <a href="#page2" data-transition="slide" class="ui-btn">Login</a>
- <a href="#page3" data-transition="slide" class="ui-btn">Register</a>
- <div data-role="footer">Copyrigth 2016</div>
- </div>
- <div id="page2" data-role="page">
- <div data-role="header">Login</div>
- <?PHP
- if($_POST){
- $Username = $_POST['Username'];
- $Password = $_POST['Password'];
- try {
- $host = '127.0.0.1';
- $dbname = 'echobuild';
- $user = 'root';
- $pass = '';
- # MySQL with PDO_MYSQL
- $DBH = new PDO("mysql:host=$host;dbname=$dbname;port=3307", $user, $pass);
- $sql = "select * from users where Username = ? and Password = ?";
- $sth = $DBH->prepare($sql);
- $sth->bindParam(1,$Username);
- $sth->bindParam(2,$Password);
- $sth->execute();
- $check = $sth->fetch(PDO::FETCH_ASSOC);
- $message = '';
- if(!empty($check)){
- $Username = $check['Username'];
- $message = 'Loggin in!';
- }else{
- $message = 'Sorry, details incorrect';
- }
- if ($sth->rowCount() > 0){
- $Id = $rec['Id'];
- $AccType = $rec['AccType'];
- if($AccType == 'Customer'){
- echo '<script>window.location="page4" </script>';
- die;
- }
- if($AccType == 'Staff'){
- echo '<script>window.location="page5" </script>';
- die;
- }
- if($AccType == 'Delivery'){
- echo '<script>window.location="page6" </script>';
- die;
- }
- if($AccType == 'Admin'){
- echo '<script>window.location="page7" </script>';
- die;
- }
- if($Username||$Password == ''){
- echo '<script>alert="Please enter a valid username and password!" </script>';
- }
- }
- }catch(PDOException $e) {echo 'Error';}
- }
- ?>
- <form method="post" action=" <?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" >
- <label for="text-1">Username:</label>
- <input type="text" name="Username" id="Username" value="">
- <label for="text-2">Password:</label>
- <input type="password" name="Password" id="Password" value="">
- <input type="submit" value="Login">
- </form>
- </div>
- <div id="page3" data-role="page">
- <div data-role="Register">Register Page</div>
- <?php
- if($_POST){
- $firstname = $_POST['FirstName'];
- $lastname = $_POST['LastName'];
- $address = $_POST['Address'];
- $phone = $_POST['Phone'];
- $acctype = $_POST['AccType'];
- $email = $_POST['Email'];
- $username = $_POST['Username'];
- $password = $_POST['Password'];
- $password1 = $_POST['Password1'];
- try {
- $host = '127.0.0.1';
- $dbname = 'echobuild';
- $user = 'root';
- $pass = '';
- # MySQL with PDO_MYSQL
- $DBH = new PDO("mysql:host=$host;dbname=$dbname;port=3307", $user, $pass);
- $sql = "INSERT INTO `Users` (`FirstName`, `LastName`, `Address`, `Phone`, `AccType`, `Email`, `Username`, `Password`, `Password1`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);";
- $sth = $DBH->prepare($sql);
- $sth->bindParam(1, $firstname, PDO::PARAM_INT);
- $sth->bindParam(2, $lastname, PDO::PARAM_INT);
- $sth->bindParam(3, $address, PDO::PARAM_INT);
- $sth->bindParam(4, $phone, PDO::PARAM_INT);
- $sth->bindParam(5, $acctype, PDO::PARAM_INT);
- $sth->bindParam(6, $email, PDO::PARAM_INT);
- $sth->bindParam(7, $username, PDO::PARAM_INT);
- $sth->bindParam(8, $password, PDO::PARAM_INT);
- $sth->bindParam(9, $password1, PDO::PARAM_INT);
- $sth->execute();
- }catch(PDOException $e) {echo 'Error';}
- echo '<script>alert="You are now register!" </script>';
- }
- ?>
- <form method="post" action=" <?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" >
- <label for="text-3">First Name:</label>
- <input type="text" data-clear-btn="true" name="FirstName" id="FirstName" value="">
- <label for="text-4">Last Name:</label>
- <input type="text" data-clear-btn="true" name="LastName" id="LastName" value="">
- <label for="text-5">Address:</label>
- <input type="text" data-clear-btn="true" name="Address" id="Address" value="">
- <label for="text-6">Phone:</label>
- <input type="text" data-clear-btn="true" name="Phone" id="Phone" value="">
- <label for="text-7">Account Type:</label>
- <input type="text" data-clear-btn="true" name="AccType" id="AccType" value="">
- <label for="text-8">Email:</label>
- <input type="text" data-clear-btn="true" name="Email" id="Email" value="">
- <label for="text-9">Username:</label>
- <input type="text" data-clear-btn="true" name="Username" id="Username" value="">
- <label for="text-10">Password:</label>
- <input type="password" data-clear-btn="true" name="Password" id="Password" value="">
- <label for="text-11">Confirm Password:</label>
- <input type="password" data-clear-btn="true" name="Password1" id="Password1" value="">
- <input type="submit" name="submit" value="Register" class="ui-btn ui-corner-all">
- </form>
- </div>
- <div id="page4" data-role="page">
- <div data-role="Customer">Customer Page</div>
- <?php
- session_start();
- $_SESSION['Username'] = '';
- echo 'You are logged!' . session_id();
- ?>
- <a href="#page8" data-transition="slide" class="ui-btn">Logout</a>
- </div>
- <div id="page5" data-role="page">
- <div data-role="Staff">Staff Page</div>
- <?php
- session_start();
- $_SESSION['Username'] = '';
- echo 'You are logged!' . session_id();
- ?>
- <a href="#page8" data-transition="slide" class="ui-btn">Logout</a>
- </div>
- <div id="page6" data-role="page">
- <div data-role="Delivery">Delivery Page</div>
- <?php
- session_start();
- $_SESSION['Username'] = '';
- echo 'You are logged!' . session_id();
- ?>
- <a href="#page8" data-transition="slide" class="ui-btn">Logout</a>
- </div>
- <div id="page7" data-role="page">
- <div data-role="Admin">Admin Page</div>
- <?php
- session_start();
- $_SESSION['Username'] = '';
- echo 'You are logged!' . session_id();
- ?>
- <a href="#page8" data-transition="slide" class="ui-btn">Logout</a>
- </div>
- <div id="page8" data-role="page">
- <div data-role="Logout">Logout Page</div>
- <?php
- session_start();
- if(session_destroy()){
- header("Location: main.php");
- }
- ?>
- </div>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement