Ajouter un contrat


[insert_php]

try {
$bdd = new PDO(‘mysql:host=abassurcfxab.mysql.db;dbname=abassurcfxab;charset=utf8’, ‘abassurcfxab’, ‘TYm77GFPSzzg’);

} catch (PDOException $e) {

echo ‘‘;
die();
}
$id=$_GET[‘id’];

$reponse = $bdd->query(‘SELECT * FROM wp_users WHERE ID = ‘.$id);
$donnees = $reponse->fetch();
[/insert_php]
[insert_php]
if (!file_exists(Upload_contrat)) {
//Créer un dossier ‘Upload_contrat/’
mkdir(‘Upload_contrat/’, 0777, true);

//Créer un identifiant difficile à deviner
$nom = md5(uniqid(rand(), true));
}
[/insert_php]

Ajouter un contrat






[insert_php]
// On commence par récupérer les champs
if(isset($_POST[‘inserer’]))
{
// Creates the Variables needed to upload the file

$UploadName = $_FILES[‘UploadFileField’][‘name’];
$UploadName = mt_rand(100000, 999999).$UploadName;
$UploadTmp = $_FILES[‘UploadFileField’][‘tmp_name’];
$UploadType = $_FILES[‘UploadFileField’][‘type’];
$FileSize = $_FILES[‘UploadFileField’][‘size’];

// Removes Unwanted Spaces and characters from the files names of the files being uploaded

$UploadName = preg_replace(« #[^a-z0-9.]#i », «  », $UploadName);

// Upload File Size Limit

if(($FileSize > 1250000)){

die(« Error – File to Big »);

}

// Checks a File has been Selected and Uploads them into a Directory on your Server

if(!$UploadTmp){
die(« Aucun fichier sélectionné, veuillez télécharger à nouveau »);
}
else if ( $UploadType != « application/pdf ») {

die( « L’extension de fichier n’est pas de type PDF.!! »);
}else{
move_uploaded_file($UploadTmp, « Upload_contrat/$UploadName »);
}
if(isset($_POST[‘user_nicename’])) $user_nicename=$_POST[‘user_nicename’];
else $user_nicename= » »;

if(isset($_POST[‘user_email’])) $user_email=$_POST[‘user_email’];
else $user_email= » »;

if(isset($_POST[‘user_registered’])) $user_registered=$_POST[‘user_registered’];
else $user_registered= » »;

if(isset($_POST[‘contrat_description’])) $contrat_description=$_POST[‘contrat_description’];
else $contrat_description= » »;

if(isset($_POST[‘contrat_url’])) $contrat_url=$_POST[‘contrat_url’];
else $contrat_url= » »;

$idCci = $_GET[‘id’];

$req = $bdd->prepare(‘INSERT INTO wp_contrats(ID_user, user_nicename, user_email,user_registered , contrat_description, contrat_url,contrat_registered) VALUES(:ID_user, :user_nicename, :user_email, :user_registered, :contrat_description, :UploadName, NOW())’);
$req->execute(array(

‘ID_user’ => $idCci,
‘user_nicename’ => $user_nicename,
‘user_email’ => $user_email,
‘user_registered’ => $user_registered,
‘contrat_description’ => $contrat_description,
‘UploadName’ => $UploadName,
));

if($req)
{
//echo ‘‘;

//Redirection de l’admin vers la page de consultation
header(‘Location: http://espace.ab-assur.com/consulter-la-liste-des-clients/’);
exit();

}
else {
echo ‘‘;
}
}[/insert_php]