[RESOLU] erreurs posts ne s'affichent pas

Eléphant du PHP | 233 Messages

28 oct. 2012, 10:44

Bonjour,
dans le code si dessous, les erreurs ne s'affichent pas quand je clique sur "valider".
Plusieurs message devrait s'afficher si je valide sans avoir rempli les champs obligatoires et le captcha.
Si tout est rempli le message est envoyé quand même, donc pas de problème de ce côté.

Merci d'avance de votre aide.
<?php

require_once("initvars.inc.php");
require_once("config.inc.php");
  
if($image_verification) 
{
	require_once("captcha.cls.php");
	$captcha = new captcha();
}

$msg = "";
$err = "";

?>

<?php

if (!$_GET['adid'])
{
	header("Location: $script_url/?view=main&cityid=$xcityid&lang=$xlang");
	exit;
}


$adtable = ($_GET['view'] == "showevent") ? $t_events : $t_ads;
$adid_prefix = (($xview == "events") ? "E" : "A");
$full_adid = ($adid_prefix . $xadid);
$reported = explode(";", $_COOKIE["reported"]);
$is_reported = in_array($full_adid, $reported);


$qsA = $_GET; $qs = "";
unset($qsA['do'], $qsA['reported'], $qsA['mailed'], $qsA['mailerr'], $qsA['msg'], $qsA['err']);
foreach ($qsA as $k=>$v) $qs .= "$k=$v&";

if ($_GET['do'] == "reportabuse")
{
    if (!$is_reported) {

		
    	$sql = "UPDATE $adtable 
    			SET abused = abused + 1 
    			WHERE adid = $_GET[adid] 
    				AND abused < " . ($spam_indicator - 1);
    	
    	mysql_query($sql) or die($sql);
    
    	if(mysql_affected_rows())
    	{
    		echo "<div class=\"msg\">$lang[MESSAGE_ABUSE_REPORT]</div>";
    		
    		if($max_abuse_reports)
    		{
    			
    			$sql = "UPDATE $adtable 
    					SET enabled = '0' 
    					WHERE adid = $_GET[adid]
    						AND abused >= $max_abuse_reports";
    			mysql_query($sql);
    			
    		}
    
    		header("Location: $script_url/?{$qs}reported=y");
    		exit;
    	}
    }

	unset($_GET['do']);
}


if ($xview == "showevent")
{
	
	$sql = "SELECT a.*, UNIX_TIMESTAMP(a.timestamp) AS timestamp, UNIX_TIMESTAMP(a.createdon) AS createdon, UNIX_TIMESTAMP(a.expireson) AS expireson, UNIX_TIMESTAMP(feat.featuredtill) AS featuredtill,
			UNIX_TIMESTAMP(a.starton) AS starton, UNIX_TIMESTAMP(a.endon) AS endon
		FROM $t_events a
			LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'E'
		WHERE a.adid = $xadid
			AND $visibility_condn_admin";
	$ad = mysql_fetch_array(mysql_query($sql));

	$isevent = 1;

	
	$thisurl = buildURL($xview, array($xcityid, $xdate, $xadid, $ad['adtitle']));
	

}
else
{
	
	$xfieldsql = "";
	if(count($xsubcatfields)) 
	{
		for($i=1; $i<=$xfields_count; $i++)	$xfieldsql .= ", axf.f$i";
	}

	
	$sql = "SELECT a.*, ct.cityname as cityname, UNIX_TIMESTAMP(a.timestamp) AS timestamp, UNIX_TIMESTAMP(a.createdon) AS createdon, UNIX_TIMESTAMP(a.expireson) AS expireson, UNIX_TIMESTAMP(feat.featuredtill) AS featuredtill $xfieldsql
			FROM $t_ads a
				INNER JOIN $t_subcats scat ON scat.subcatid = a.subcatid
                INNER JOIN $t_cities ct ON a.cityid = ct.cityid
				LEFT OUTER JOIN $t_adxfields axf ON a.adid = axf.adid
				LEFT OUTER JOIN $t_featured feat ON a.adid = feat.adid AND feat.adtype = 'A'
			WHERE a.adid = $xadid
				AND $visibility_condn_admin";
	$ad = mysql_fetch_array(mysql_query($sql));

	$isevent = 0;
	
	$thisurl = buildURL($xview, array($xcityid, $xcatid, $xcatname, $xsubcatid, $xsubcatname, 
	    $xadid, $ad['adtitle']));
	

}


