Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. <?
  2. ob_start();
  3. session_start();
  4. //inkludujemy plik z has&#322;ami
  5.  
  6. include("conf.php");
  7.  
  8. //Laczenie z baza
  9. mysql_connect ( 'tibiaice.xaa.pl:2082', 'tibiaice','3L3mDn')or die("Nie mo&#380;na si&#281; po&#322;&#261;czy&#263; z baz&#261;: ".mysql_error());
  10. mysql_select_db('tibiaice_01') or die(mysql_error());
  11. ?>
  12.  
  13. <html>
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  16. <title>Rejestracja</title>
  17. <script type="text/javascript">
  18. <!-- //
  19. function regulamin()
  20. {
  21. if(document.getElementById('reg').checked == true )
  22. {
  23. document.getElementById('dalej').disabled=false;
  24. }
  25. else
  26. {
  27. document.getElementById('dalej').disabled=true;
  28. }
  29. }
  30. // -->
  31. </script>
  32.  
  33. </head>
  34. <form method="post" action="<? echo $PHP_SELF;?>" METHOD=POST enctype="multipart/form-data">
  35. <center>
  36. <center><b>Login:<b><br />
  37. <input type="text" name="login" style="font-size: 10pt; font-family: Tahoma; font-weight: bold" /><br />
  38. <b>Email:<b><br />
  39. <input type="text" name="email" style="font-size: 10pt; font-family: Tahoma; font-weight: bold" /><br />
  40. <b>Has&#322;o:</b><br />
  41. <input type="password" name="haslo" style="font-size: 10pt; font-family: Tahoma; font-weight: bold" /><br />
  42. <b>O¶wiadczam i&#380; zaakceptowa&#322;em regulamin</b>
  43. <input type="checkbox" id="reg" onclick="regulamin()" /><br />
  44. <input type="submit" name="submit" value="Rejestracja" id="dalej" disabled="disabled" style="font-size: 10pt; font-family: Tahoma; font-weight: bold" /></center>
  45.  
  46.  
  47. </form>
  48. <?
  49. //Jak wiadomo dobrze u&#380;y&#263; funkcji trim aby usun&#261;&#263; zb&#281;dne znaki
  50. $login = trim($_POST['login']);
  51. $email = trim($_POST['email']);
  52. $pass_md5 = md5($_POST['haslo']);
  53. $pass = $_POST['haslo'];
  54. if($_POST['submit']) {
  55. $checkuser = mysql_query("SELECT login FROM users WHERE login='$login'");
  56. $username_exist = mysql_num_rows($checkuser);
  57.  
  58. //Jezeli zarejestrowanych takich nazw jest wiecej niz 0
  59. if($username_exist > 0){
  60. echo '
  61. <h2><center><b>Ta nazwa jest ju&#380; zaj&#281;ta wybierz inn±</b></center></h2>
  62. ';
  63. unset($login);
  64. exit();
  65. }
  66.  
  67. //Wysylamy zapytanie z logowaniem
  68. $zapytanie = "INSERT INTO `users` (`id`, `login`, `email`, `haslo`) VALUES (NULL, '$login', '$email', '$pass_md5')";
  69. $idzapytania = mysql_query($zapytanie);
  70.  
  71. if(!$idzapytania)
  72. {
  73. echo 'blad!' . mysql_error();
  74. }
  75. else
  76. {
  77. echo '
  78. <h2><center><b>Poprawnie si&#281; zarejestrowa&#322;e¶, <a href="logowanie.php">mo&#380;esz si&#281; zalogowa&#263;</a></b></center></h2>
  79. ';
  80. }}
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement