Hallo beste mensen van het forum PHP Hulp,
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.
Als waarden niet null mogen zijn, kun je in de query '' gebruiken voor een lege string.
of je past de tabelstructuur aan zodat ze wel NULL mogen zijn.
Ja het probleem is meer dat de gegevens van de register pagina niet opgeslagen worden in de variabelen. En daarom krijg ik geloof ik de error dat mn query null aangeeft. Het probleem is meer dus om op te lossen dat ik de variabelen gevuld krijg zeg maar. Ik had de code erbij geplaatst maar die is zo te zien niet door gekomen. Ik pas dat zo even aan.
Frank Nietbelangrijk op 11/01/2015 11:35:41

of je past de tabelstructuur aan zodat ze wel NULL mogen zijn.

Ahum, om een integrity constraint violation te vermijden de constraint verwijderen????

Ik begin me af te vragen hoe jou database modellen er uit zien :-P
Ger van Steenderen op 11/01/2015 14:03:04

de constraint verwijderen????


Dat heb ik niet gezegd.
Ger, de foutmelding en de OORZAAK van de foutmelding zijn twee verschillende dingen.
Frank, ik weet niet wat je daarmee wilt zeggen, maar de oorzaak van de foutmelding is niet de NOT NULL constraint, maar dat er NULL wordt geprobeerd in te voegen in een kolom met een NOT NULL constraint.

Die constraint staat er niet voor niets, dus weghalen is absoluut geen optie.
Ik heb het idee dat er iets fout gaat bij het doorgeven van de variabelen van mijn submit form(action=post). Er lijkt iets fout te gaan bij het gedeelte van view->controlller->model en weer terug. Het klinkt misschien raar, maar het lijkt er op dat de controller de parameters leegt of niet geheel doorgeeft aan het model.
Hopelijk kan iemand mij helpen of heeft de gouden tip
Hier is de code van de controller:

<?php

/**
* Class Application
* The heart of the app
*/
class Application
{
/** @var null The controller part of the URL */
private $url_controller;
/** @var null The method part (of the above controller) of the URL */
private $url_action;
/** @var null Parameter one of the URL */
private $url_parameter_1;
/** @var null Parameter two of the URL */
private $url_parameter_2;
/** @var null Parameter three of the URL */
private $url_parameter_3;

/**
* Starts the Application
* Takes the parts of the URL and loads the according controller & method and passes the parameter arguments to it
* TODO: get rid of deep if/else nesting
* TODO: make the hardcoded locations ("error/index", "index.php", new Index()) dynamic, maybe via config.php
*/
public function __construct()
{
$this->splitUrl();

// check for controller: is the url_controller NOT empty ?
if ($this->url_controller) {
// check for controller: does such a controller exist ?
if (file_exists(CONTROLLER_PATH . $this->url_controller . '.php')) {
// if so, then load this file and create this controller
// example: if controller would be "car", then this line would translate into: $this->car = new car();
require CONTROLLER_PATH . $this->url_controller . '.php';
$this->url_controller = new $this->url_controller();

// check for method: does such a method exist in the controller ?
if ($this->url_action) {
if (method_exists($this->url_controller, $this->url_action)) {

// call the method and pass the arguments to it
if (isset($this->url_parameter_3)) {
$this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2, $this->url_parameter_3);
} elseif (isset($this->url_parameter_2)) {
$this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2);
} elseif (isset($this->url_parameter_1)) {
$this->url_controller->{$this->url_action}($this->url_parameter_1);
} else {
// if no parameters given, just call the method without arguments
$this->url_controller->{$this->url_action}();
}
} else {
// redirect user to error page (there's a controller for that)
header('location: ' . URL . 'error/index');
}
} else {
// default/fallback: call the index() method of a selected controller
$this->url_controller->index();
}
// obviously mistyped controller name, therefore show 404
} else {
// redirect user to error page (there's a controller for that)
header('location: ' . URL . 'error/index');
}
// if url_controller is empty, simply show the main page (index/index)
} else {
// invalid URL, so simply show home/index
require CONTROLLER_PATH . 'index.php';
$controller = new Index();
$controller->index();
}
}

/**
* Gets and splits the URL
*/
private function splitUrl()
{
if (isset($_GET['url'])) {

// split URL
$url = rtrim($_GET['url'], '/');
$url = filter_var($url, FILTER_SANITIZE_URL);
$url = explode('/', $url);

// Put URL parts into according properties
// By the way, the syntax here if just a short form of if/else, called "Ternary Operators"
// http://davidwalsh.name/php-shorthand-if-else-ternary-operators
$this->url_controller = (isset($url[0]) ? $url[0] : null);
$this->url_action = (isset($url[1]) ? $url[1] : null);
$this->url_parameter_1 = (isset($url[2]) ? $url[2] : null);
$this->url_parameter_2 = (isset($url[3]) ? $url[3] : null);
$this->url_parameter_3 = (isset($url[4]) ? $url[4] : null);
}
}
}

en dit is mijn function uit mn model:
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{
print_r($_POST);
echo "\nPDO::errorInfo():\n";
print_r($this->db->errorInfo());
}

Reageren