NoteOnMe博客平台搭建
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

95 行
2.3 KiB

3 年前
  1. <?php
  2. require_once "pdo.php";
  3. session_start();
  4. if ( isset($_POST['name']) && isset($_POST['password'])
  5. ) {
  6. if (strlen($_POST['name']) < 1 ||
  7. strlen($_POST['password']) < 1) {
  8. $_SESSION['error'] = '输入不能为空';
  9. header( 'Location: signup.php' ) ;
  10. return;
  11. }
  12. $sql = "INSERT INTO users (name, password)
  13. VALUES (:name, :password)";
  14. $stmt = $pdo->prepare($sql);
  15. try{
  16. $stmt->execute(array(
  17. ':name' => $_POST['name'],
  18. ':password' => $_POST['password']));
  19. }catch (Exception $e) {
  20. $_SESSION['error'] = '用户已存在';
  21. header( 'Location: signup.php' ) ;
  22. return;
  23. }
  24. $_SESSION['success'] = 'Record Added';
  25. header( 'Location: index.php' ) ;
  26. return;
  27. }
  28. ?>
  29. <html><head>
  30. <script src="js/jquery.min.js"></script>
  31. <script src="js/bootstrap.min.js"></script>
  32. <script src="js/setting.js"></script>
  33. <meta charset="utf-8"/>
  34. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  35. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  36. <script src="js/jquery.singlePageNav.min.js"></script>
  37. <link rel="stylesheet" type="text/css" href="css/templatemo-style.css?t={{time()}}">
  38. <style type="text/css">
  39. .kongxin{
  40. font-size: 40px;
  41. text-shadow: 0 0 2px black;
  42. color: white;
  43. }
  44. </style>
  45. </head><body>
  46. <div class="container">
  47. <section class="col-md-12 content" id="home">
  48. <div class="col-lg-12 col-md-12 content-item content-item-1 background" style='text-align:center;'>
  49. <h1 class="main-title text-center dark-blue-text"> NEW JOURNEY...</h1><br/>
  50. <?php
  51. if ( isset($_SESSION['error']) ) {
  52. echo '<p style="color:red">'.$_SESSION['error']."</p>\n";
  53. unset($_SESSION['error']);
  54. }
  55. ?>
  56. <form method="POST" action="signup.php" class="contact-form">
  57. <div class="form-group">
  58. <label for="name">用户名</label>
  59. <input type="text" name="name" ><br/>
  60. </div>
  61. <div class="form-group">
  62. <label for="id_1723" >密码 </label>
  63. <input type=text type="password" name="password" id="id_1723"><br/>
  64. </div>
  65. <div class="form-group">
  66. <input type="submit" class="btn no-bg btn-contact" value="确定">
  67. <a href="index.php">取消</a>
  68. </div>
  69. <br/>
  70. </form>
  71. </div>
  72. </section>
  73. </div>
  74. <div class="text-center footer">
  75. <div class="container"> NOTEBOOK</div>
  76. </div>
  77. </body>
  78. </html>