if (!$ad) 
{
    
	header("Location: $script_url/index.php?view=post404&cityid=$xcityid&lang=$xlang");
    
	exit;
}


if ($_POST['email'] && $_POST['mail'] && $ad['showemail'] == EMAIL_USEFORM)
{
	$err = "";
	
	if ($image_verification && !$captcha->verify($_POST['captcha']))
	{
		$err .= $lang['ERROR_IMAGE_VERIFICATION_FAILED'] . "<br>";
	}
	if (!ValidateEmail($_POST['email'])) 
	{
		$err .= $lang['ERROR_INVALID_EMAIL'] . "<br>";
	}

	if (preg_match("/[\\000-\\037]/", $_POST['email']))
	{
		handle_security_attack("@");
	}
	else if (!$err)
	{
		$thismail_header = file_get_contents("mailtemplates/contact_header.txt");
		$thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
		$thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
		$thismail_header = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_header);
		$thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);

		$thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
		$thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
		$thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
		$thismail_footer = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_footer);
		$thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);

		$msg = $thismail_header . "\n" .
				stripslashes($_POST['mail']) . "\n" .
				$thismail_footer;		
		
        $xtraheaders = array("Reply-To: " . $_POST['email']);

		$mailerr = sendMail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $msg, 
			$site_email, $langx['charset'], "attach", $xtraheaders);
		
		
        if ($mailerr)
		{
			$mailresult = "n";
			if ($mailerr == "FAILED") $mailerr = "";
		}
		else 
		{
            $mailresult = "y";
        }

		header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
		exit;
	}

}

$sql = "SELECT *
		FROM $t_adpics p
		WHERE p.adid = $xadid
			AND isevent = '$isevent'";
$pres = mysql_query($sql);


?>


<script language="javascript">
function confirmAbuseReport()
{
	if (confirm('<?php echo addslashes($lang['REPORT_ABUSE_CONFIRM']); ?>'))
	{
        
        eval("location.href = '?' + '<?php echo $qs; ?>' + 'do=reportabuse'");
        
	}
}
</script>


<?php

if ($_GET['reported']) {
    $reported[] = $full_adid;
    setcookie("reported", implode(";", $reported), time()+90*24*60*60, "/");
    $is_reported = true;
}

?>


<?php

if(!$_POST['mail'])
{
	if($_GET['mailed'] == "y")		{ $msg .= $lang['MESSAGE_MAIL_SENT']."<br>"; }
	elseif ($_GET['mailed'] == "n")	{ $err .= $lang['ERROR_MAIL_NOT_SENT']."<br>".$_GET['mailerr']."<br>"; }

	if($_GET['reported'] == "y")	{ $msg .= $lang['MESSAGE_ABUSE_REPORT']."<br>"; }
}

if($_GET['msg'])				{ $msg .= nl2br(htmlentities($_GET['msg']))."<br>"; }
if($_GET['err'])				{ $err .= nl2br(htmlentities($_GET['err']))."<br>"; }

?>

<?php

if($err) echo "<div class=\"err\">$err</div>";
if($msg) echo "<div class=\"msg\">$msg</div>";

?>
<?php include_once("inc/prev_next.inc.php");?>
<?php if($ad['featuredtill'] && $ad['featuredtill'] > time()) { ?>
<div class="msg">
<img src="images/featured.gif" align="absmiddle">
<b><?php echo $lang['THIS_AD_IS_FEATURED']; ?></b>
</div>
<?php } ?>

<table class="postheader" width="100%"> 
<tr>
<td>

<div align="right">

<?php if(!$is_reported) { ?><a href="javascript:confirmAbuseReport();"><?php echo $lang['REPORT_ABUSE']; ?></a> | <?php } ?>
<a href="?view=mailad&cityid=<?php echo $xcityid; ?>&adid=<?php echo $xadid; ?>&adtype=<?php echo $xadtype; ?><?php if($xdate) echo "&date={$xdate}"; ?>"><?php echo $lang['EMAIL_THIS_AD_LINK']; ?></a> 


</div>
<?php echo $lang['POST_ID']; ?> <?php echo ($xview=="showevent"?"E":"A"); ?><?php echo $ad['adid']; ?><br><br>
<?php
if ($xview == "showevent")
{
?>
	<b><?php echo date("d", $ad['starton'])." ".$langx['months_short'][date("n", $ad['starton'])-1] . ", " . date("y", $ad['starton']); ?>
	<?php if($ad['starton'] != $ad['endon']) echo " - " . date("d", $ad['endon']) . " " . $langx['months_short'][date("n", $ad['endon'])-1] . ", " . date("y", $ad['endon']); ?></b>
	<br>

<?php
}
?>

<div class="posttitle"> 
<?php echo $ad['adtitle']; ?>
<?php 
$loc = "";
if($ad['area']) $loc = $ad['area'];
if($xcityid < 0) $loc .= ($loc ? ", " : "") . $ad['cityname'];
if($loc) echo " <span class=\"adarea\">($loc)</span>";
?>
</div><br>

<b><?php echo $lang['AD_DATE']; ?></b>: 
<?php echo QuickDate($ad['createdon']); ?>
<br>

<?php if($ad['createdon'] != $ad['timestamp']) { ?>
<b><?php echo $lang['AD_LAST_UPDATE']; ?></b>: 
<?php echo QuickDate($ad['timestamp']); ?>
<br>
<?php } ?>

<b><?php echo $lang['AD_EXPIRES_ON']; ?></b>: 
<?php echo QuickDate($ad['expireson']); ?>
<br>

<b><?php echo $lang['REPLY_TO']; ?></b>: 
<?php if ($ad['showemail'] == EMAIL_SHOW) { ?>
	<a href="mailto:<?php echo $ad['email']; ?>"><?php echo $ad['email']; ?></a>

<?php } elseif ($ad['showemail'] == EMAIL_USEFORM) { ?>
	<i><?php echo $lang['USE_CONTACT_FORM']; ?></i>

<?php } else { ?>
	<i><?php echo $lang['EMAIL_NOT_SHOWN']; ?></i>

<?php } ?>
<br>

</td>
</tr>
</table>

<?php
if(($xsubcathasprice && $ad['price']) || count($xsubcatfields))
{
    
    $actualfields = $xsubcathasprice ? 1 : 0;
?>
<div>
<table>

<?php if($xsubcathasprice) { ?><tr><td><b><?php echo $xsubcatpricelabel; ?></b></td><td>: <?php if(($xsubcathasprice && $ad['price'] != 0.00)) { ?><?php echo $ad['price'] .' '. $currency; ?><?php } else { echo $lang['AD_PRICE_NOT_PROVIDED']; } ?></td></tr><?php } ?>

<?php if(count($xsubcatfields)) { foreach ($xsubcatfields as $fldnum=>$fld) { if(($fld['TYPE'] == "N" && $ad["f$fldnum"] > 0) || ($fld['TYPE'] != "N" && $ad["f$fldnum"])) { $actualfields++; ?>
<tr><td><b><?php echo $fld['NAME']; ?></b></td><td>: <?php echo $ad["f$fldnum"]; ?></td></tr>
<?php }}} ?>
</table></div>
<?php if ($actualfields) { ?>
<div style="border-bottom:1px solid #E0E0E0;">&nbsp;</div>
<?php } ?>
<?php
    
}
?>

<table class="post" width="100%"><tr><td> 


<?php echo generateHtml($ad['addesc'], $ad['createdon']); ?>


</td></tr></table>

<?php

if (@mysql_num_rows($pres))
{
	$i = 0;
?>

	<table class="postpics" width="100%"><tr><td> 

<?php
	while ($row = mysql_fetch_array($pres))
	{
		$i++;

		$imgsize = GetThumbnailSize("{$datadir[adpics]}/{$row[picfile]}", $images_max_width, $images_max_height);

?>

		<img src="<?php echo "{$datadir[adpics]}/{$row[picfile]}"; ?>" id="adimg<?php echo $i; ?>" width="<?php echo $imgsize[0]; ?>" height="<?php echo $imgsize[1]; ?>"><br><br>

<?php
	}
?>

	</td></tr></table>

<?php

	$imgcnt = $i;

}
?>

<?php 
if($ad['othercontactok']) echo "<p class=\"disclosure_yes\">$lang[COMMERCIAL_CONTACT_OK]</p>";
else echo "<p class=\"disclosure_no\">$lang[COMMERCIAL_CONTACT_NOT_OK]</p>";
?>


<?php
$hits = $ad['hits'];
$already_hit = explode(";", $_COOKIE["hits"]);
if (!in_array($full_adid, $already_hit)) {
    $sql = "update $adtable set hits = hits + 1, timestamp = timestamp where adid = $xadid";
    mysql_query($sql);
    $already_hit[] = $full_adid;
    setcookie("hits", implode(";", $already_hit), 0, "/");
    $hits++;
}
?>


<div class="hits">Vue <?php echo $hits; ?> fois<br><br></div>
<br style="clear:both">



<?php if ($ad['showemail'] == EMAIL_USEFORM) { 

/*$qs = ""; $qsA = $_GET; unset($qsA['syndicate']);
foreach ($qsA as $k=>$v) $qs .= "$k=$v&";*/

?>

	<form action="<?php echo "$script_url/?$qs"; ?>" method="post" enctype="multipart/form-data">
	<table class="contactform">
	<tr>
		<th colspan="2"><?php echo $lang['CONTACT_USER']; ?>:<a name="contactform">&nbsp;</a>
</th>
	</tr>
	<tr><td colspan="2">&nbsp;</td></tr>
	<tr>
		<td><?php echo $lang['YOUR_EMAIL']; ?>: <span class="marker">*</span></td>
		<td>
		<input type="text" size="65" name="email">
		</td>
	</tr>
	<tr>
		<td valign="top"><?php echo $lang['YOUR_MESSAGE']; ?>: <span class="marker">*</span></td>
		<td>
		<textarea cols="64" rows="10" name="mail"></textarea>
		</td>
	</tr>
	<tr>
		<td valign="top"><?php echo $lang['ATTACHMENT']; ?>:</td>
		<td>
		<input type="file" size="55" name="attach"><br>
		<span class="hint"><?php echo $lang['UNSUPPORTED_ATTACHEMNTS']; ?>: <?php echo implode(", ", $contactmail_attach_wrongfiles); ?><br>
		<?php echo $lang['MAX_ATTACHMENT_SIZE']; ?>: <?php echo $contactmail_attach_maxsize; ?>KB</span>
		</td>
	</tr>

	<?php
	if($image_verification)
	{
	?>

		<tr>
			<td valign="top"><?php echo $lang['POST_VERIFY_IMAGE']; ?>: <span class="marker">*</span></td>
			<td>
			<img src="captcha.png.php?<?php echo rand(0,999); ?>"><br>
			<span class="hint"><?php echo $lang['POST_VERIFY_IMAGE_HINT']; ?></span><br>
			<input type="text" name="captcha" value="">
			</td>
		</tr>

	<?php
	}
	?>

	<tr>
		<td>&nbsp;</td>
		<td><button type="submit"><?php echo $lang['BUTTON_SEND_MAIL']; ?></button></td>
	</tr>
	</table>
	</form>

<?php } ?>

Eléphant du PHP | 233 Messages

29 oct. 2012, 15:24

Bonjour,
visiblement c'est compliqué vu que personne ne répond.
Je détail alors le code qui devrait afficher les messages d'erreur.
Le seul message qui s'affiche est : votre mail a bien été envoyé
Merci de vos idées :
if ($_POST['email'] && $_POST['mail'] && $ad['showemail'] == EMAIL_USEFORM)
{
	$err = "";
	
	if ($image_verification && !$captcha->verify($_POST['captcha']))
	{
		$err .= $lang['ERROR_IMAGE_VERIFICATION_FAILED'] . "<br>";
	}
	if (!ValidateEmail($_POST['email'])) 
	{
		$err .= $lang['ERROR_INVALID_EMAIL'] . "<br>";
	}

	if (preg_match("/[\\000-\\037]/", $_POST['email']))
	{
		handle_security_attack("@");
	}
	else if (!$err)
	{
		$thismail_header = file_get_contents("mailtemplates/contact_header.txt");
		$thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
		$thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
		$thismail_header = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_header);
		$thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);

		$thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
		$thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
		$thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
		$thismail_footer = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_footer);
		$thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);

		$msg = $thismail_header . "\n" .
				stripslashes($_POST['mail']) . "\n" .
				$thismail_footer;		
		
        $xtraheaders = array("Reply-To: " . $_POST['email']);

		$mailerr = sendMail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $msg, 
			$site_email, $langx['charset'], "attach", $xtraheaders);
		
		
        if ($mailerr)
		{
			$mailresult = "n";
			if ($mailerr == "FAILED") $mailerr = "";
		}
		else 
		{
            $mailresult = "y";
        }

		header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
		exit;
et aussi celui qui affiche le message de confirmation d'envoi mais pas celui : erreur d'envoi de votre mail... :)
<?php

if(!$_POST['mail'])
{
	if($_GET['mailed'] == "y")		{ $msg .= $lang['MESSAGE_MAIL_SENT']."<br>"; }
	elseif ($_GET['mailed'] == "n")	{ $err .= $lang['ERROR_MAIL_NOT_SENT']."<br>".$_GET['mailerr']."<br>"; }

	if($_GET['reported'] == "y")	{ $msg .= $lang['MESSAGE_ABUSE_REPORT']."<br>"; }
}

if($_GET['msg'])				{ $msg .= nl2br(htmlentities($_GET['msg']))."<br>"; }
if($_GET['err'])				{ $err .= nl2br(htmlentities($_GET['err']))."<br>"; }

?>

Mammouth du PHP | 702 Messages

29 oct. 2012, 16:36

tu as un message d'erreur, ou quelque chose ?

Eléphant du PHP | 233 Messages

29 oct. 2012, 18:11

non rien aucun message d'erreur. Le seul message qui s'affiche c'est votre message est bien envoyé si tous les champs sont remplis . :?:

Avatar du membre
Modérateur PHPfrance
Modérateur PHPfrance | 8758 Messages

29 oct. 2012, 22:37

salut,


met le header et le exit en commentaire pour être certain d'avoir un message d'erreur.

Tu pourras aussi déboguer ton script et vérifier la valeur des variables avant de les utiliser.


Utilise isset ou empty pour savoir i le formulaire et pas un if($variable).


@+
Il en faut peu pour être heureux ......

Eléphant du PHP | 233 Messages

30 oct. 2012, 10:21

Bonjour,
je ne suis pas un spécialiste du php, je saurais pas faire ce genre de chose mais avec une aide votre part, j’arriverai sans doute à comprendre comment ça marche.
De quelle manière on débogue un script ? et comment on met le head et exit en commentaire ?
Merci d'avance.
salut,


met le header et le exit en commentaire pour être certain d'avoir un message d'erreur.

Tu pourras aussi déboguer ton script et vérifier la valeur des variables avant de les utiliser.


Utilise isset ou empty pour savoir i le formulaire et pas un if($variable).


@+

Avatar du membre
Modérateur PHPfrance
Modérateur PHPfrance | 8758 Messages

30 oct. 2012, 10:57

hum un commentaire en php c'est avec // ou /* */

tu peux lire ce tuto sur le sujet http://phpdebutant.org/article52.php

@+
Il en faut peu pour être heureux ......

Eléphant du PHP | 233 Messages

30 oct. 2012, 11:08

Bonjour,
j'ai donc fait ceci mais je ne sais pas exactement si c'est cela qu'il faut faire. De plus ça n'a rien changé, pas de message d'erreur :
if ($_POST['email'] && $_POST['mail'] && $ad['showemail'] == EMAIL_USEFORM)
{
	$err = "";
	
	if ($image_verification && !$captcha->verify($_POST['captcha']))
	{
		$err .= $lang['ERROR_IMAGE_VERIFICATION_FAILED'] . "<br>";
	}
	if (!ValidateEmail($_POST['email'])) 
	{
		$err .= $lang['ERROR_INVALID_EMAIL'] . "<br>";
	}

	if (preg_match("/[\\000-\\037]/", $_POST['email']))
	{
		handle_security_attack("@");
	}
	else if (!$err)
	{
	/*	$thismail_header = file_get_contents("mailtemplates/contact_header.txt");
		$thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
		$thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
		$thismail_header = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_header);
		$thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);

		$thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
		$thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
		$thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
		$thismail_footer = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_footer);
		$thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);

		$msg = $thismail_header . "\n" .
				stripslashes($_POST['mail']) . "\n" .
				$thismail_footer;		
		
        $xtraheaders = array("Reply-To: " . $_POST['email']);

		$mailerr = sendMail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $msg, 
			$site_email, $langx['charset'], "attach", $xtraheaders); */
		
		
        if ($mailerr)
		{
			$mailresult = "n";
			if ($mailerr == "FAILED") $mailerr = "";
		}
		else 
		{
            $mailresult = "y";
        }

		header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
		//exit;
	}

}

ViPHP
xTG
ViPHP | 7331 Messages

30 oct. 2012, 11:36

Le exit est commenté, on avance, maintenant commentes le header. :P

Eléphant du PHP | 233 Messages

30 oct. 2012, 11:58

Voilà qui est fait mais ne change rien :
 if ($mailerr)
		{
			$mailresult = "n";
			if ($mailerr == "FAILED") $mailerr = "";
		}
		else 
		{
            $mailresult = "y";
        }

		//header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
		//exit;
	}

Avatar du membre
Mammouth du PHP | 1303 Messages

30 oct. 2012, 12:17

salut,


met le header et le exit en commentaire pour être certain d'avoir un message d'erreur.

Tu pourras aussi déboguer ton script et vérifier la valeur des variables avant de les utiliser.


Utilise isset ou empty pour savoir i le formulaire et pas un if($variable).


@+
Salut, il me semble que empty vérifie si isset et/ou empty :wink:
EDIT: non je dit une connerie...

essaye comme ceci:
if ($_POST['email'] && $_POST['mail'] && $ad['showemail'] == EMAIL_USEFORM)
{
       
       
        if ($image_verification && !$captcha->verify($_POST['captcha']))
        {
                $err .= $lang['ERROR_IMAGE_VERIFICATION_FAILED'] . "<br>";
        } elseif (!ValidateEmail($_POST['email']))
        {
                $err .= $lang['ERROR_INVALID_EMAIL'] . "<br>";
        }

        elseif (preg_match("/[\\000-\\037]/", $_POST['email']))
        {
                handle_security_attack("@");
        }
        else if (!$err)
        {
        /*      $thismail_header = file_get_contents("mailtemplates/contact_header.txt");
                $thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
                $thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
                $thismail_header = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_header);
                $thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);

                $thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
                $thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
                $thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
                $thismail_footer = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_footer);
                $thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);

                $msg = $thismail_header . "\n" .
                                stripslashes($_POST['mail']) . "\n" .
                                $thismail_footer;              
               
        $xtraheaders = array("Reply-To: " . $_POST['email']);

                $mailerr = sendMail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $msg,
                        $site_email, $langx['charset'], "attach", $xtraheaders)
               
               
        if ($mailerr)
                {
                        $mailresult = "n";
                        if ($mailerr == "FAILED") $mailerr = "";
                }
                else
                {
            $mailresult = "y";
        }; */
echo $err;
                //header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
                //exit;
        }

}

Eléphant du PHP | 233 Messages

30 oct. 2012, 12:37

Non, pas de changement... :(

Avatar du membre
Mammouth du PHP | 1303 Messages

30 oct. 2012, 12:51

essaye ceci:
// on initialise nos vairbales:
$err = "";
$erreur = "non";
if(isset($_POST['email']) && isset($_POST['mail']) && $ad['showemail'] == EMAIL_USEFORM) {
	if ($image_verification && !$captcha->verify($_POST['captcha'])) {
		$err .= $lang['ERROR_IMAGE_VERIFICATION_FAILED'] . "<br>";
		$erreur = "oui";
	}
	if (!ValidateEmail($_POST['email'])) {
		$err .= $lang['ERROR_INVALID_EMAIL'] . "<br>";
		$erreur = "oui";
	}
	if (preg_match("/[\\000-\\037]/", $_POST['email'])) { // a quoi sert ce preg_match ??
		handle_security_attack("@");
		// je le met en erreur
		$err .= "handle_security_attack...";
		$erreur = "oui";
	}
	if ($erreur == "oui") {
		// si il y a une erreur, on l'affiche:
		echo "Erreur: ".$err;
	} else {
		$thismail_header = file_get_contents("mailtemplates/contact_header.txt");
		$thismail_header = str_replace("{@SITENAME}", $site_name, $thismail_header);
		$thismail_header = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_header);
		$thismail_header = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_header);
		$thismail_header = str_replace("{@FROM}", $_POST['email'], $thismail_header);

		$thismail_footer = file_get_contents("mailtemplates/contact_footer.txt");
		$thismail_footer = str_replace("{@SITENAME}", $site_name, $thismail_footer);
		$thismail_footer = str_replace("{@ADTITLE}", $ad['adtitle'], $thismail_footer);
		$thismail_footer = str_replace("{@ADURL}", "{$script_url}/{$thisurl}", $thismail_footer);
		$thismail_footer = str_replace("{@FROM}", $_POST['email'], $thismail_footer);

		$msg = $thismail_header . "\n" .
				stripslashes($_POST['mail']) . "\n" .
				$thismail_footer;              

		$xtraheaders = array("Reply-To: " . $_POST['email']);

		$mailerr = sendMail($ad['email'], $lang['MAILSUBJECT_CONTACT_FORM'], $msg,
				$site_email, $langx['charset'], "attach", $xtraheaders);
               
               
		if ($mailerr) {
			$mailresult = "n";
			if ($mailerr == "FAILED") {
				$mailerr = "";
			}
		} else {
			$mailresult = "y";
		}
		echo "Résultat: mailresult = ".$mailresult.", mailerr = ".$mailerr;
		//header("Location: $script_url/?$qs&mailed=$mailresult&mailerr=$mailerr");
		//exit;
	}
}

Eléphant du PHP | 233 Messages

30 oct. 2012, 13:07

Merci
super ...ça marche ! =D>
J'ai commenté le car il s'affiche déjà en haut du code
//echo "Erreur: ".$err;
En tout cas merci infiniment de votre aide.... :lol:

Avatar du membre
Mammouth du PHP | 1303 Messages

30 oct. 2012, 13:23

avec plaisir, bonne continuation