Ik ben hier nogal nieuw dus ik hoop dat ik het topic in de juiste categorie heb geplaatst.
Maar laat ik het kort houden en gelijk naar het probleem gaan.
Ik heb nogal moeite om data naar mijn database te schrijven door middel van pdo en een query. De variabelen uit mijn register file moeten zijn doorgegeven naar mijn loginmodel. Maar telkens krijg ik deze error waaruit blijkt dat mijn variabelen niet null mogen zijn.

Ik hoop dat jullie enig idee hebben waarom de variabelen leeg zijn. Ze zijn niet allemaal leeg. user_name en user_email komen wel gewoon door, dat is het rare. En op het moment kan ik de fout niet vinden.
Bij voorbaat dank,
Sebastiaan
Hier is mijn loginmodel.php register_new user function.
public function registerNewUser()
{
// perform all necessary form checks
if (!$this->checkCaptcha()) {
$_SESSION["feedback_negative"][] = FEEDBACK_CAPTCHA_WRONG;
} elseif (empty($_POST['user_name'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_USERNAME_FIELD_EMPTY;
} elseif (empty($_POST['user_password_new']) OR empty($_POST['user_password_repeat'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_PASSWORD_FIELD_EMPTY;
} elseif ($_POST['user_password_new'] !== $_POST['user_password_repeat']) {
$_SESSION["feedback_negative"][] = FEEDBACK_PASSWORD_REPEAT_WRONG;
} elseif (strlen($_POST['user_password_new']) < 6) {
$_SESSION["feedback_negative"][] = FEEDBACK_PASSWORD_TOO_SHORT;
} elseif (strlen($_POST['user_name']) > 64 OR strlen($_POST['user_name']) < 2) {
$_SESSION["feedback_negative"][] = FEEDBACK_USERNAME_TOO_SHORT_OR_TOO_LONG;
} elseif (!preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_USERNAME_DOES_NOT_FIT_PATTERN;
} elseif (empty($_POST['user_email'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_EMAIL_FIELD_EMPTY;
} elseif (strlen($_POST['user_email']) > 64) {
$_SESSION["feedback_negative"][] = FEEDBACK_EMAIL_TOO_LONG;
} elseif (!filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
$_SESSION["feedback_negative"][] = FEEDBACK_EMAIL_DOES_NOT_FIT_PATTERN;
} elseif (empty($_POST['user_persnaam'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_PERSNAAM_FIELD_EMPTY;
} elseif (empty($_POST['user_telefoonnummer'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_TELEFOONNUMMER_FIELD_EMPTY;
} elseif (empty($_POST['user_enkelsterkte'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_ENKELSTERKTE_FIELD_EMPTY;
} elseif (empty($_POST['user_dubbelsterkte'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_DUBBELSTERKTE_FIELD_EMPTY;
} elseif (empty($_POST['user_geslacht'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_GESLACHT_FIELD_EMPTY;
} elseif (empty($_POST['user_leeftijd'])) {
$_SESSION["feedback_negative"][] = FEEDBACK_LEEFTIJD_FIELD_EMPTY;
} elseif (!empty($_POST['user_name'])
AND strlen($_POST['user_name']) <= 64
AND strlen($_POST['user_name']) >= 2
AND preg_match('/^[a-z\d]{2,64}$/i', $_POST['user_name'])
AND !empty($_POST['user_enkelsterkte'])
AND !empty($_POST['user_dubbelsterkte'])
AND !empty($_POST['user_telefoonnummer'])
AND !empty($_POST['user_geslacht'])
AND !empty($_POST['user_bondsnummer'])
AND !empty($_POST['user_persnaam'])
AND !empty($_POST['user_leeftijd'])
AND !empty($_POST['user_email'])
AND strlen($_POST['user_email']) <= 64
AND filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)
AND !empty($_POST['user_password_new'])
AND !empty($_POST['user_password_repeat'])
AND ($_POST['user_password_new'] === $_POST['user_password_repeat'])) {
// clean the input
$user_name = strip_tags($_POST['user_name']);
$user_email = strip_tags($_POST['user_email']);
// crypt the user's password with the PHP 5.5's password_hash() function, results in a 60 character
// hash string. the PASSWORD_DEFAULT constant is defined by the PHP 5.5, or if you are using PHP 5.3/5.4,
// by the password hashing compatibility library. the third parameter looks a little bit shitty, but that's
// how those PHP 5.5 functions want the parameter: as an array with, currently only used with 'cost' => XX
$hash_cost_factor = (defined('HASH_COST_FACTOR') ? HASH_COST_FACTOR : null);
$user_password_hash = password_hash($_POST['user_password_new'], PASSWORD_DEFAULT, array('cost' => $hash_cost_factor));
// check if username already exists
$query = $this->db->prepare("SELECT * FROM users WHERE user_name = :user_name");
$query->execute(array(':user_name' => $user_name));
$count = $query->rowCount();
if ($count == 1) {
$_SESSION["feedback_negative"][] = FEEDBACK_USERNAME_ALREADY_TAKEN;
return false;
}
// check if email already exists
$query = $this->db->prepare("SELECT user_id FROM users WHERE user_email = :user_email");
$query->execute(array(':user_email' => $user_email));
$count = $query->rowCount();
if ($count == 1) {
$_SESSION["feedback_negative"][] = FEEDBACK_USER_EMAIL_ALREADY_TAKEN;
return false;
}
// generate random hash for email verification (40 char string)
$user_activation_hash = sha1(uniqid(mt_rand(), true));
// generate integer-timestamp for saving of account-creating date
$user_creation_timestamp = time();
// write new users data into database
$sql = "INSERT INTO users (user_name, user_password_hash, user_email, user_bondsnummer, user_telefoonnummer, user_leeftijd, user_geslacht, user_persnaam, user_dubbelsterkte, user_enkelsterkte, user_creation_timestamp, user_activation_hash, user_provider_type)
VALUES (:user_name, :user_password_hash, :user_email, :user_bondsnummer, :user_telefoonnummer, :user_leeftijd, :user_geslacht, :user_persnaam, :user_dubbelsterkte, :user_enkelsterkte, :user_creation_timestamp, :user_activation_hash, :user_provider_type)";
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($query = $this->db->prepare($sql)) {
$query->execute(array(':user_name' => $user_name,
':user_password_hash' => $user_password_hash,
':user_email' => $user_email,
':user_bondsnummer' => $user_bondsnummer,
':user_telefoonnummer' => $user_telefoonnummer,
':user_leeftijd' => $user_leeftijd,
':user_geslacht' => $user_geslacht,
':user_persnaam' => $user_persnaam,
':user_dubbelsterkte' => $user_dubbelsterkte,
':user_enkelsterkte' => $user_enkelsterkte,
':user_creation_timestamp' => $user_creation_timestamp,
':user_activation_hash' => $user_activation_hash,
':user_provider_type' => 'DEFAULT'));
}else{
echo "\nPDO::errorInfo():\n";
print_r($this->db->errorInfo());
}
$count = $query->rowCount();
if ($count != 1) {
$_SESSION["feedback_negative"][] = FEEDBACK_ACCOUNT_CREATION_FAILED;
return false;
}
// get user_id of the user that has been created, to keep things clean we DON'T use lastInsertId() here
$query = $this->db->prepare("SELECT user_id FROM users WHERE user_name = :user_name");
$query->execute(array(':user_name' => $user_name));
if ($query->rowCount() != 1) {
$_SESSION["feedback_negative"][] = FEEDBACK_UNKNOWN_ERROR;
return false;
}
$result_user_row = $query->fetch();
$user_id = $result_user_row->user_id;
// send verification email, if verification email sending failed: instantly delete the user
if ($this->sendVerificationEmail($user_id, $user_email, $user_activation_hash)) {
$_SESSION["feedback_positive"][] = FEEDBACK_ACCOUNT_SUCCESSFULLY_CREATED;
return true;
} else {
$query = $this->db->prepare("DELETE FROM users WHERE user_id = :last_inserted_id");
$query->execute(array(':last_inserted_id' => $user_id));
$_SESSION["feedback_negative"][] = FEEDBACK_VERIFICATION_MAIL_SENDING_FAILED;
return false;
}
} else {
$_SESSION["feedback_negative"][] = FEEDBACK_UNKNOWN_ERROR;
}
// default return, returns only true of really successful (see above)
return false;
}
en de view register.php
<div class="content">
<!-- echo out the system feedback (error and success messages) -->
<?php $this->renderFeedbackMessages(); ?>
<html>
<h2>Registreren</h2>
<!-- register form -->
<form method="post" action="<?php echo URL; ?>login/register_action" name="registerform">
<!-- the user name input field uses a HTML5 pattern check -->
<h2>Persoonlijke gegevens</h2>
<!-- the naam input field uses a HTML5 pattern check -->
<label for="login_bondsnummer">
Bondsnummer
<span style="display: block; font-size: 12px; color: #999;">(Vul hier als eerst uw acht cijferige bondsnummer in die u op uw pasje kunt vinden)</span>
</label>
<input id="login_input_bondsnummer" class="login_input" type="text" name="user_bondsnummer" />
<!-- the user name input field uses a HTML5 pattern check -->
<label for="login_input_persnaam">
Uw Voornaam + Achternaam
<span style="display: block; font-size: 14px; color: #999;">(Uw volledige naam)</span>
</label>
<input id="login_input_persnaam" class="login_input" type="text" name="user_persnaam"/>
<label for="login_input_telefoonnummer">
Uw Telefoonnummer
<span style="display: block; font-size: 14px; color: #999;">(Uw telefoonnummer)</span>
</label>
<input id="login_input_telefoonnummer" class="login_input" type="text" name="user_telefoonnummer" />
<!-- the user name input field uses a HTML5 pattern check -->
<label for="login_input_enkelsterkte">
Enkelsterkte
<span style="display: block; font-size: 14px; color: #999;">(uw enkelsterkte)</span>
</label>
<input id="login_input_enkelsterkte" class="login_input" type="number" name="user_enkelsterkte" min="1" max="9" value="1" />
<label for="login_input_dubbelsterkte">
Dubbelsterkte
<span style="display: block; font-size: 14px; color: #999;">(uw dubbelsterkte)</span>
</label>
<input id="login_input_enkelsterkte" class="login_input" type="number" name="user_dubbelsterkte" min="1" max="9" value="1" />
<label for="login_input_geslacht">
Geslacht
<span style="display: block; font-size: 14px; color: #999;">(Uw Geslacht)</span>
</label>
<input id="login_input_geslacht" class="login_input" type="radio" name="user_geslacht" value="man" style="vertical-align: middle" /> Man </br>
<input id="login_input_geslacht" class="login_input" type="radio" name="user_geslacht" value="vrouw" style="vertical-align: middle" /> Vrouw </br>
</br>
<label for="login_input_leeftijd">
Uw Leeftijd
<span style="display: block; font-size: 14px; color: #999;">(Uw leeftijd)</span>
</label>
<input id="login_input_leeftijd" class="login_input" type="date" name="user_leeftijd" />
</br>
</br>
<h2>Account Gegevens</h2>
<label for="login_input_username">
Username
<span style="display: block; font-size: 14px; color: #999;">(only letters and numbers, 2 to 64 characters)</span>
</label>
<input id="login_input_username" class="login_input" type="text" pattern="[a-zA-Z0-9]{2,64}" name="user_name" required />
<!-- the email input field uses a HTML5 email type check -->
<label for="login_input_email">
User's email
<span style="display: block; font-size: 14px; color: #999;">
(please provide a <span style="text-decoration: underline; color: mediumvioletred;">real email address</span>,
you'll get a verification mail with an activation link)
</span>
</label>
<input id="login_input_email" class="login_input" type="email" name="user_email" required />
<label for="login_input_password_new">
Password (min. 6 characters!
<span class="login-form-password-pattern-reminder">
Please note: using a long sentence as a password is much much safer then something like "!c00lPa$$w0rd").
Have a look on
<a href="http://security.stackexchange.com/questions/6095/xkcd-936-short-complex-password-or-long-dictionary-passphrase">
this interesting security.stackoverflow.com thread
</a>.
</span>
</label>
<input id="login_input_password_new" class="login_input" type="password" name="user_password_new" pattern=".{6,}" required autocomplete="off" />
<label for="login_input_password_repeat">Repeat password</label>
<input id="login_input_password_repeat" class="login_input" type="password" name="user_password_repeat" pattern=".{6,}" required autocomplete="off" />
</br>
</br>
<!-- show the captcha by calling the login/showCaptcha-method in the src attribute of the img tag -->
<!-- to avoid weird with-slash-without-slash issues: simply always use the URL constant here -->
<img id="captcha" src="<?php echo URL; ?>login/showCaptcha" />
<span style="display: block; font-size: 11px; color: #999; margin-bottom: 10px">
<!-- quick & dirty captcha reloader -->
<a href="#" onclick="document.getElementById('captcha').src = '<?php echo URL; ?>login/showCaptcha?' + Math.random(); return false">[ Reload Captcha ]</a>
</span>
<label>
Please enter these characters
<span style="display: block; font-size: 11px; color: #999;">
Please note: This captcha will be generated when the img tag requests the captcha-generation
(and a real image) from YOURURL/login/showcaptcha. As this is a client-side triggered request, the
$_SESSION["captcha"] dump in the footer will not show the captcha characters. The captcha generation
happens AFTER the rendering of the footer.
</span>
</label>
<input type="text" name="captcha" required />
<input type="submit" name="register" value="Register" />
</form>
</div>
<?php if (FACEBOOK_LOGIN == true) { ?>
<div class="register-facebook-box">
<h1>or</h1>
<a href="<?php echo $this->facebook_register_url; ?>" class="facebook-login-button">Register with Facebook</a>
</div>
<?php } ?>
</div>
[size=xsmall]Toevoeging op 11/01/2015 00:52:35:[/size]
Sorry dat ik het zo vaak geplaatst heb.