Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][TPL] przekazywanie zmiennych
krystian1991x
post
Post #1





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

Ostrzeżenie: (10%)
X----


Mam problem z formularzem rejestracji a konkretnie taki ustawiłem sobie żeby sprawdzało czy wszystkie pola zostały wypełnione oraz czy pola z hasłem oraz pola z email są takie same niestety coś tutaj nie gra Bo gdy za pierwszym razem wypełnię formularz to plik się przeładuje ale nie wyskoczy żaden komunikat :/ za drugim razem za to pokazuje mi tak jak by błąd z poprzedniego wypełnienia czyli jak w poprzednim niezgodne było hasło to wtedy wyskakuje mi błąd że pola z hasłem nie są identyczne o co tutaj chodzi ? Podaje kod PHP
  1. $login = mysql_escape_string($_POST['nick']);
  2. $password = mysql_escape_string($_POST['pw']);
  3. $rpw = mysql_escape_string($_POST['rpw']);
  4. $email = mysql_escape_string($_POST['email']);
  5. $remail = mysql_escape_string($_POST['remail']);
  6.  
  7. $login_use = mysql_query ("SELECT login FROM user WHERE login='$login'");
  8. $email_use = mysql_query ("SELECT email FROM user WHERE email='$email'");
  9.  
  10. if($_POST['register'] == 1) {
  11. if($login == "" && $password == "" && $rpw == "" && $email == "" && $remail == "")
  12. {
  13. $error_register = "bad_null";
  14. } else{
  15. if($pw == $rpw) {
  16.  
  17. $error_register = "bad_pw";
  18. } else {
  19.  
  20. if($email != $remail) { $error_register = "bad_email";
  21. } else {
  22.  
  23. $error_register = "yes";
  24.  
  25. $zapytanie = "INSERT INTO `user` (`id`, `login`, `password`, `email`, `avatar`)
  26. VALUES ('', '$login', '".md5($password)."', '$email', '')" ;
  27. $idzapytania = mysql_query($zapytanie);
  28. } }
  29. }
  30. }
  31. $smarty->assign('index', $img);
  32. $smarty->assign('error', $error_register);
  33. $smarty->display('register.tpl');
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
krystian1991x
post
Post #2





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 7.08.2010

Ostrzeżenie: (10%)
X----


zrobiłem to w ten sposób ale i tak nie działa HELP

  1. <form action="register.php" onsubmit="return validate();" method="post">
  2.  
  3. <div style="padding-left: 100px;">
  4. <table style="width: 377px; height: 220px; background-image: url('templates/images/54.png');">
  5.  
  6. <tr>
  7. <td valign="top">
  8. <table style="color: #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left: 36px;padding-top: 40px;">
  9. <tr><td valign="top" align="right" style="padding-top: 5px;"><b>Login:</b></td><td><input style="background-repeat: no-repeat; background-color: #64a424;padding-left: 4px;background-image: url('templates/images/52.png'); border: 0px; width: 165px; height: 22px;" name="nick" type="text" /></td></tr>
  10. <tr><td valign="top" align="right" style="padding-top: 5px;"><b>Hasło:</b></td><td><input style="background-repeat: no-repeat; background-color: #64a424; padding-left: 4px; background-image: url('templates/images/52.png'); border: 0px; width: 165px; height: 22px;" name="pw" type="password" /></td></tr>
  11. <tr><td valign="top" align="right" style="padding-top: 5px;"><b>Powtórz hasło:</b></td><td><input style="background-repeat: no-repeat; background-color: #64a424; padding-left: 4px; background-image: url('templates/images/52.png'); border: 0px; width: 165px; height: 22px;" name="rpw" type="password" /></td></tr>
  12. <tr><td valign="top" align="right" style="padding-top: 5px;"><b>Adres e-mail:</b></td><td><input style="background-repeat: no-repeat; background-color: #64a424; padding-left: 4px; background-image: url('templates/images/52.png'); border: 0px; width: 165px; height: 22px;" name="email" type="text" /></td></tr>
  13. <tr><td valign="top" align="right" style="padding-top: 5px;"><b>Powtórz adres:</b></td><td><input style="background-repeat: no-repeat; background-color: #64a424; padding-left: 4px; background-image: url('templates/images/52.png'); border: 0px; width: 165px; height: 22px;" name="remail" type="text" /></td></tr>
  14. <tr><td><input type='hidden' name='register' value='1' /></td><td style="padding-left: 100px;" align="left"> <input type="image" src="templates/images/53.png" value="Załóż konto" /></td></tr>
  15. </td>
  16. </tr>
  17.  
  18.  
  19. </div>
  20. </form>
  21. <script type="text/javascript">{literal}
  22. function error(tekst) {
  23. if (errfound) return;
  24. window.alert(tekst);
  25. errfound = true;
  26. }
  27. function validate() {
  28. errfound = false;
  29. var bledy = "";
  30. with (document.forms[0]) {
  31. if (nick.value == "") bledy += "Nie podałeś imienia. \n";
  32. if (pw.value == "") bledy += "Nie podałeś nazwiska.\n";
  33. if (rpw.value == "") bledy += "Nie napisałeś treści";
  34. if (email.value == "") bledy += "Nie podałeś nazwiska.\n";
  35. if (remail.value == "") bledy += "Nie napisałeś treści";
  36. if (bledy != "") error(bledy);
  37. }
  38. return !errfound;
  39. }
  40. {/literal}</script>


pomocy ?

help ?

hej hej help me :E

nikt nie wie ? dziwne :<
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: 18.09.2025 - 00:54