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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
| <?php
session_start();
require('config.php');
if(!empty($_POST))
{
extract($_POST);
$valid = true;
if(empty($login))
{
$valid = false;
$erreurpseudo = 'Renseignez ce champs';
}
if(!empty($login) && strlen($login)<3)
{
$valid = false;
$erreurlogin = '3 caractères minimum';
}
if(empty($email))
{
$valid = false;
$erreurmail = 'Renseignez ce champs';
}
if(!empty($email) && filter_var($email, FILTER_VALIDATE_EMAIL) === false)
{
$valid = false;
$erreurmail = 'Adresse e-mail invalide';
}
if(!empty($url) && filter_var($url, FILTER_VALIDATE_URL) === false)
{
$valid = false;
$erreururl = 'Url invalide';
}
if(empty($commentaire))
{
$valid = false;
$erreurcommentaire = 'Renseignez votre commentaire';
}
if(!empty($commentaire) && strlen($commentaire)<15)
{
$valid = false;
$erreurcommentaire = '15 caractères minimum';
}
if($valid)
{
$login = strip_tags($login);
$email = strip_tags($email);
$url = strip_tags($url);
$commentaire = strip_tags($commentaire);
$req = $bdd->prepare('INSERT INTO commentaire (login,email,url,commentaire) VALUES (:login,:email,:url,:commentaire)');
$req->execute(array(
'login'=>$login,
'email'=>$email,
'url'=>$url,
'commentaire'=>$commentaire
));
$req->closeCursor();
unset($login);
unset($email);
unset($url);
unset($commentaire);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hof-ten-berg</title>
<link href="css/design.css" rel="stylesheet" type="text/css" media="screen" />
<?php include('script.php'); ?>
</head>
<body>
<!--début container-->
<div id="container">
<?php include('banner.php'); ?>
<!--début main-->
<div id="main">
<!--début content-->
<div id="content">
<?php
if(!empty($_GET['id']))
{
$id = $_GET['id'];
echo $id;
}
$req = $bdd->prepare('SELECT * FROM news WHERE id=:id');
$req->execute(array('id'=>$id));
while($data = $req->fetch(PDO::FETCH_OBJ))
{
?>
<!--news1-->
<div class="news-complet">
<div class="topic-complet">
<h2><?php echo $data->titre; ?></h2>
<p class="post">Posté le <?php echo date('d/m/Y',strtotime($data->date)); ?> à <?php echo date('H:i',strtotime($data->date)); ?></p>
<hr/>
<img class="illustration" src="images/img-article1.png" alt="illustration" />
<p class="text"><?php echo $data->contenu; ?></p>
</div>
</div>
<!--fin news1-->
<?php
}
$req->closeCursor();
?>
<div id="form">
<h3>Laissez un commentaire</h3>
<form action="voir.php" method="post" id="formulaire">
<label for="pseudo">Pseudo :</label>
<div class="error"><?php if(isset($erreurlogin)) echo $erreurlogin;?></div>
<input type="text" name="login" id="login" value="<?php if(isset($login)) echo $login;?>" />
<label for="email">E-mail :</label>
<div class="error"><?php if(isset($erreurmail)) echo $erreurmail;?></div>
<input type="text" name="email" id="email" value="<?php if(isset($email)) echo $email;?>" />
<label for="pseudo">Site Web :</label>
<div class="error"><?php if(isset($erreururl)) echo $erreururl;?></div>
<input type="text" name="url" id="url" value="<?php if(isset($url)) echo $url;?>" />
<label for="pseudo">Commentaire:</label>
<div class="error"><?php if(isset($erreurcommentaire)) echo $erreurcommentaire;?></div>
<textarea name="commentaire" id="commentaire"><?php if(isset($commentaire)) echo $commentaire;?></textarea>
<input type="submit" value="Envoyer" />
</form>
</div>
</div>
<!--fin content-->
<?php include('sidebar.php'); ?>
</div>
<!--fin main-->
<?php include('footer.php'); ?>
</div>
<!--fin container-->
</body>
</html> |
Partager