Advertisement
Guest User

Untitled

a guest
Sep 13th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.05 KB | None | 0 0
  1. <?php
  2.    
  3.     session_start(); // Starting Session
  4. $error=''; // Variable To Store Error Message
  5. if (isset($_POST['submit'])) {
  6. if (empty($_POST['username']) || empty($_POST['password'])) {
  7. $error = "Username or Password is invalid";
  8. }
  9. else
  10. {
  11. // Define $username and $password
  12. $username=$_POST['username'];
  13. $password=$_POST['password'];
  14.  
  15. define('DBHOST', 'localhost');
  16. define('DBUSER', 'root');
  17. define('DBPASS', '');
  18. define('DBNAME', 'tastyfood'); 
  19.  
  20. // Create connection
  21. $conn = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
  22.  
  23. $sql = "INSERT INTO `users` (username, password) VALUES ('$username', '$password')";
  24. query($sql);
  25.        
  26. mysql_close($conn); // Closing Connection
  27. }
  28. } ?>
  29.  
  30. <!DOCTYPE html>
  31. <html lang="en">
  32. <head>
  33.     <title>
  34.         Food by Tomas
  35.     </title>
  36.     <meta charset="utf-8">
  37.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  38.     <link href="res/reset.css" rel="stylesheet">
  39.     <link href="res/stylesheet.css" rel="stylesheet">
  40.     <link href="res/responsive.css" rel="stylesheet">
  41.     <!-- Latest compiled and minified bootstrap-CSS -->
  42.     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
  43.     <link rel="stylesheet" href="res/loginstyle.css" >
  44.     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  45.  
  46.    
  47.     <script>
  48.     /* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
  49.         function myFunction() {
  50.             var x = document.getElementById("myTopnav");
  51.             if (x.className === "topnav") {
  52.             x.className += " responsive";
  53.             } else {
  54.             x.className = "topnav";
  55.             }
  56.         }
  57.     </script>
  58.    
  59. </head>
  60. <body>
  61.          <ul class="topnav" id="myTopnav">
  62.             <li class="title"> Tasty Food </li>
  63.             <li><a class = "" href="index.html">Startsida</a></li>
  64.             <li><a href="recipes.html">Recept</a></li>
  65.             <li><a href="calendar.html">Kalender</a></li>
  66.             <li class="login"><a class="active" href="login.html">Login</a></li>
  67.            
  68.             <li class="icon">
  69.                 <a href="javascript:void(0);" onclick="myFunction()">&#9776;</a>
  70.             </li>
  71.         </ul>
  72.        
  73.         <div class="container">
  74.             <form class="form-signin" method="POST">
  75.            
  76.             <?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
  77.             <?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>
  78.            
  79.             <h2 class="form-signin-heading">Please Register</h2>
  80.             <div class="input-group">
  81.                 <span class="input-group-addon" id="basic-addon1">@</span>
  82.                 <input type="text" name="username" class="form-control" placeholder="Username" required>
  83.             </div>
  84.                 <label for="inputPassword" class="sr-only">Password</label>
  85.                 <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
  86.                 <button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
  87.                 <a class="btn btn-lg btn-primary btn-block" href="login.php">Login</a>
  88.             </form>
  89.         </div>
  90.            
  91.         <div id = "footer">
  92.             <p> A footer</p>
  93.         </div> 
  94. </body>
  95. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement