Page 1 sur 1

Transformation

Posté : 28 oct. 2011, 00:45
par thenavy
Bonjour, voila j'ai un petit problème qui ce pose, j'ai un serveur web loger chez moi et donc je n'arrive pas a configurer mon serveur smtp etc ... j'ai donc un formulaire de commentaire par envoie d'email, j'ai celui de base :
<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+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\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+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>
 
<form action="mailer.php" method="post" name="form1" id="form1" style="margin:0px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px; width:300px;" onsubmit="MM_validateForm('from','','RisEmail','subject','','R','verif_box','','R','message','','R');return document.MM_returnValue">

Votre E-Mail :<br />
<input name="from" type="text" id="from" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px; font-family:Verdana, Arial, Helvetica, sans-serif;font-size:11px;" value="<?php echo $_GET['from'];?>"/>
<br />
<br />

Sujet :<br />
<input name="subject" type="text" id="subject" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;" value="<?php echo $_GET['subject'];?>"/>
<br />
<br />

Vérification Captcha:<br />
<input name="verif_box" type="text" id="verif_box" style="padding:2px; border:1px solid #CCCCCC; width:180px; height:14px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"/><br/><br/>
<img src="verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" align="absbottom" /><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;">Faux code de vérification</div><br /> 
<?php ;}?>

Commentaire :<br />
<textarea name="message" cols="6" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:300px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"><?php echo $_GET['message'];?></textarea>
<input name="Submit" type="submit" style="margin-top:10px; display:block; border:1px solid #000000; width:100px; height:20px;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; padding-left:2px; padding-right:2px; padding-top:0px; padding-bottom:2px; line-height:14px; background-color:#EFEFEF;" value="Send Message"/>
</form>
Voici la 2ème page :
<?php
// ----------------------------------------- 
//  The Web Help .com
// ----------------------------------------- 
// remember to replace [email protected] with your own email address lower in this code.

// load the variables form address bar
$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("[email protected]", 'Formulaire thenavy.free.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: index.php?subject=$subject&from=$from&message=".urlencode($message)."&wrong_code=true");
	exit;
} else {
	echo "Aucune variable reçue, cette page ne peut pas être directement accessible";
	exit;
	}
?>
<!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=iso-8859-1" />
<title>E-mail</title>
<style type="text/css">
<!--
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
}
-->
</style></head>

<body>
Votre e-mail à bien été envoyé, vous recevrez un email suivant votre demande ou question.<br />
<br />
Retourner à la <a href="/">page d'accueil </a> ? 
</body>
</html>
ce formulaire permet l'envoie de mail quand on a rempli le captcha et les zone, j'aurais voulu au lieu de l'envoyer par mail l'envoyer dans ma BDD, je sais que c'est possible mail me manque des connaissances pour pouvoir le faires, merci de me repondre au plus vite !
thenavy

Re: Transformation

Posté : 28 oct. 2011, 08:48
par xTG
Je ne peux que te recommander de lire des cours pour apprendre ce qu'il te manque. :)
http://www.siteduzero.com/tutoriel-3-14 ... mysql.html (lire la partie 3)

Sinon voici de quoi configurer un serveur SMTP et l'utiliser avec PhPMailer :
http://stephaneey.developpez.com/tutori ... phpmailer/

Re: Transformation

Posté : 28 oct. 2011, 11:14
par Mazarini
Bonjour,

Si tu utilises windows, il faut paramétrer le serveur smtp en mettant celui de ton fournisseur d'accès dans le fichier php.ini. Les commentaires dans ce fichier sont suffisamment explicite pour le faire à mon avis.

Re: Transformation

Posté : 01 nov. 2011, 14:09
par thenavy
Bonjour, merci pour ces tuto mais ce n'est pas exactement ce que je cherche mais a transformer juste d'un envoie de mail a une inscription dans une BDD, j'ai des conaissances en PHP mais je ne sais pas creer des scripts.
Merci

Re: Transformation

Posté : 01 nov. 2011, 15:38
par moogli
salut,
j'ai des conaissances en PHP mais je ne sais pas creer des scripts.
désolé cela se contre dit :)

je te conseil http://phpdebutant.org/article118.php et les suivants tu y trouvera tous ce que tu y souhaite :)


ah sinon dreamwever doit surement savoir faire ^^

@+

Re: Transformation

Posté : 01 nov. 2011, 20:14
par thenavy
Bonjour, merci pour votre lien mais pour être franc ce site ne m'aide pas :D mais j'aurait un autre script (justement j'en revient a mon sujet de base) comment fait-on pour configurer un serveur smtp sur apache2.
Merci bien

Re: Transformation

Posté : 01 nov. 2011, 21:37
par moogli
ça ce ne fait l'un est un serveur "de mail" l'autre un serveur web !

je te conseil de suivre les tutos déjà indiqué a ce sujet !


@+