Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- registration.php
- <html>
- <head>
- <title>Registration</title>
- </head>
- <body>
- <h2>Register</h2>
- <form method="post" action="regProcess.php">
- <label>Username</label>
- <input type="text" name="username">
- <label>Email</label>
- <input type="email" name="email">
- <label>Password</label>
- <input type="password" name="password">
- <button type="submit" class="btn" name="register_btn">Register</button>
- </form>
- </body>
- </html>
- dbconn.php
- <?php
- $con = mysqli_connect("localhost","root","","crud");
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- else
- {
- //echo "Database Connection Successfull";
- }
- ?>
- regProcess.php
- <html>
- <head>
- <title>Login</title>
- </head>
- <body>
- <h2>Register</h2>
- <form method="post" action="regProcess.php">
- <label>Username</label>
- <input type="text" name="username">
- <label>Password</label>
- <input type="password" name="password">
- <button type="submit" class="btn" name="login_btn">Login</button>
- </form>
- </body>
- </html>
- login.php
- <html>
- <head>
- <title>Login</title>
- </head>
- <body>
- <h2>Register</h2>
- <form method="post" action="loginProcess.php">
- <label>Username</label>
- <input type="text" name="username">
- <label>Password</label>
- <input type="password" name="password">
- <button type="submit" class="btn" name="login_btn">Login</button>
- </form>
- </body>
- </html>
- loginProcess.php
- <?php
- require('dbconn.php');
- if (isset($_POST['login_btn'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $query = "SELECT * FROM user WHERE username='$username' AND password='$password'";
- $results = mysqli_query($con, $query);
- if (mysqli_num_rows($results) == 1) {
- echo "$username Login Successfully";
- }
- else
- {
- echo "Login faild";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment