My php script doesn't work (no entries are added) while my others scripts work, they are different but similar, only the values and fields are different. Does anyone know why? The form part works, my values are correct but there are no new entries in my database and no errors are reported.
if(isset($_POST['id_discord']) AND !empty($_POST['id_discord'])) {
try {
$bdd = new PDO('mysql:host=localhost:3306;dbname=teg;charset=utf8', 'username', 'password');
}
catch (Exception $e){
die('Erreur : ' . $e->getMessage());
}
$req = $bdd->prepare('INSERT INTO staff(id_discord, pseudo_discord, discord_tag, pseudo_mc, UUID, rank, rank_level, description, twitter, youtube, twitch, instagram) VALUES (:id_discord, :pseudo_discord, :discord_tag, :pseudo_mc, :UUID, :rank, :rank_level, :description, :twitter, :youtube, :twitch, :instagram);') or die(print_r($bdd->errorInfo()));;
$req->execute(array(
'id_discord' => $_POST['id_discord'],
'pseudo_discord' => $_POST['pseudo_discord'],
'discord_tag' => '#' . $_POST['discord_tag'],
'pseudo_mc' => $_POST['pseudo_mc'],
'UUID' => $_POST['UUID'],
'rank' => $_POST['rank'],
'rank_level' => $_POST['rank_level'],
'description' => $_POST['description'],
'twitter' => $_POST['twitter'],
'youtube' => $_POST['youtube'],
'twitch' => $_POST['twitch'],
'instagram' => $_POST['instagram']
));
}
This is another script for another form and it works, but they are the same, only values and fields are different
if(isset($_POST['numero']) AND !empty($_POST['numero'])) {
try {
$bdd = new PDO('mysql:host=localhost:3306;dbname=teg;charset=utf8', 'username', 'password');
}
catch (Exception $e){
die('Erreur : ' . $e->getMessage());
}
$req = $bdd->prepare('INSERT INTO kiosque(numero, date_publication, description, edition, calameo, reading_time) VALUES (:numero, :date_publication, :description, :edition, :calameo, :reading_time);') or die(print_r($bdd->errorInfo()));;
$req->execute(array(
'numero' => $_POST['numero'],
'date_publication' => $_POST['date_publication'],
'description' => $_POST['description'],
'edition' => $_POST['edition'],
'calameo' => $_POST['calameo'],
'reading_time' => $_POST['reading_time']));
/* Form files */
if (isset($_FILES['pdf']['tmp_name'])) {
$destination = '/var/www/vhosts/theelderguardian.fr/httpdocs/resources/kiosque/';
$entire_path = $destination . $_POST['edition'] . '.pdf';
// move_uploaded_file($_FILES['pdf']['tmp_name'], $destination.$_FILES['pdf']['name']);
rename($_FILES['pdf']['tmp_name'], $entire_path);
chmod($entire_path, 0644);
}
if (isset($_FILES['first_page']['tmp_name'])) {
$destination = '/var/www/vhosts/theelderguardian.fr/httpdocs/resources/kiosque/';
$entire_path = $destination . $_POST['edition'] . '.png';
// move_uploaded_file($_FILES['pdf']['tmp_name'], $destination.$_FILES['pdf']['name']);
rename($_FILES['first_page']['tmp_name'], $entire_path);
chmod($entire_path, 0644);
}
if (isset($_FILES['thumbnail']['tmp_name'])) {
$destination = '/var/www/vhosts/theelderguardian.fr/httpdocs/resources/kiosque/';
$entire_path = $destination . $_POST['edition'] . '_thumbnail.png';
// move_uploaded_file($_FILES['pdf']['tmp_name'], $destination.$_FILES['pdf']['name']);
rename($_FILES['thumbnail']['tmp_name'], $entire_path);
chmod($entire_path, 0644);
}
}