Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][mysql] problem z logowaniem i bazą danych
mtskilla
post
Post #1





Grupa: Zarejestrowani
Postów: 76
Pomógł: 1
Dołączył: 17.01.2007

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


  1. <?php
  2. include "conn.inc.php";
  3. ?>
  4.  
  5.  
  6.  
  7. <?php print '<'.'?xml version="1.0" encoding="iso-8859-2"?'.'>'; ?>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  9. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  10.  
  11. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
  12. <head>
  13. <meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />
  14. <title>php</title>
  15. <link href="style.css" type="text/css" rel="stylesheet" />
  16. </head>
  17. <body>
  18.  
  19.  
  20. <?php
  21.  
  22. if (isset($_POST['submit']) && $_POST['submit'] == "Zarejestruj") {
  23. if ($_POST['username'] != "" &&
  24. $_POST['password'] != "" &&
  25. $_POST['first_name'] != "" &&
  26. $_POST['last_name'] != "" ) {
  27.  
  28.  
  29. $query = "SELECT username FROM user_info".
  30. "WHERE username = '" . $_POST['username'] . "';";
  31.  
  32. $result = mysql_query($query)
  33. or die (mysql_error());
  34.  
  35. if (mysql_num_rows($result) != 0) {
  36.  
  37. ?>
  38.  
  39. Nazwa uzytkownika
  40. <?php echo $_POST['username']; ?> jest już używana. Proszę wybrac inna!
  41.  
  42. <form acrion="index.php" method="post">
  43. Nazwa kierownika: <input type="text" name="username" /><br />
  44. Haslo: <input type="password" name="password" value="<?php echo $_POST['password']; ?>" /><br />
  45. Imię: <input type="text" name="first_name" value="<?php echo $_POST['first_name']; ?>" /><br />  
  46. Nazwisko: <input type="text" name="last_name" value="<?php echo $_POST['last_name']; ?>" /><br /> 
  47. <input type="submit" name="submit" value="Zarejestruj" />  
  48. <input type="reset" value="Wyczysc" />
  49. </form>
  50.  
  51. <?php
  52. } else {
  53. $query= "INSERT INTO user_info (username, password, first_name, last_name)".
  54. "VALUES (
  55. '".$_POST['username']."', 
  56. (PASSWORD('".$_POST['password']."')),
  57. '".$_POST['first_name']."',
  58. '".$_POST['last_name']."')";
  59.  
  60.  
  61. $result = mysql_query($query)
  62. or die (mysql_error());
  63.  $_SESSION['user_logged'] = $_POST['username'];
  64.  $_SESSION['user_password'] = $_POST['password'];
  65. ?>
  66.  
  67.  <?php echo $_POST['first_name']."".$_POST['last_name']; ?> Zostal pomyslnie dodany jako kierownik.
  68.  
  69. <?php 
  70. header("Refresh: 5; URL=index.php");
  71. echo "Kierownik dodany." . " Za moment nastąpi przeniesienie na stronę glowną.<br />";
  72. die();
  73. }
  74. }else {
  75. ?>
  76.  
  77.  
  78. Należy wypelnic wszystkie pola!
  79.  
  80. <form acrion="admin.php" method="post">
  81. Nazwa kierownika: <input type="text" name="user" value="<?php echo $_POST['username']; ?>" /> <br />
  82. Haslo: <input type="password" name="password" value="<?php echo $_POST['password']; ?>" /> <br />
  83. Imię: <input type="text" name="first_name" value="<?php echo $_POST['first_name']; ?>" />  <br />  
  84. Nazwisko: <input type="text" name="last_name" value="<?php echo $_POST['last_name']; ?>" /> <br /> 
  85. <input type="submit" name="submit" value="Zarejestruj" />  
  86. <input type="reset" value="Wyczysc" />
  87. </form>
  88.  
  89. <?php
  90. }
  91. } else {
  92. ?>
  93.  
  94. Należy podac login, hasla, imienia oraz nazwiska kierownika.
  95.  
  96.  
  97. <form acrion="admin.php" method="post">
  98. Nazwa kierownika: <input type="text" name="username" /><br />
  99. Haslo: <input type="password" name="password" /><br />
  100. Imię: <input type="text" name="first_name" /><br />  
  101. Nazwisko: <input type="text" name="last_name" /><br /> 
  102. <input type="submit" name="submit" value="Zarejestruj" />  
  103. <input type="reset" value="Wyczysc" />
  104. </form>
  105.  
  106. <?php
  107. }
  108. ?>
  109.  
  110. </body>
  111. </html>

Problem polega na tym, ze zamiast dzialac wywala mi błąd Something is wrong in your syntax obok '= 'asdasd'' w linii 1. w bazie mam tabele user_info. HELP

Ten post edytował mtskilla 22.01.2007, 11:53:04
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: 24.09.2025 - 13:49