rejestracja.php
<html> <head> <meta http-equiv="Content-Language" content="pl"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="author" content=""> <link rel="shortcut icon" href="Favorites.ico"> <script type="text/javascript"> <!-- function Validateregister_form(theForm) { var regexp; regexp = /^[A-Za-zŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőöřůúűüýţ˙0-9-]*$/; if (!regexp.test(theForm.Editbox1.value)) { alert("Wpisz poprawny Login!"); theForm.Editbox1.focus(); return false; } if (theForm.Editbox1.value == "") { alert("Wpisz poprawny Login!"); theForm.Editbox1.focus(); return false; } regexp = /^[A-Za-zŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőöřůúűüýţ˙]*$/; if (!regexp.test(theForm.Editbox2.value)) { alert("Wpisz poprawne Imie!"); theForm.Editbox2.focus(); return false; } if (theForm.Editbox2.value == "") { alert("Wpisz poprawne Imie!"); theForm.Editbox2.focus(); return false; } regexp = /^[A-Za-zŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖŘŮÚŰÜÝŢßŕáâăäĺćçčéęëěíîďđńňóôőöřůúűüýţ˙]*$/; if (!regexp.test(theForm.Editbox3.value)) { alert("Wpisz poprawne Nazwisko!"); theForm.Editbox3.focus(); return false; } if (theForm.Editbox3.value == "") { alert("Wpisz poprawne Nazwisko!"); theForm.Editbox3.focus(); return false; } if (theForm.Editbox4.value == "") { alert("Wpisz poprawne Hasło!"); theForm.Editbox4.focus(); return false; } if (theForm.Editbox5.value == "") { alert("Powtórz Hasło!"); theForm.Editbox5.focus(); return false; } if (theForm.Editbox5.value != theForm.Editbox4.value) { alert("Hasła nie są zgodne. Popraw i wpisz ponownie!"); theForm.Editbox5.focus(); return false; } return true; } //--> </script> </head> <body> <div id="container"> <div id="wb_Shape10" style="position:absolute;left:249px;top:0px;width:402px;height:52px;z-index:13;"> <div id="wb_Text2" style="position:absolute;left:216px;top:387px;width:469px;height:48px;z-index:14;text-align:left;"> </div> <div id="wb_regform1" style="position:absolute;left:239px;top:90px;width:420px;height:273px;z-index:15;"> <form name="register_form" method="post" action="<?php echo basename(__FILE__); ?>" enctype="multipart/form-data" accept-charset="UTF-8" id="regform1" onsubmit="return Validateregister_form(this)"> <button id="AdvancedButton1" onfocus="SetStyle('AdvancedButton1', 'styl1');return false;" onblur="SetStyle('AdvancedButton1', 'button1');return false;" type="submit" name="" value="submit" class="button1" style="position:absolute;left:30px;top:236px;width:110px;height:25px;z-index:0;"><div style="text-align:center"><span style="color:#FFFFFF;font-family:Tahoma;font-size:15px">Rejestruj</span></div></button> <input type="text" id="Editbox1" onfocus="SetStyle('Editbox1', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox1', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:135px;top:16px;width:148px;height:23px;line-height:23px;z-index:1;" name="Login" value=""> <input type="text" id="Editbox2" onfocus="SetStyle('Editbox2', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox2', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:135px;top:56px;width:148px;height:23px;line-height:23px;z-index:2;" name="Imie" value=""> <input type="text" id="Editbox3" onfocus="SetStyle('Editbox3', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox3', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:135px;top:96px;width:148px;height:23px;line-height:23px;z-index:3;" name="Nazwisko" value=""> <div id="wb_login" style="position:absolute;left:47px;top:19px;width:78px;height:18px;text-align:right;z-index:4;"> </div> <div id="wb_Text4" style="position:absolute;left:23px;top:99px;width:102px;height:18px;text-align:right;z-index:5;"> </div> <div id="wb_Text5" style="position:absolute;left:47px;top:58px;width:78px;height:18px;text-align:right;z-index:6;"> </div> <input type="password" id="Editbox4" onfocus="SetStyle('Editbox4', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox4', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:135px;top:136px;width:148px;height:23px;line-height:23px;z-index:7;" name="user_haslo" value="" autocomplete="off"> <div id="wb_Text6" style="position:absolute;left:23px;top:139px;width:102px;height:18px;text-align:right;z-index:8;"> </div> <input type="password" id="Editbox5" onfocus="SetStyle('Editbox5', 'stylramkafocus1');return false;" onblur="SetStyle('Editbox5', 'stylramka1');return false;" class="stylramka1" style="position:absolute;left:135px;top:176px;width:148px;height:23px;line-height:23px;z-index:9;" name="uesr_phaslo" value="" autocomplete="off"> <div id="wb_Text7" style="position:absolute;left:23px;top:178px;width:102px;height:18px;text-align:right;z-index:10;"> </div> <div id="wb_adduser" style="position:absolute;left:292px;top:2px;width:128px;height:128px;z-index:11;"> <hr id="Line1" class="ui-widget-header" style="margin:0;padding:0;position:absolute;left:28px;top:220px;width:259px;height
:1px;z-index:12;"> </form> </div> </div> </body> </html>
config.php
<?php ?>
kod który muszę dopisać w rejestracja.php
<?php require_once("config.php"); $dodaj = "INSERT INTO uzytkownicy (user_id,login,imie,nazwisko,haslo,data_rejestracji,status) VALUES ('','".$login."','".$imie."','".$nazwisko."','".$haslo."', NOW(), '')"; if($dodaj) { ?> <div style="color:#008000; font-weight:bold; text-align:center;"><h2>Udało się zarejestrować!!!</h2></div> <?php }else { ?> <div style="color:#c24f00; font-weight:bold; text-align:center;"><h2>Nie udało się zarejestrować!!!</h2></div> <?php } ?>
I teraz pytanie, w którym miejscu powinienem wpisać ten kod by rejestracja.php spełnił swoją funkcję tzn. rejestrował nowego użytkownika. Próbowałem już wpisać na końcu formularza jako <div></div> ale przy samej próbie wejścia na strone rejestracja.php dodawało automatycznie użytkownika do bazy MySQL, a chcę by użytkownik dodawał się dopiero po tym jak wypełnię wszystkie konieczne pola i wcisnę button "rejestruj".
Może ten kod zupełnie nie pasuje do pliku rejestracja.php - czekam na wszelkie sugestie i podpowiedzi. Z góry dziękuję.