Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); // Starting Session
- $error=''; // Variable To Store Error Message
- if (isset($_POST['submit'])) {
- if (empty($_POST['username']) || empty($_POST['password'])) {
- $error = "Username or Password is invalid";
- }
- else
- {
- // Define $username and $password
- $username=$_POST['username'];
- $password=$_POST['password'];
- define('DBHOST', 'localhost');
- define('DBUSER', 'root');
- define('DBPASS', '');
- define('DBNAME', 'tastyfood');
- // Create connection
- $conn = new mysqli(DBHOST, DBUSER, DBPASS, DBNAME);
- $sql = "INSERT INTO `users` (username, password) VALUES ('$username', '$password')";
- query($sql);
- mysql_close($conn); // Closing Connection
- }
- } ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>
- Food by Tomas
- </title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link href="res/reset.css" rel="stylesheet">
- <link href="res/stylesheet.css" rel="stylesheet">
- <link href="res/responsive.css" rel="stylesheet">
- <!-- Latest compiled and minified bootstrap-CSS -->
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
- <link rel="stylesheet" href="res/loginstyle.css" >
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <script>
- /* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */
- function myFunction() {
- var x = document.getElementById("myTopnav");
- if (x.className === "topnav") {
- x.className += " responsive";
- } else {
- x.className = "topnav";
- }
- }
- </script>
- </head>
- <body>
- <ul class="topnav" id="myTopnav">
- <li class="title"> Tasty Food </li>
- <li><a class = "" href="index.html">Startsida</a></li>
- <li><a href="recipes.html">Recept</a></li>
- <li><a href="calendar.html">Kalender</a></li>
- <li class="login"><a class="active" href="login.html">Login</a></li>
- <li class="icon">
- <a href="javascript:void(0);" onclick="myFunction()">☰</a>
- </li>
- </ul>
- <div class="container">
- <form class="form-signin" method="POST">
- <?php if(isset($smsg)){ ?><div class="alert alert-success" role="alert"> <?php echo $smsg; ?> </div><?php } ?>
- <?php if(isset($fmsg)){ ?><div class="alert alert-danger" role="alert"> <?php echo $fmsg; ?> </div><?php } ?>
- <h2 class="form-signin-heading">Please Register</h2>
- <div class="input-group">
- <span class="input-group-addon" id="basic-addon1">@</span>
- <input type="text" name="username" class="form-control" placeholder="Username" required>
- </div>
- <label for="inputPassword" class="sr-only">Password</label>
- <input type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
- <button class="btn btn-lg btn-primary btn-block" type="submit">Register</button>
- <a class="btn btn-lg btn-primary btn-block" href="login.php">Login</a>
- </form>
- </div>
- <div id = "footer">
- <p> A footer</p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement