1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
<?php
$password = "blabla";
$bdd = new PDO('mysql:host=localhost;dbname=video;charset=utf8', 'root', '');
if(isset($_POST['email']) && isset($_POST['password'])){
if(empty($_POST['email']) || $_POST['password']){
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
if($_POST['password'] == $password){ // si le mot de passe est bon
$file = 'http://localhost/wordpress/wp-content/uploads/edd/2015/05/basmati.mp3';
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
$req = $bdd->prepare('INSERT INTO email VALUES (:email)');
$req->bindValue(':email', $_POST['email']);
$req->execute();
}
else{
echo '<p class="erreur">Mot de passe invalide</p>';
}
}
else{
echo '<p class="erreur"> Email invalide </p>';
}
}
else{
echo '<p class="erreur">Email ou mot de passe vide</p>';
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link href='download.css' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Dosis' rel='stylesheet' type='text/css'>
<title>FREE DOWNLOAD</title>
</head>
<a href="http://localhost/wordpress"><img src="http://localhost/wordpress/wp-content/uploads/2015/05/LOGO-HEADER.png" id="logo"></a>
<body>
<form action="#" method="POST" id="formulaire">
<input type="text" name="password" id="password" placeholder="code téléchargement" required><br>
<input type="email" name="email" id="email" placeholder="email" required><br>
<input type="submit" name="Commander" id="envoyer" value="Commander">
</form>
</body>
</html> |