Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <html>
  2. <head>
  3. <title>Registration page</title>
  4. <style type="text/css">
  5. body {
  6. font-family: Tahoma;
  7. font-size: 13px;
  8. background: #9999BB;
  9. }
  10.  
  11. #container {
  12. border: 1px red solid;
  13. margin: 0px auto;
  14. width: 800px;
  15. }
  16.  
  17. #head {
  18. border: 1px cyan solid;
  19. height: 100px;
  20. }
  21.  
  22. #left {
  23. border: 1px blue solid;
  24. width: 196px;
  25. height: 200px;
  26. float: left;
  27. display: inline;
  28. }
  29.  
  30. #main {
  31. border: 1px green solid;
  32. float: right;
  33. width: 600px;
  34. height: 400px;
  35. }
  36.  
  37. #foot {
  38. border: 1px yellow solid;
  39. height: 40px;
  40. clear: both;
  41. }
  42. </style>
  43.  
  44. </head>
  45.  
  46. <body>
  47. <div id="container">
  48. <div id="head">
  49. This is a header
  50. </div>
  51.  
  52. <div id="left">
  53. Some menuz
  54. </div>
  55.  
  56. <div id="main">
  57. <!-- first page -->
  58. <div>
  59. <?php
  60. // function which makes the db connection
  61. function dbconnect($dbaddr = '127.0.0.1', $user = 'root', $pass = 'abc123') {
  62. $conn = mysql_connect($dbaddr, $user, $pass);
  63. if (!$conn) die("Couldn't connect to database!");
  64. else return $conn;
  65. }
  66.  
  67. // function which executes the query
  68. function execquery($conn, $sql) {
  69. return mysql_query($sql, $conn);
  70. }
  71.  
  72. if (count($_POST) > 0) { // if the $_POST array has values in it, it means it's come from your form.
  73. $name = $_POST['name'];
  74. $age = $_POST['name'];
  75. $gender = $_POST['gender'];
  76. $username = $_POST['username'];
  77. $password = md5($_POST['password']);
  78.  
  79. if (count($_FILES) > 0) { // if $_FILES has values then there was an image upload
  80. $permpath = "images/uploads/". basename($_FILES['inputfile']['name']);
  81. if (move_uploaded_file($_FILES['inputfile']['tmp_name'], $permpath)) {
  82. echo "Image ". $_FILES['inputfile']['name'] ." uploaded successfully.";
  83. } else {
  84. echo "There was an error uploading your image.";
  85. $permpath = "";
  86. }
  87. }
  88.  
  89. // db stuff starts here. first establish a db connection with dbconnect().
  90. $conn = dbconnect();
  91. // build the sql query
  92. $sql = "insert into users (name, age, gender, username, password, image) values (". $name .", ". $age .", ". $gender .", ". $username .", ". $password .", ". $permpath .";";
  93.  
  94. // attempt to execute the query and print success/failure messages
  95. if (execquery($conn, $sql)) echo "User created successfully!";
  96. else echo "There was an error creating the user account; please try again.";
  97.  
  98. } else {
  99. // if the $_POST array is empty then you know there was an error, or the request didn't come from your form
  100. echo "There was an error processing your registration. Please go back and try the FUCK again.";
  101. }
  102. ?>
  103. </div>
  104. </div>
  105.  
  106. <div id="foot">
  107. This is a footer
  108. </div>
  109. </div>
  110. </body>
  111. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement