Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Nie dodaje rekordu do bazy.
MrPey
post 29.03.2009, 19:52:49
Post #1





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 21.01.2009

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


Witam, napisałem skrypt rejestracji, lecz nie chce dodać on rekordów do bazy.
Kod
<?

$login = $_POST['login'];
$pass = md5(md5($_POST['pass']).md5($_POST['pass']));
$repass = md5(md5($_POST['repass']).md5($_POST['repass']));
$email = $_POST['email'];
$gg = $_POST['gg'];
$avatar = $_POST['avatar'];
$about = $_POST['about'];
$group = 0;
$regdate = date("d.m.Y, H;i");
$ban = 0;
$posts = 0;
$topics = 0;

                
    
                if ($pass == $repass)
            {
                    if ($login && $pass)
                        {
                            $ins = @mysql_query ("INSERT INTO users (login,pass,email,gg,avatar,about,group,regdate,ban,posts,topics) VALUE ('$login', '$pass', '$email', '$gg', '$avatar', '$about', '$group', '$regdate', '$ban', '$posts', '$topics')");
                            mysql_close($connect);
                }
            }
            
            elseif (empty($login) || empty($pass) || empty($repass) || empty($email))
                                {
                                    echo "Uzupełnij wszystkie wymaganie pola.";
                                }
            
            else
                {
                    echo "Hasła się różnią.";
                }
?>

<div style="background-color: #f0ffcb; padding: 7px;">
W celu skorzystania z serwisu prosimy o wypełnienie poniżej zamieszczonego formularza.
<hr style="color: #b8ff00;"  />
    <div style="weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif; color: #656565; font-size: 11px;">
    <form action="" method="post">
    <label for="form1_login">
Nazwa użytkownika<span style="color: red;">*</span>:
<input type="text" name="login" style="margin-left: 20px;"><br><br>

    <label for="form1_login" style="">
Hasło<span style="color: red;">*</span>:
<input type="password" name="pass" style="margin-left: 100px;"><br><br>

    <label for="form1_login">
Powtórz hasło<span style="color: red;">*</span>:
<input type="password" name="repass" style="margin-left: 52px;"><br><br>

    <label for="form1_login">
E-mail<span style="color: red;">*</span>:
<input type="text" name="email" style="margin-left: 95px;"><br><br>

    <label for="form1_login">
Gadu-gadu:
<input type="text" name="gg" style="margin-left: 75px;"><br><br>

    <label for="form1_login">
Avatar:
<input type="text" name="avatar" style="margin-left: 100px;"><br><br>

    <label for="form1_login">
O sobie:
<textarea style="margin-left: 94px;" name="about"></textarea>
<br><br>
<input type="submit" value="Dalej" style="border: 1px solid #3c7392; background-color: #f1faff; margin-left: 147px;">
</form>
<hr style="color: #b8ff00;"  />
<span style="color: red;">*</span> Pole obowiązkowe.

</label>
</div>
</div>
Go to the top of the page
+Quote Post
maniekl2
post 29.03.2009, 19:55:55
Post #2





Grupa: Zarejestrowani
Postów: 162
Pomógł: 29
Dołączył: 6.04.2008

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


Radze użyć BB-code. Jak usuniesz @ przed mysql_query może pojawi się jakiś błąd

Ten post edytował maniekl2 29.03.2009, 19:56:25
Go to the top of the page
+Quote Post
RubiX
post 29.03.2009, 19:57:19
Post #3





Grupa: Zarejestrowani
Postów: 162
Pomógł: 6
Dołączył: 14.02.2007
Skąd: Poznań

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


jest mysql_close($connect);

a gdzie jest connect ?

i łączenie z sql ?

Ten post edytował RubiX 29.03.2009, 19:57:51


--------------------
===================================

\o/ torebki
Go to the top of the page
+Quote Post
MrPey
post 29.03.2009, 19:59:19
Post #4





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 21.01.2009

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


Cytat
Jak usuniesz @ przed mysql_query może pojawi się jakiś błąd

niestety już patrzalem i nic :/

Cytat
a gdzie jest connect ?

i łączenie z sql ?

jest w pliku index.php, do którego includowana jest rejestracja - tak więc jest.
Go to the top of the page
+Quote Post
Tajgeer
post 29.03.2009, 20:02:12
Post #5





Grupa: Zarejestrowani
Postów: 290
Pomógł: 48
Dołączył: 11.05.2008
Skąd: Kielce

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


Dodaj do tego inserta
Kod
or die(mysql_error());
i zobacz co wyświetli

Ten post edytował Tajgeer 29.03.2009, 20:09:31
Go to the top of the page
+Quote Post
MrPey
post 29.03.2009, 20:07:34
Post #6





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 21.01.2009

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


Cytat
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group,regdate,ban,posts,topics) VALUE ('ss', 'dc1175d4d859e75459973e74925bd800',' at line 1
Go to the top of the page
+Quote Post
Tajgeer
post 29.03.2009, 20:09:57
Post #7





Grupa: Zarejestrowani
Postów: 290
Pomógł: 48
Dołączył: 11.05.2008
Skąd: Kielce

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


Zamień VALUE na VALUES i spróbuj.
Go to the top of the page
+Quote Post
MrPey
post 29.03.2009, 20:11:48
Post #8





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 21.01.2009

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


nie pomoglo :/
Go to the top of the page
+Quote Post
Tajgeer
post 29.03.2009, 20:15:00
Post #9





Grupa: Zarejestrowani
Postów: 290
Pomógł: 48
Dołączył: 11.05.2008
Skąd: Kielce

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


Możesz spróbować jeszcze tak:
Kod
$ins = mysql_query("INSERT INTO users (`login`,`pass`,`email`,`gg`,`avatar`,`about`,`group`,`regdate`,`ban`,`posts`,`topics`) VALUES ('$login', '$pass', '$email', '$gg', '$avatar', '$about', '$group', '$regdate', '$ban', '$posts', '$topics')") or die(mysql_error());


Jeśli nie zadziała - pokaż strukturę tabeli users.

Ten post edytował Tajgeer 29.03.2009, 20:15:16
Go to the top of the page
+Quote Post
MrPey
post 29.03.2009, 20:18:36
Post #10





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 21.01.2009

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


Cytat
CREATE TABLE IF NOT EXISTS `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`pass` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`gg` int(10) DEFAULT NULL,
`avatar` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
`sygnature` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`group` int(1) NOT NULL,
`about` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`ban` int(1) NOT NULL DEFAULT '0',
`regdate` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`posts` int(1) NOT NULL DEFAULT '0',
`topics` int(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

--
-- Zrzut danych tabeli `users`
--
Go to the top of the page
+Quote Post
Tajgeer
post 29.03.2009, 20:21:43
Post #11





Grupa: Zarejestrowani
Postów: 290
Pomógł: 48
Dołączył: 11.05.2008
Skąd: Kielce

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


Kod
$ins = mysql_query("INSERT INTO users VALUES ('', '$login', '$pass', '$email', '$gg', '$avatar', '', '$group', '$about', '$ban', '$regdate', '$posts', '$topics')") or die(mysql_error());
Go to the top of the page
+Quote Post
MrPey
post 29.03.2009, 20:25:47
Post #12





Grupa: Zarejestrowani
Postów: 31
Pomógł: 0
Dołączył: 21.01.2009

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


dzięki bardzo, działa!
do zamknięcia smile.gif
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 16.07.2025 - 19:23