Może zaczne od plików jakie posiadam, a później opisze problem.
rejestracja.php
<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;
}
//-->
<div id="wb_Shape10" style="position:absolute;left:249px;top:0px;width:402px;height:52px;z-index:13;"> <img src="images/rejestracja_0008.png" id="Shape10" alt="" style="border-width:0;width:402px;height:52px;"></div> <div id="wb_Text2" style="position:absolute;left:216px;top:387px;width:469px;height:48px;z-index:14;text-align:left;"> <div><span style="color:#FF0000;font-family:Tahoma;font-size:13px;">UWAGA!
</span></div> <div><span style="color:#000000;font-family:Tahoma;font-size:13px;">Po poprawnej
<strong>Rejestracji Nowego Użytkownika
</strong> poczekaj na aktywację konta.
</span></div> <div><span style="color:#000000;font-family:Tahoma;font-size:13px;">Aktywacji dokonuje tylko i wyłącznie Administrator.
</span></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><span style="color:#000000;font-family:Tahoma;font-size:15px;"> Login
</span></div> <div id="wb_Text4" style="position:absolute;left:23px;top:99px;width:102px;height:18px;text-align:right;z-index:5;"> <div><span style="color:#000000;font-family:Tahoma;font-size:15px;">Nazwisko
</span></div> <div id="wb_Text5" style="position:absolute;left:47px;top:58px;width:78px;height:18px;text-align:right;z-index:6;"> <div><span style="color:#000000;font-family:Tahoma;font-size:15px;"> Imie
</span></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><span style="color:#000000;font-family:Tahoma;font-size:15px;">Hasło
</span></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><span style="color:#000000;font-family:Tahoma;font-size:15px;">Powtórz Hasło
</span></div> <div id="wb_adduser" style="position:absolute;left:292px;top:2px;width:128px;height:128px;z-index:11;"> <img src="images/useraddx128.png" id="adduser" alt="" border="0" style="width:128px;height:128px;"></div> <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;">
config.php
<?php
?>
kod który muszę dopisać w rejestracja.php
<?php
$haslo = md5($_POST['haslo']);
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ę.
Ten post edytował gogomania 24.02.2013, 21:37:32