I have a problem when uploading the data, when I register it, it sends me the message that "supposedly" the function execute () returned "true", but when I check my db, nothing of the data appears.
I'm using PDO and so I have the codes: controller.php (the one that receives the form data)
<?php
class MvcController {
public function Template () {
include 'Views/Templated/template.php';
}
public function NavPageLoginController(){
if (isset($_GET['nav'])){
$link = $_GET['nav'];
} else {
$link = "Login";
}
$request = NavPageLogin::LinkPageLogin($link);
include $request;
}
public function NavPageController() {
if (isset($_GET['nav'])) {
$link = $_GET['nav'];
} else {
$link = "Home";
}
$request = NavPage::LinkPage($link);
include $request;
}
public function RegisterUserController(){
if (isset($_POST['ci'])) {
$date = 0;
$access = 0;
$Data = array("name" => $_POST['name'],
"surname" => $_POST['surname'],
"email" => $_POST['email'],
"password" => $_POST['password'],
"year" => $_POST['year'],
"ci" => $_POST['ci'],
"country" => $_POST['country'],
"photo" => $_FILES['photoprofile'],
"date" => $date,
"access" => $access);
$request = Data::RegisterUserModel($Data, "users");
if ($request == "success") {
echo "Listo";
}
}
}
}
?>
CRUD.php (the one that handles queries and send them back to the Controller)
<?php require 'Models/CORE.php';
class Data extends Connection {
public function RegisterUserModel($data, $table){
if ($data['photo']){
global $dirupload;
global $rupload;
$ci = $data['ci'];
$dirupload = "photoprofile/$ci/";
$photo = $data['photo'];
$namephoto = $photo['name'];
$nameTmp = $photo['tmp_name'];
$rupload = "{$dirupload}profile.jpg";
$extArchive = preg_replace( '/image\//', '', $photo['type'] );
if( $extArchive == 'jpeg' || $extArchive == 'png') {
if( !file_exists( $dirupload ) ) {
mkdir( $dirupload, 775, true );
}
if( move_uploaded_file( $nameTmp, $rupload ) ) {
return true;
} else {
return false;
}
} else {
$photoinvalid = true;
}
}
$stmt = Connection::Connect()->prepare("INSERT INTO $table(name, surname, email, pass, ci, year, country, rupload) VALUES (:name,:surname,:email,:password,:year,:ci,:country,:photo)");
$stmt->bindParam(':name', $data['name'], PDO::PARAM_STR);
$stmt->bindParam(':surname', $data['surname'], PDO::PARAM_STR);
$stmt->bindParam(':email', $data['email'], PDO::PARAM_STR);
$stmt->bindParam(':password', $data['password'], PDO::PARAM_STR);
$stmt->bindParam(':year', $data['year'], PDO::PARAM_INT);
$stmt->bindParam(':ci', $data['ci'], PDO::PARAM_INT);
$stmt->bindParam(':country', $data['country'], PDO::PARAM_STR);
$stmt->bindParam(':photo', $rupload, PDO::PARAM_LOB);
if ($stmt->execute()) {
return "success";
} else {
return "error";
}
}
}
?>
The weirdest thing is that if I change the word "success" for any other word, I continue to press the word "Ready" which is what confuses me. Thanks in advance