Bonjour,
j'ai un soucis avec un code pour envoyer des mails directement depuis mon site, voici le code qui fonctionne correctement :
Le HTML
Le PHP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit contenir une adresse e-mail.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' doit contenir un nombre.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est vide.\n'; } } if (errors) alert('Les erreurs suivantes ont été détecté :\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> <fieldset style="margin-top:0"> <legend><h1>Formulaire</h1></legend> <h2>Veuillez remplir les champs suivants afin de nous contacter</h2> <br/> <form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; width:100%;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue"> <div style="line-height: 20px;">Votre e-mail : <input name="from" type="text" id="from" style="float:right; padding:2px; width:320px;" value="<?php if (isset($_POST['from'])) { echo $_GET['from']; } ?>"/></div> <br /> <br /> <div style="line-height: 20px;">Objet : <input name="subject" type="text" id="subject" style="float:right; padding:2px; width:360px;" value="<?php if (isset($_POST['from'])) { echo $_GET['subject']; } ?>"/></div> <br /> <br /> <div style="line-height: 20px;">Code de confirmation : <input name="verif_box" type="text" id="verif_box" style="padding:2px; width:220px;"/> <img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /></div> <br /> <br /> <!-- if the variable "wrong_code" is sent from previous page then display the error field --> <?php if(isset($_GET['wrong_code'])){?> <div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;">Code de confirmation incorrect !</div><br /> <?php ;}?> Message :<br /> <textarea name="message" cols="6" rows="5" id="message" style="padding:2px; width:100%; height:100px;"><?php if (isset($_POST['from'])) { echo $_GET['message']; } ?></textarea><br /> <center><input name="Submit" type="submit" style="margin-top:10px; padding:0 5px;" value="Envoyer le Message"/></center> </form> </fieldset>
Maintenant, je voudrais faire un formulaire pour signaler un bug, donc je veux que le sujet du message soit 'bug', ajouter un nouveau champ en plus du message et mettre le tout en forme :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 $subject = $_POST["subject"]; $message = $_POST["message"]; $from = $_POST["from"]; $verif_box = $_POST["verif_box"]; // remove the backslashes that normally appears when entering " or ' $message = stripslashes($message); $subject = stripslashes($subject); $from = stripslashes($from); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page mail("contact@domaine.fr", .$subject, $_SERVER['REMOTE_ADDR']."\n\n".$message, "From: $from"); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else if(isset($message) and $message!=""){ // if verification code was incorrect then return to contact page and show error header("Location: contact.php?subject=$subject&from=$from&message=".urlencode($message)."&wrong_code=true"); exit; } else { echo "no variables received, this page cannot be accessed directly"; exit; } ?>
HTML
PHP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <script type="text/JavaScript"> <!-- function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit contenir une adresse e-mail.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' doit contenir un nombre.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' est vide.\n'; } } if (errors) alert('Les erreurs suivantes ont été détecté :\n'+errors); document.MM_returnValue = (errors == ''); } //--> </script> <fieldset style="margin-top:0"> <legend><h1>Formulaire</h1></legend> <h2>Veuillez remplir les champs suivants afin que notre équipe puisse supprimer le bug le plus rapidement possible</h2> <br/> <form action="mailerdead.php" method="post" name="form1" id="form1" style="margin:0px; width:100%;" onsubmit="MM_validateForm('from','','RisEmail','verif_box','','R','adresse','','R','message','','R');return document.MM_returnValue"> <div style="line-height: 20px;">Votre e-mail : <input name="from" type="text" id="from" style="float:right; padding:2px; width:320px;" value="<?php if (isset($_POST['from'])) { echo $_GET['from']; } ?>"/></div> <br /> <br /> <div style="line-height: 20px;">Code de confirmation : <input name="verif_box" type="text" id="verif_box" style="padding:2px; width:220px;"/> <img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /></div> <br /> <br /> <!-- if the variable "wrong_code" is sent from previous page then display the error field --> <?php if(isset($_GET['wrong_code'])){?> <div style="border:1px solid #990000; background-color:#D70000; color:#FFFFFF; padding:4px; padding-left:6px;width:295px;">Code de confirmation incorrect !</div><br /> <?php ;}?> <div style="line-height: 20px;">Adresse de la page : <input name="adresse" type="text" id="adresse" style="float:right; padding:2px; width:290px;" value="<?php if (isset($_POST['from'])) { echo $_GET['adresse']; } ?>"/></div> <br /> <br /> Description du bug :<br /> <textarea name="message" cols="6" rows="5" id="message" style="padding:2px; width:100%; height:100px;"><?php if (isset($_POST['from'])) { echo $_GET['message']; } ?></textarea><br /> <center><input name="Submit" type="submit" style="margin-top:10px; padding:0 5px;" value="Envoyer le Message"/></center> </form> </fieldset>
et là j'ai l'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 $adresse = $_POST["adresse"]; $message = $_POST["message"]; $from = $_POST["from"]; $verif_box = $_POST["verif_box"]; // remove the backslashes that normally appears when entering " or ' $message = stripslashes($message); $adresse = stripslashes($adresse); $from = stripslashes($from); // check to see if verificaton code was correct if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ // if verification code was correct send the message and show this page mail("deadlink@domaine.fr", "bug", $_SERVER['REMOTE_ADDR']."\n\n <b>Adresse de la page</b> : <a href=/"" .$adresse. "/">Page du bug</a>\n\n".$message, "From: $from"); // delete the cookie so it cannot sent again by refreshing this page setcookie('tntcon',''); } else if(isset($message) and $message!=""){ // if verification code was incorrect then return to contact page and show error header("Location: deadbug.php?subject=Bug&from=$from$adresse=".urlencode($adresse)."&message=".urlencode($message)."&wrong_code=true"); exit; } else { echo "no variables received, this page cannot be accessed directly"; exit; } ?>
donc le problème vient de là :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /mailerdead.php on line 21
Je ne vois pas comment faire, le but est d'avoir "Adresse de la page" en gras avec l'url à côté, un saut de 2 lignes et le message.
Code : Sélectionner tout - Visualiser dans une fenêtre à part $_SERVER['REMOTE_ADDR']."\n\n <b>Adresse de la page</b> : <a href=/"" .$adresse. "/">Page du bug</a>\n\n".$message
Quelqu'un peut-il m'aider s'il vous plait ?
Partager