PHP form

Résolu/Fermé
jaibesoindelaide Messages postés 136 Date d'inscription mardi 13 novembre 2007 Statut Membre Dernière intervention 2 juillet 2010 - 18 juin 2010 à 20:35
avion-f16 Messages postés 19244 Date d'inscription dimanche 17 février 2008 Statut Contributeur Dernière intervention 17 avril 2024 - 18 juin 2010 à 21:38
Bonjour,

en fesant un forumlaire pour laisser un feedback, le message suivant apparait:

Notice: Undefined variable: errmsg in /var/www/webs/ahc/test/feedb.php on line 61

ligne 61: if(!isset($_POST['send']) || $errmsg != "")


A voir également:

3 réponses

jaibesoindelaide Messages postés 136 Date d'inscription mardi 13 novembre 2007 Statut Membre Dernière intervention 2 juillet 2010
18 juin 2010 à 20:35
<!-- This is the actual PHP mail function used to send the mail -->
<?php
$recipientEmail = "marche@live.com";
$emailSubject = "Feedback";

$error = ""; //leave blank
if(isset($_POST['submit'])){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$result = checkForSpam(Array($name));
if($error == ''){
$priority = 3;
$php_version = phpversion();
$headers = "From: $name <$email>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: $priority\n";
$headers .= "X-Mailer: PHP $php_version\n";
$subject = $emailSubject;
$to_email = $recipientEmail;
mail($to_email, $subject, $message, $headers);
}
}
//utility functions
function checkForSpam($fields){
$spam = false;
for ($i=0;$i<count($fields);$i++){
if (eregi("%0A",$fields[$i]) || eregi("%0D",$fields[$i]) || eregi("\r",$fields[$i]) || eregi("\n",$fields[$i])){
$spam = true;
}
}
return $spam;
}
?>
<!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>AHC-CAS Feedback</TITLE>

<!-- These link to the SpryValidation you must have these files -->
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<style type="text/css">
body {
font-family: Verdana, Geneva, sans-serif;
font-size: 12px;
}
</style>
</head>

<body>

<!-- This is the form you can style it or customize it how ever you'd like -->
<?php
if(!isset($_POST['send']) || $errmsg != "")
{
?>
<form method="post" action="feedb.php">
<table cellpadding="0" cellspacing="5" border="0" class="contacttable">
<tr>
<td class="text1" width="50%">
<table width="500px" cellpadding="0" cellspacing="12" border="0" class="contacttable">
<tr>
<td width="90px" align="right" valign="top"><span class="red">*</span>Name:</td>
<td align="left" valign="top"><span id="sprytextfield1">
<input type="text" name="name" id="name" />
<span class="textfieldRequiredMsg">Your Name is Required.</span></span> </td>
</tr>
<tr>
<td align="right" valign="top"><span class="red">*</span>E-Mail:</td>
<td align="left" valign="top"><span id="sprytextfield2">
<input type="text" name="email" id="email" />
<span class="textfieldRequiredMsg">Your E-Mail is required.</span>
<span class="textfieldInvalidFormatMsg">Invalid format.</span></span> </td>
</tr>
<tr>
<td align="right" valign="top"><span class="red">*</span>Message:</td>
<td align="left" valign="top"><span id="sprytextarea1">
<textarea name="message" id="message" cols="40" rows="8"></textarea><br />
<span class="textareaRequiredMsg">A Message is required.</span></span> </td>
</tr>
<tr>
<td align="left" valign="top"><input type="hidden" name="send" value="yes" /></td>
<td align="left" valign="top">
<input type="submit" name="submit" value="Send Message" /> <span class="red">*</span><i>Required</i></td>
</tr>
</table>
</td>
</tr>
</table>
</form>

<!-- This is the Success Message that will appear after the message has been successfully sent. -->
<?php
}
else{
$success = "<strong><center><br />Thanks for your message!<br />Well be in contact shortly.<br /></center></strong>";
echo $success;
}
?>

<!-- This script code must be at the bottom of your page, just above the </body> tag -->
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", 'none', {validateOn: ['blur']});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", 'email', {validateOn: ['blur']});
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1", {validateOn: ['blur']});
//-->
</script>

</body>
</html>
0
x-jojo34-x Messages postés 19 Date d'inscription vendredi 18 juin 2010 Statut Membre Dernière intervention 22 juin 2010
18 juin 2010 à 21:33
Bonsoirs,

En PHP je m'y connait très peut.
Vous aurez pas oubliée de faire une châine a $errmsg ?
0
avion-f16 Messages postés 19244 Date d'inscription dimanche 17 février 2008 Statut Contributeur Dernière intervention 17 avril 2024 4 496
18 juin 2010 à 21:38
La variable $errmsg n'existe pas, tu ne peux pas l'utiliser dans ta condition.
0