Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['register'])) {
- # Register-button was clicked
- $createsql1="INSERT INTO cruduser(id,username,password) VALUES
- ('','$uname','$pwd')";
- if (mysqli_query($con,$createsql1)) {
- echo "Insert Successful in Table cruduser";
- mysqli_close($con);
- //Redirect because we need to consider the post request from crudadd.php
- header( 'Location: crudaddusr.php' ) ;
- //include ("crudadd.php");
- }
- else
- {
- die(mysqli_error($con));
- }
- }
- if (isset($_POST['login'])) {
- # Login-button was clicked
- session_start();
- $SESSION['suname']=$uname;
- $SESSION['spwd']=$pwd;
- if ($uname=='admin' && $pwd=='admin') {
- include('crudview.php');
- }
- else
- {
- header( "Location: crudeditusr.php?suname=$uname&spwd=$pwd");
- }
- }
- mysqli_close($con);
- }
- ?>
- <!--DocType HTML -->
- <! bootstrap link is downloaded from bootstrapcdn.com for css and js -->
- <! col-mod-6 col-mod-offset are bootstrap related-->
- <HTML>
- <head>
- <title>"Add records in CRUD Table"</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="row">
- <form method="post" class="form-horizontal col-mod-6 col-mod-offset-3">
- <h2>Create The table CRUD</h2>
- <div class="form-group">
- <label for="input" class="col-sm-2 control-label">Username : </label>
- <div class="col-sm-10">
- <input type="text" name="uname" required pattern="^[A-Za-z0-9]+" class="form-control" id="input1" placeholder="Username"/>
- </div>
- </div>
- <div class="form-group">
- <label for="input" class="col-sm-2 control-label">Password: </label>
- <div class="col-sm-10">
- <input type="password" name="pwd" required pattern="^[A-Za-z0-9]+" class="form-control" id="input1" value='<?php if (isset($password_error)) echo $password_error; ?>' placeholder="Password"/>
- <!--<span class="text-danger"><?php if (isset($password_error)) echo $password_error; ?></span>-->
- </div>
- </div>
- <div class="form-group">
- <label for="input" class="col-sm-2 control-label">Confirm Password : </label>
- <div class="col-sm-10">
- <input type="password" name="cpwd" required pattern="^[A-Za-z0-9]+" class="form-control" id="input1" placeholder="Confirm Password"/>
- <span class="text-danger"><?php if (isset($cpassword_error)) echo $cpassword_error; ?></span>
- </div>
- </div>
- <div class="row">
- <div class="col-mod-6 col-mod-offset-3">
- <button id="submit1" name="register" class="btn btn-primary pull-right">Register</button>
- <button id="submit2" name="login" class="btn btn-secondary pull-right">Login</button>
- </div>
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement