Ik ben een afgeschermd gedeelte voor een website aan het bouwen in PHP. Nu heb ik al een werkende login, maar ik krijg het registratieformulier niet werkende. Wanneer ik de POST waardes van mijn formulier naar het onderstaande PHP bestand stuur krijg ik de volgende melding:
De fout zit hem in regel 17, maar ik zie echt niet wat er mis is. Misschien dat iemand mij een beetje op weg kan helpen?Notice: Undefined index: password in /var/www/html/includes/register.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/djarea/includes/register.php:17) in /var/www/html/djarea/includes/register.php on line 41
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <?php error_reporting(E_ALL); include('db.php'); if(isset($_POST['submit'])) { // Not leave any fields blank if (!$_POST['username'] | !$_POST['password1'] | !$_POST['password2'] | !$_POST['age'] | !$_POST['country'] | !$_POST['email']) { die('You did not complete all of the required fields.'); } // Passwords match if ($_POST['password1'] != $_POST['password2']) { die('Your passwords did not match.'); } // Username and password sent from signup form // Remove all HTML-tags and PHP-tags, then create a sha1-hash $username = strip_tags(mysql_real_escape_string($_POST['username'])); $password = sha1(strip_tags(mysql_real_escape_string($_POST['password']))); // Check if username already exists $query = sprintf("SELECT username FROM users WHERE username = '$username'") or die(mysql_error()); $result = mysql_query($query); if(0 != mysql_num_rows($result)) { die('Sorry, the username '.$username.' is already in use.'); } // Check if age are digits $age = strip_tags(mysql_real_escape_string($_POST['age'])); // Check country $country = strip_tags(mysql_real_escape_string($_POST['country'])); // Check email $email = strip_tags(mysql_real_escape_string($_POST['email'])); if(!preg_match("/^[a-z0-9\å\ä\ö._-]+@[a-z0-9\å\ä\ö.-]+\.[a-z]{2,6}$/i", $email)) { die('Invalid e-mail'); } // Check website $website = strip_tags(mysql_real_escape_string($_POST['website'])); // insert it into the database $insert = "INSERT INTO users (username, password, age, country, email, website) VALUES ('$username', '$password, '$age, '$country, '$email, '$website')"; $add_member = mysql_query($insert); //Redirect header('Location: ../login.php'); } ?> |