Advertisement
Guest User

Untitled

a guest
May 28th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <!-- upload page --!>
  2. <?php
  3. include("connect.php");
  4.  
  5. $_SESSION['username'];
  6.  
  7. $username = $_SESSION['username'];
  8.  
  9. if ($_POST['submit'])
  10. {
  11.  
  12. $name = $_FILES['myfile']['name'];
  13. $tmp_name = $_FILES['myfile']['tmp_name'];
  14.  
  15. if ($name)
  16. {
  17. // start upload procress
  18. $location = "avatars/$name";
  19. move_uploaded_file($tmp_name,$location);
  20. if ($name)
  21. if ($name)
  22.  
  23. $query = mysql_query("UPDATE users SET imagelocation='$location' WHERE username='$username'");
  24. die("your avatar has been uploaded! <a href='view.php'>Home</a>");
  25. }
  26. else
  27. echo "please choose your avatar";
  28. }
  29.  
  30.  
  31. echo "<p>welcome, ".$username."!<p>";
  32.  
  33. echo "upload your image:
  34.  
  35. <form action='upload.php' method='POST' enctype='multipart/form-data'>
  36. File: <input type='file' name='myfile'> <input type='submit' name='submit' value='upload'>
  37. </form> ";
  38.  
  39. ?>
  40. <!-- upload page end--!>
  41. <!-- register page --!>
  42. <?php
  43. echo "<h1>Register</h1>";
  44.  
  45. $submit = $_POST['submit'];
  46. $fullname = strip_tags ($_POST['fullname']);
  47. $username = strip_tags ($_POST['username']);
  48. $password = strip_tags ($_POST['password']);
  49. $repeatpassword = strip_tags ($_POST
  50.  
  51. ['repeatpassword']);
  52. $date = date("Y-m-d");
  53.  
  54. if ($submit)
  55. {
  56. // check for existance
  57.  
  58. if
  59.  
  60. ($fullname&&$username&&$password&&$repeatpassword
  61.  
  62. )
  63. {
  64. if ($password==$repeatpassword)
  65. {
  66. if (strlen ($username)>25||strlen ($fullname)>25)
  67. {
  68. echo "Lenght of username or fullname is too long";
  69. }
  70. else
  71. {
  72. if (strlen ($password)>32||strlen ($password)<4)
  73. {
  74. echo "Password must be between 4 and 32 characters";
  75. }
  76. else
  77. {
  78. // register user
  79.  
  80. $password = md5 ($password);
  81. $repeatpassword = md5 ($repeatpassword);
  82.  
  83. // open database
  84.  
  85. $connect = mysql_connect("localhost","root","");
  86. mysql_select_db ("phpacademy");
  87.  
  88. $queryreg = mysql_query("
  89. INSERT INTO users VALUES
  90.  
  91. ('','$fullname','$username','','$password','$date')
  92. ");
  93.  
  94. die ("you have been registered! <a href='index.php'>Click
  95.  
  96. here</a> to login");
  97.  
  98. }
  99.  
  100.  
  101. }
  102. }
  103. else
  104. echo "your passwords doesnt match";
  105. }
  106. else
  107. echo "Please fill in <b>all</b> fields!";
  108.  
  109. }
  110.  
  111.  
  112.  
  113. ?>
  114. <html><legend><b>Lol you noob aren't even registered
  115.  
  116. </b></legend><p>
  117. <form
  118.  
  119. action='register.php' method='POST'>
  120. <table
  121.  
  122. border=\"0\" width=\"510\">
  123.  
  124.  
  125. <tr>
  126. <td>
  127. Your full name:
  128. </td>
  129. <td>
  130. <input type='text'
  131.  
  132. name='fullname' value='<?php echo $fullname; ?>'>
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>
  137. Choose a username:
  138. </td>
  139. <td>
  140. <input type='text'
  141.  
  142. name='username' value='<?php echo $username; ?>'>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td>
  147. Choose a password:
  148. </td>
  149. <td>
  150. <input type='password'
  151.  
  152. name='password'>
  153. </td>
  154. </tr>
  155. <tr>
  156. <td>
  157. Repeat your password:
  158. </td>
  159. <td>
  160. <input type='password'
  161.  
  162. name='repeatpassword'>
  163. </td>
  164. </tr>
  165.  
  166. </table>
  167. <p>
  168. <input type='submit' name='submit' value='Register'>
  169. </form>
  170.  
  171.  
  172.  
  173. </html>
  174. <--register page end-->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement