Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. if (isset($_POST['register'])) {
  2. # Register-button was clicked
  3.  
  4.  
  5. $createsql1="INSERT INTO cruduser(id,username,password) VALUES
  6. ('','$uname','$pwd')";
  7.  
  8. if (mysqli_query($con,$createsql1)) {
  9. echo "Insert Successful in Table cruduser";
  10. mysqli_close($con);
  11. //Redirect because we need to consider the post request from crudadd.php
  12. header( 'Location: crudaddusr.php' ) ;
  13. //include ("crudadd.php");
  14. }
  15. else
  16. {
  17. die(mysqli_error($con));
  18. }
  19. }
  20. if (isset($_POST['login'])) {
  21. # Login-button was clicked
  22. session_start();
  23. $SESSION['suname']=$uname;
  24. $SESSION['spwd']=$pwd;
  25. if ($uname=='admin' && $pwd=='admin') {
  26. include('crudview.php');
  27. }
  28. else
  29. {
  30. header( "Location: crudeditusr.php?suname=$uname&spwd=$pwd");
  31. }
  32. }
  33. mysqli_close($con);
  34. }
  35. ?>
  36. <!--DocType HTML -->
  37. <! bootstrap link is downloaded from bootstrapcdn.com for css and js -->
  38. <! col-mod-6 col-mod-offset are bootstrap related-->
  39. <HTML>
  40. <head>
  41. <title>"Add records in CRUD Table"</title>
  42. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  43. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  44. </head>
  45. <body>
  46. <div class="container">
  47. <div class="row">
  48. <form method="post" class="form-horizontal col-mod-6 col-mod-offset-3">
  49. <h2>Create The table CRUD</h2>
  50. <div class="form-group">
  51. <label for="input" class="col-sm-2 control-label">Username : </label>
  52. <div class="col-sm-10">
  53. <input type="text" name="uname" required pattern="^[A-Za-z0-9]+" class="form-control" id="input1" placeholder="Username"/>
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <label for="input" class="col-sm-2 control-label">Password: </label>
  58. <div class="col-sm-10">
  59. <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"/>
  60. <!--<span class="text-danger"><?php if (isset($password_error)) echo $password_error; ?></span>-->
  61. </div>
  62. </div>
  63. <div class="form-group">
  64. <label for="input" class="col-sm-2 control-label">Confirm Password : </label>
  65. <div class="col-sm-10">
  66. <input type="password" name="cpwd" required pattern="^[A-Za-z0-9]+" class="form-control" id="input1" placeholder="Confirm Password"/>
  67. <span class="text-danger"><?php if (isset($cpassword_error)) echo $cpassword_error; ?></span>
  68. </div>
  69. </div>
  70. <div class="row">
  71.  
  72. <div class="col-mod-6 col-mod-offset-3">
  73. <button id="submit1" name="register" class="btn btn-primary pull-right">Register</button>
  74. <button id="submit2" name="login" class="btn btn-secondary pull-right">Login</button>
  75. </div>
  76. </div>
  77. </form>
  78. </body>
  79. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement