Bonjour
Je suis novice dans la programmation en php... Je suis actuellement occupé de créer un site internet pour des amis qui parte faire un tour du monde en solex.
Je leur est faite leur site (je suis étudiant graphiste), mais je ne suis pas programmeur...
J'ai été ennuié par des injections (html iframe-inf..) est je cherche a empêcher l'injection dans le formulaire... htmlentities serais la meilleur solution, mais je ne sais pas ou le mettre dans mon code... Je cherche donc quelqu'un pour aider un pauvre novice qui subis les injections et qui ne sais comment lutter
merci d'avance
voici mon code :
<?php
//
// Verifier que les informations sont postes
//
if($_POST['submit_mess']) {
if(isset($_POST) && isset($_POST['name']) && isset($_POST['surname']) && isset($_POST['mail']) && isset($_POST['message'])) {
extract($_POST);
// Simplifier l'criture de "$_POST["nomdelavarible] en "$nomdelavariable"
if(!empty($name) && !empty($surname) && !empty($mail) && !empty($message)) {
// Dfinition des variables
$message=str_replace("\"","'",$message);
$message=str_replace("v","",$message);
$message=str_replace("","",$message);
$message=str_replace("v","",$message);
$message=str_replace("v","",$message);
// Remplacer des caractres spciaux
$destinataire="contact@avelosolex.com";
$expediteur=$mail;
$reponse=$expediteur;
$sujet="Message du site français";
// Retour la ligne : \n
$message="Un nouveau message du site francais est arrive\n
Name : $name \n
Surname : $surname \n
Mail : $mail \n
Message : $message";
$entete="From: $mail";
mail($destinataire, $sujet, $message, $entete);
}
}
}
<html>
<head>
<title>avelosolex.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="css/template.css" rel="stylesheet" type="text/css">
<link href="css/contact.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="Javascript" >
function check() {
// D?claration de la variable pour le message type qui s'affichera
var msg = 'Merci de remplir les champs présents :\n \n' ;
var lgMsg = msg.length;
// D?claration des variables pour les expressions r?guli?res
var mail = new RegExp(/^[A-Za-z0-9\.\-_]+@[A-Za-z0-9\-]+\.[a-zA-Z\.\-_]{1,}/gi);
// Test des diff?rents champs
// V?rification du nom
if (document.form.name.value == "" || document.form.name.value == "Name") {
msg += '- Name\n';
document.form.name.style.backgroundColor = "#FF0000";
}
// V?rification du pr?nom
if (document.form.surname.value == "" || document.form.surname.value == "Surname") {
msg += '- Surname\n';
document.form.surname.style.backgroundColor = "#FF0000";
}
// V?rification du mail
if (document.form.mail.value == '' || !mail.test(document.form.mail.value)) {
msg += '- Mail (ex : \"xxxx@yyyy.zzzz\")\n';
document.form.mail.style.backgroundColor = "#FF0000";
}
// V?rification du message
if (document.form.message.value == 'Message' || document.form.message.value == '') {
msg += '- Message\n';
document.form.message.style.backgroundColor = "#FF0000";
}
// Message si les champs ne sont pas remplis correctement
if ( msg.length > lgMsg ) {
alert(msg);
return(false);
// Message si tout est OK
} else {
alert('Merci pour votre message.\nil est envoyé...\ncliquez sur ok pour continuer.\nCette page sera rafreshie.');
return(true);
}
}
//-->
</script>
<style type="text/css">
<!--
.Style1 {color: #FF0000}
-->
</style>
</head>
<body background="images/template/fond.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="894" height="899" border="0" align="center" cellpadding="0" cellspacing="0" id="Tableau_01">
<tr>
<td height="129" background="images/template/banner.gif"><table width="896" height="111" border="0">
<tr>
<td width="688"> </td>
<td width="198"> </td>
</tr>
<tr>
<td> </td>
<td valign="bottom"><form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="4652532">
<input type="image" src="http://www.avelosolex.com/fr/images/template/DON.gif" border="0" name="submit" alt="PayPal - la solution de paiement en ligne la plus simple et la plus sécurisée !">
<img alt="" border="0" src="https://www.paypal.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>
</td>
</tr>
</table> </td>
</tr>
<tr>
<td width="894" height="736" background="images/template/arriere_plan.jpg"><table height="736" border="0">
<tr>
<td rowspan="2" width="197" id="entremenu" valign="top">
<table border="0" align="center"id="table_menu">
<tr>
<td width="138" height="30" colspan="7" background="images/template/cellule_menu.gif" id="menutxt"><a href="presentation.html" class="link">PRESENTATION</a></td>
</tr>
<tr>
<td width="138" height="6" colspan="7"></td>
</tr>
<tr>
<td width="138" height="30" colspan="7" background="images/template/cellule_menu.gif" id="menutxt" ><a href="itineraire.html" class="link">ITINERAIRE</a></td>
</tr>
<tr>
<td width="138" height="6" colspan="7"></td>
</tr>
<tr>
<td width="138" height="30" colspan="7" background="images/template/cellule_menu.gif" id="menutxt"><a href="reportage.html" class="link">REPORTAGE</a></td>
</tr>
<tr>
<td width="138" height="6" colspan="7"></td>
</tr>
<tr>
<td width="138" height="30" colspan="7" background="images/template/cellule_menu.gif"id="menutxt"><a href="equipe.html" class="link">L'EQUIPE</a></td>
</tr>
<tr>
<td width="138" height="6" colspan="7"></td>
</tr>
<tr>
<td width="138" height="32" colspan="7" valign="top" background="images/template/cellule_menu.gif" id="menutxt"><a href="sponsors.html" class="link">PRESSE ET <br>
SPONSORS</a></td>
</tr>
<tr>
<td width="138" height="6" colspan="7"></td>
</tr>
<tr>
<td width="138" height="30" colspan="7" background="images/template/cellule_menu.gif" id="menutxt"><a href="http://www.avelosolex.com/aventures" class="link" target="_blank">SUIVRE NOS AVENTURES
</td>
</tr>
<tr>
<td width="138" height="6" colspan="7">
</td>
</tr>
<tr>
<td width="138" height="32" colspan="7" valign="middle" background="images/template/cellule_menu_ac.gif" id="menutxt"><a href="contact.php" class="link" >CONTACT</a></td>
</tr>
<tr>
<td width="138" height="32" colspan="7" valign="middle" background="images/template/cellule_menu.gif" id="menutxt"><a href="liens.html" class="link">LIENS</a></td>
</tr>
<tr>
<td width="138" height="1" colspan="7"></td>
</tr>
<tr>
<td width="138" height="1" colspan="7"></td>
</tr>
<tr>
<td width="138" height="35" colspan="7" id="newsletter"><a href="newsletter.php" class="link">>>>INSCRIPTION A LA <br>
//// NEWSLETTER ////</a></td>
</tr>
<tr>
<td width="138" height="10" colspan="7"></td>
</tr>
<tr>
<td height="14"></td>
<td><div align="center"><a href="../fr/contact.php"><img src="images/template/fr.png" width="24" height="24" border="0"></a></div></td>
<td></td>
<td><div align="center"><a href="../es/contact.php"><img src="images/template/es.png" width="24" height="24" border="0"></a></div></td>
<td></td>
<td><div align="center"><a href="../en/contact.php"><img src="images/template/en.png" width="24" height="24" border="0"></a></div></td>
<td></td>
</tr>
</table> </td>
<td height="11" background="images/template/barre_txt_defilement.png" id="defilement"><table width="691" border="0">
<tr>
<td width="74"></td>
<td width="364" id="defilement_txt"><marquee direction="left" scrollamount="4" height="12" bgcolor="#EEE8C6" width="364">
<font face="arial" size="3"><a href="../besoins.html" class="link">>>Pour savoir comment nous aider <span class="Style1">CLIQUEZ-ICI</span><< >>Pour savoir comment nous aider</a></font>
</marquee></td>
<td width="239"></td>
</tr>
</table></td>
</tr>
<tr>
<td width="713" height="342"><div align="center">
<p id="menutxt"><br>
Contact Par mail</p>
<div id="form_container">
<form name="form" class="appnitro" method="post" action="contact.php?test" onSubmit="return check()" enctype="multipart/form-data">
<ul>
<p><input name="name" class="element text medium" type="text" maxlength="255" value="Votre prénom" onFocus="javascript:this.value=''" onBlur="javascript:this.style.backgroundColor='#FFFFFF'" height="10" /> </p>
<p> <input name="surname" class="element text medium" type="text" maxlength="255" value="Votre nom" onFocus="javascript:this.value=''" onBlur="javascript:this.style.backgroundColor='#FFFFFF'" height="10"/></p>
<p><input name="mail" class="element text medium" type="text" maxlength="255" value="Votre e-mail" onFocus="javascript:this.value=''" onBlur="javascript:this.style.backgroundColor='#FFFFFF'" height="10"/></p>
<p>
<textarea name="message" class="element textarea medium" onFocus="javascript:this.value=''" onBlur="javascript:this.style.backgroundColor='#FFFFFF'" height="50"></textarea>
</p>
<p><input class="button_text" type="submit" name="submit_mess" value="Envoyer" />
<input class="button_text" type="reset" name="delete" value="Effacer" /></p>
</form>
</div>
</div></td> </tr>
<tr>
<td colspan="2"><div></div></td> </tr>
</table></td>
</tr>
<tr>
<td bgcolor="#732318" id="menubas"><a href="mentions-legale.html" class="link-bas">MENTIONS LEGALES</a> - <a href="plan.html" class="link-bas">PLAN DU SITE</a></td>
</tr>
<tr>
<td>
<img src="images/template/cal_bas.jpg" width="894" height="18" alt=""></td>
</tr>
</table>
</body>
</html>