Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Mysql]Jak stworzyć tabelę pod tą rejestrację
kiepski96
post
Post #1





Grupa: Zarejestrowani
Postów: 233
Pomógł: 0
Dołączył: 22.02.2010

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $error_message = "";
  3. if ($_SERVER['REQUEST_METHOD'] == 'POST')
  4. {
  5. $action = isset($_POST['action']) ? $_POST['action'] : '';
  6. $mysql_server = 'serwer';
  7. $mysql_username = 'nazwa użytkownika';
  8. $mysql_password = 'hasło';
  9. $mysql_database = 'baza danych';
  10. $mysql_table = 'nazwa tabeli';
  11.  
  12. $success_page = './profil.php';
  13.  
  14. if ($action == 'signup')
  15. {
  16. $newusername = $_POST['username'];
  17. $newemail = $_POST['email'];
  18. $newpassword = $_POST['password'];
  19. $confirmpassword = $_POST['confirmpassword'];
  20. $newfullname = $_POST['fullname'];
  21. if ($newpassword != $confirmpassword)
  22. {
  23. $error_message = 'Hasła nie psują do siebie';
  24. }
  25. else
  26. if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newusername))
  27. {
  28. $error_message = 'Nieprawidłowa nazwa użytkownika';
  29. }
  30. else
  31. if (!ereg("^[A-Za-z0-9_!@$]{1,50}$", $newpassword))
  32. {
  33. $error_message = 'Wystąpił błąd.Wpisz inne hasło.';
  34. }
  35. else
  36. if (!ereg("^[A-Za-z0-9_!@$.' &]{1,50}$", $newfullname))
  37. {
  38. $error_message = 'Wystąpił błąd przy wprowadzeniu imienia';
  39. }
  40. else
  41. if (!ereg("^.+@.+\..+$", $newemail))
  42. {
  43. $error_message = 'Nieprawidłowy adres email';
  44. }
  45. else
  46. if (isset($_POST['captcha'],$_SESSION['random_txt']) && md5($_POST['captcha']) == $_SESSION['random_txt'])
  47. {
  48. unset($_POST['captcha'],$_SESSION['random_txt']);
  49. }
  50. else
  51. {
  52. $error_message = 'The entered code was wrong.';
  53. }
  54. if (empty($error_message))
  55. {
  56. $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
  57. mysql_select_db($mysql_database, $db);
  58. $sql = "SELECT username FROM ".$mysql_table." WHERE username = '".$newusername."'";
  59. $result = mysql_query($sql, $db);
  60. if ($data = mysql_fetch_array($result))
  61. {
  62. $error_message = 'Nazwa użytkownika jest już zajęta';
  63. }
  64. }
  65. if (empty($error_message))
  66. {
  67. $crypt_pass = md5($newpassword);
  68. $sql = "INSERT `".$mysql_table."` (`username`, `password`, `fullname`, `email`, `active`) VALUES ('$newusername', '$crypt_pass', '$newfullname', '$newemail', 1)";
  69. $result = mysql_query($sql, $db);
  70. $mailto = $newemail;
  71. $subject = 'Nowe konto';
  72. $message = 'Założono konto stronazasms';
  73. $message .= "\r\nUsername: ";
  74. $message .= $newusername;
  75. $message .= "\r\nPassword: ";
  76. $message .= $newpassword;
  77. $message .= "\r\n";
  78. $header = "From: stronazasms@tlen.pl"."\r\n";
  79. $header .= "Reply-To: stronazasms@tlen.pl"."\r\n";
  80. $header .= "MIME-Version: 1.0"."\r\n";
  81. $header .= "Content-Type: text/plain; charset=utf-8"."\r\n";
  82. $header .= "Content-Transfer-Encoding: 8bit"."\r\n";
  83. $header .= "X-Mailer: PHP v".phpversion();
  84. mail($mailto, $subject, $message, $header);
  85. mail('stronazasms@tlen.pl', $subject, $message, $header);
  86. header('Location: '.$success_page);
  87. }
  88. }
  89. }
  90. ?>



Mam taki skrypt rejestracji.
Jaką dodać tabelę do mysql pod ten skrypt?(IMG:style_emoticons/default/questionmark.gif)
Proszę o podanie kodu tabeli.

  1. <?php
  2. if($_SERVER['REQUEST_METHOD'] == 'POST')
  3. {
  4. $success_page = '';
  5. $error_page = basename(__FILE__);
  6. $mysql_server = 'sdbhdncn';
  7. $mysql_username = 'xbxcnn';
  8. $mysql_password = 'shdhd';
  9. $mysql_database = 'asdghsh';
  10. $mysql_table = 'ddcndcn';
  11. $crypt_pass = md5($_POST['password']);
  12. $found = false;
  13. $fullname = '';
  14.  
  15. $db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
  16. mysql_select_db($mysql_database, $db);
  17. $sql = "SELECT password, fullname, active FROM ".$mysql_table." WHERE username = '".$_POST['username']."'";
  18. $result = mysql_query($sql, $db);
  19. if ($data = mysql_fetch_array($result))
  20. {
  21. if ($crypt_pass == $data['password'] && $data['active'] != 0)
  22. {
  23. $found = true;
  24. $fullname = $data['fullname'];
  25. }
  26. }
  27. if($found == false)
  28. {
  29. header('Location: '.$error_page);
  30. }
  31. else
  32. {
  33. $_SESSION['username'] = $_POST['username'];
  34. $_SESSION['fullname'] = $fullname;
  35. $rememberme = isset($_POST['rememberme']) ? true : false;
  36. if ($rememberme)
  37. {
  38. setcookie('username', $_POST['username'], time() + 3600*24*30);
  39. setcookie('password', $_POST['password'], time() + 3600*24*30);
  40. }
  41. header('Location: '.$success_page);
  42. }
  43. }
  44. $username = isset($_COOKIE['username']) ? $_COOKIE['username'] : '';
  45. $password = isset($_COOKIE['password']) ? $_COOKIE['password'] : '';
  46. ?>



Mam taki skrypt logowania.
Jaką dodać tabelę do mysql pod ten skrypt?(IMG:style_emoticons/default/questionmark.gif)
Proszę o podanie kodu tabeli.



Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 26.09.2025 - 19:55