Guest User

Untitled

a guest
Mar 10th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', '1');
  5.  
  6. function verifyEmail($email)
  7. {
  8. $wholeexp = '/^(.+?)@(([a-z0-9\.-]+?)\.[a-z]{2,5})$/i';
  9. $userexp = "/^[a-z0-9\~\\!\#\$\%\&\(\)\-\_\+\=\[\]\;\:\'\"\,\.\/]+$/i";
  10. if (preg_match($wholeexp, $email, $regs))
  11. {
  12. $username = $regs[1];
  13. $host = $regs[2];
  14. if (checkdnsrr($host, MX))
  15. {
  16. if (preg_match($userexp, $username))
  17. {
  18. return true;
  19. }
  20. else
  21. {
  22. return false;
  23. }
  24. }
  25. else
  26. {
  27. return false;
  28. }
  29. }
  30. else
  31. {
  32. return false;
  33. }
  34. }
  35.  
  36.  
  37. include("sql.php");
  38.  
  39. $submit=$_POST['submit'];
  40. $typ=$_POST['typ'];
  41.  
  42. $username=$_POST['username'];
  43. $password=$_POST['password'];
  44. $password_md5=md5($password);
  45. $email=$_POST['email'];
  46.  
  47. $city=$_POST['city'];
  48. $about=$_POST['about'];
  49. $phone=$_POST['phone'];
  50. $gg=$_POST['gg'];
  51. $photo=$_POST['photo'];
  52.  
  53. $register="random";
  54.  
  55. if($submit=="Rejestruj")
  56. {
  57.  
  58. //login
  59.  
  60. if ($username=="")
  61. {
  62. $error=1;
  63. $error_login="Login nie może być pusty";
  64. }
  65.  
  66. $szukaj=mysql_query("SELECT * FROM user WHERE username='$username';");
  67. while($rekord=mysql_fetch_array($szukaj))
  68. {
  69. $error=1;
  70. $error_login="Login już istnieje";
  71. }
  72.  
  73. // hasło
  74.  
  75. if (strlen($password)<6)
  76. {
  77. $error=1;
  78. $error_haslo="Hasło musi mieć minimum 6 znaków";
  79. }
  80.  
  81. // email
  82.  
  83. if ($email=="")
  84. {
  85. $error=1;
  86. $error_email="Email nie może być pusty";
  87. }
  88. if (verifyEmail($email)!=true)
  89. {
  90. $error=1;
  91. $error_email="Błędy format adresu";
  92. }
  93.  
  94.  
  95. include("top.php");
  96.  
  97.  
  98.  
  99. if ($submit!="Rejestruj" || $error!=0)
  100. {
  101. print"
  102. <form name=\"rejestracja\" action=\"rejestracja.php\" method=\"POST\">\n
  103. Login: input type=\"text\" name=\"username\" value=\"$username\"> <font class=\"error\">$error_login</font><br>\n
  104. Hasło: <input type=\"password\" name=\"password\" value=\"\"> <font class=\"error\">$error_haslo</font><br>\n
  105. Email: <input type=\"text\" name=\"email\" value=\"$email\"> <font class=\"error\">$error_email</font><br>\n
  106.  
  107.  
  108. Miejscowość: <input type=\"text\" name=\"city\" value=\"$city\"> <font class=\"error\">$error_nazwa</font><br>\n
  109. Kilka słów o sobie: <input type=\"text\" name=\"about\" value=\"$about\"> <font class=\"error\">$error_ulica</font><br>\n
  110. Telefon: <input type=\"text\" name=\"phone\" value=\"$phone\"> <font class=\"error\">$error_telefon</font><br>\n
  111. GG: <input type=\"text\" name=\"gg\" value=\"$gg\"> <font class=\"error\">$error_nazwisko</font><br>\n
  112. Foto: <input type=\"text\" name=\"foto\" value=\"$foto\"><br>\n
  113. ";
  114. }
  115. else
  116. {
  117. $query="
  118. INSERT INTO `piwo`.`user` (
  119. `id` ,
  120. `username` ,
  121. `pasword` ,
  122. `email` ,
  123. `citu` ,
  124. `about` ,
  125. `phone` ,
  126. `gg` ,
  127. `photo` ,
  128. `register`
  129. )
  130. VALUES (
  131. NULL , '$username', '$password_md5', '$email', '$city', '$about', '$phone', '$gg', '$photo', '$register'
  132. );";
  133. print $query;
  134. }
  135. // mysql_query($query);
  136.  
  137. // $dane_id=mysql_insert_id();
  138.  
  139. include("bottom.php");
  140. ?>
Add Comment
Please, Sign In to add comment