I'm new on MVC method, I'm trying to add a new user to the database from a form, but after filling and submiting the form, it is not working; all I have is just a blank page.
the model.php
// Add user form
public function addNewUser($rank,$type,$subtype,$email,$password,$lastname,$firstname,$phone,$country,$city,$adress,$company,$gender,$birth_date) {
$db = $this->dbConenct();
$req = $db->prepare('INSERT INTO crm_users(rank,type,subtype,email,password,lastname,firstname,phone,country,city,adress,company,gender,birth_date,reg_date)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,NOW())');
$addNewUser = $req->execute(array($rank,$type,$subtype,$email,$password,$lastname,$firstname,$phone,$country,$city,$adress,$company,$gender,$birth_date));
return $addNewUser;
}
the controler.php
// Add a new user
function newUser($rank,$type,$subtype,$email,$password,$lastname,$firstname,$phone,$country,$city,$adress,$company,$gender,$birth_date) {
$usersManager = new UsersManager();
$addNewUser = $usersManager->addNewUser($rank,$type,$subtype,$email,$password,$lastname,$firstname,$phone,$country,$city,$adress,$company,$gender,$birth_date);
// header('Location: ?content=users');
}
the router.php
newUser($_POST['rank'],$_POST['type'],$_POST['subtype'],$_POST['email'],$_POST['password'],$_POST['lastname'],$_POST['firstname'],$_POST['phone'],$_POST['country'],$_POST['city'],$_POST['adress'],$_POST['company'],$_POST['gender'],$_POST['birth_date']);
and the view.php
<form action="?content=users&action=addNewUser" method="POST" id="addUserForm">
<input type="text" name="lastname" placeholder="Nom..." required>
<input type="text" name="firstname" placeholder="Prénom..." required>
<input type="date" name="birth_date" placeholder="Date de naissance...">
<input type="hidden" name="password" value="test">
<input type="text" name="company" placeholder="Entreprise...">
<select name="country" required>
<option value="" disabled selected>Pays</option>
<option value="Algeria">Algeria</option>
</select>
<input type="text" name="city" placeholder="Ville...">
<input type="text" name="adress" placeholder="Adresse...">
<input type="radio" name="gender" value="Homme">
<input type="radio" name="gender" value="Femme">
<select name="rank" required>
<option value="" disabled selected>Rang</option>
<option value="2">Administrateur</option>
<option value="1">Utilisateur</option>
</select>
<select name="type" required>
<option value="" disabled selected>Type</option>
<option value="Cominvolt">Cominvolt</option>
</select>
<select name="subtype" required>
<option value="" disabled selected>Sous-type</option>
<option value="Développement">Développement</option>
</select>
<input type="email" name="email" placeholder="E-mail..." required>
<input type="tel" name="phone" placeholder="Numéro de téléphone..." required>
<button type="submit">AJOUTER</button>
</form>
Thank you very much for your time and help.
Comments
Post a Comment