Wednesday 15 June 2011

php - Multiple 'Undefined index' errors -



php - Multiple 'Undefined index' errors -

this question has reply here:

php: “notice: undefined variable” , “notice: undefined index” 14 answers

okay, weird... i'm working on pretty basic registration script, returns this:

notice: undefined index: username in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 42

notice: undefined index: email in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 46

notice: undefined index: email in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 50

notice: undefined index: emailconfirm in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 50

notice: undefined index: passwordp in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 54

notice: undefined index: passwordcomfirm in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 54

notice: undefined index: username in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 58

notice: undefined index: passwordp in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 62

notice: undefined index: passwordp in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 66

notice: undefined index: username in c:\xampp\htdocs\zephryte\app\classes\users.class.php on line 70

which pretty darn weird, since named of input fields corresponding variable:

<input type="text" name="username" size="45" placeholder="username..." class="input" style="width: 98%;" /> <input type="text" name="email" size="45" placeholder="e-mailadres..." class="input" style="width: 98%;" />

and on... did miss here?

edit:

since asked relevant php & html code:

html:

<form action="index.php?p=register" method="post" autocomplete="off"> <table align="center" cellpadding="8" style="width: 100%;"> <tr> <td style="width: 100%;"> <input type="text" name="username" size="45" placeholder="username..." class="input" style="width: 98%;" /> </td> </tr> <tr> <td style="width: 100%;"> <input type="text" name="email" size="45" placeholder="e-mailadres..." class="input" style="width: 98%;" /> </td> </tr> <tr> <td style="width: 100%;"> <input type="text" name="emailconfirm" size="45" placeholder="e-mailadres bevestigen..." class="input" style="width: 98%;" /> </td> </tr> <tr> </tr> <tr> <td style="width: 100%;"> <input type="password" name="passwordp" size="45" placeholder="wachtwoord..." class="input" style="width: 98%;" /> </td> </tr> <tr> </tr> <tr> <td width="100%"> <input type="password" name="passwordconfirm" size="45" placeholder="wachtwoord bevestigen..." class="input" style="width: 98%;" /> </td> </tr> <tr> <td style="width: 100%;"> <input type="text" name="skype" size="45" placeholder="skype..." class="input" style="width: 98%;" /> </td> </tr> <tr> </tr> <td width="30%"> <input type="submit" name="register" value="registreren" class="button little orange" style="width: 100%;"> </td> </table> </form>

php:

public function register() { $query = $this->db->conn->prepare('insert ht_users values "", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?'); //22 $errors = array(); if (strlen($_post['username']) < 3) { $errors[] = "je gebruikersnaam niet geldig"; } if (!filter_var($_post['email'], filter_validate_email)) { $errors[] = "je emailadres niet geldig"; } if ($_post['email'] !== $_post['emailconfirm']) { $errors[] = 'je emailadressen zijn niet \'t zelfde!'; } if ($_post['passwordp'] !== $_post['passwordcomfirm']) { $errors[] = 'je wachtwoorden zijn niet \'t zelfde'; } if (!ctype_graph($_post['username'])) { $errors[] = 'je gebruikersnaam bezit ongeldige tekens!'; } if (strlen($_post['passwordp']) < 6) { $errors[] = 'je wachtwoord moet op z\'n minst 6 tekens lang zijn'; } if (strlen($_post['passwordp']) > 20) { $errors[] = 'je wachtwoord mag maximaal 20 tekens bevatten!'; } if ($this->checkusername($_post['username'])) { $errors[] = 'oeps! er bestaat al een business relationship op deze habbonaam!<br>ben je misschien je <a href="?p=lostpass">wachtwoord vergeten</a>?'; } if ($this->checkemail($_post['email'])) { $errors[] = 'oeps! er bestaat al een business relationship op dit emailadres!<br>ben je misschien je <a href="?p=lostpass">wachtwoord vergeten</a>?'; } if (count($errors) > 0) { echo 'fuck'; //return $errors; exit(); } $password = md5($_post['passwordp']); $data = date('d-m-y'); $ipaddress = $_server['remote_addr']; if (array_key_exists('http_x_forwarded_for', $_server)) { $ipaddress = array_pop(explode(',', $_server['http_x_forwarded_for'])); } $query->bind_param('ssssssssssssssssssssss', $data, $username, $password, null, $email, $this->generatecode($username), $ipaddress, $ipaddress, $data, $data, 1, null, null, 0, 0, 1, 1, 0, $skype, 0, 0, null); $query->execute(); $query->close(); $this->login($username, $passwordp); }

add isset php:

public function register() { $query = $this->db->conn->prepare('insert ht_users values "", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?'); //22 $errors = array(); if (!isset($_post['username']) || strlen($_post['username']) < 3) { $errors[] = "je gebruikersnaam niet geldig"; } if (!isset($_post['email']) || !filter_var($_post['email'], filter_validate_email)) { $errors[] = "je emailadres niet geldig"; } if (!isset($_post['email']) || !isset($_post['emailconfirm']) || $_post['email'] !== $_post['emailconfirm']) { $errors[] = 'je emailadressen zijn niet \'t zelfde!'; } if (!isset($_post['passwordp']) || !isset($_post['passwordcomfirm']) || $_post['passwordp'] !== $_post['passwordcomfirm']) { $errors[] = 'je wachtwoorden zijn niet \'t zelfde'; } if (!isset($_post['username']) || !ctype_graph($_post['username'])) { $errors[] = 'je gebruikersnaam bezit ongeldige tekens!'; } if (!isset($_post['passwordp']) || strlen($_post['passwordp']) < 6) { $errors[] = 'je wachtwoord moet op z\'n minst 6 tekens lang zijn'; } if (!isset($_post['passwordp']) || strlen($_post['passwordp']) > 20) { $errors[] = 'je wachtwoord mag maximaal 20 tekens bevatten!'; } if (!isset($_post['username']) || $this->checkusername($_post['username'])) { $errors[] = 'oeps! er bestaat al een business relationship op deze habbonaam!<br>ben je misschien je <a href="?p=lostpass">wachtwoord vergeten</a>?'; } if (!isset($_post['email']) || $this->checkemail($_post['email'])) { $errors[] = 'oeps! er bestaat al een business relationship op dit emailadres!<br>ben je misschien je <a href="?p=lostpass">wachtwoord vergeten</a>?'; } if (count($errors) > 0) { echo 'neuken'; //return $errors; exit(); } $password = md5($_post['passwordp']); $data = date('d-m-y'); $ipaddress = $_server['remote_addr']; if (array_key_exists('http_x_forwarded_for', $_server)) { $ipaddress = array_pop(explode(',', $_server['http_x_forwarded_for'])); } $query->bind_param('ssssssssssssssssssssss', $data, $username, $password, null, $email, $this->generatecode($username), $ipaddress, $ipaddress, $data, $data, 1, null, null, 0, 0, 1, 1, 0, $skype, 0, 0, null); $query->execute(); $query->close(); $this->login($username, $passwordp); }

php

No comments:

Post a Comment