Stworzyłem taki prosty system rejestracji użytkowników do bazy danych ze sprawdzaniem pól.
Problemem jest część, która sprawdzą czy użytkownik o takim samym username jest już w bazie. W teorii działa (wyświetla np. 1 jak jest 1, 0 jak jest 0 użytkowników o takim samym nicku w bazie), jednak po wstawieniu do if($count = 0) przestaje działać. Cokolwiek bym nie wpisał wyświetla się komunikat "That user already exists.". Baza jest czyściutka, bo testuję.
Wklejam tylko część (bez forma itp.)
Byłbym bardzo wdzięczny za wskazówki lub ew. pomoc.
<?php // Get data from the form. $submit = $_POST['submit']; // Check if form is submitted. if ($submit) { // Connect to database server and select database. // Check if all data is present.. if ($username && $fullname && $password && $repeatpassword) { // Check if username already exists. if ($count = 0) { // Check if passwords match. if ($password == $repeatpassword) { // Check the length of username and full name. // Check the length of password. // If everything is ok do this... // Encrypt passwords. // Insert user into database and show success message. $queryreg = mysql_query("INSERT INTO users VALUES ('','$fullname','$username','$password','$date')"); die("You have been <b>registered</b>. Click <a href='index.php'>here</a> to return to login page."); } }else {echo "You are already registered and logged in. Click <a href='members.php'>here</a> to enter the members area.";} ?>