Page 1 of 1

contact form Error

Posted: Fri Dec 05, 2014 1:08 am
by Niraj7878
when i click to submit ,its show successfully but email not received .

Html Code

Code: Select all

<td align="left" valign="top"><form id="form1" name="form1" method="post" action="enquete.php">

                  <table width="100%" border="0" cellpadding="10" cellspacing="1">

                    <tr align="left" valign="top">

                      <td class="bodytextblack">Prénom (*)</td>

                      <td><input name="mem_fname" type="text" class="textbox" /></td>

                    </tr>

                    <tr align="left" valign="top">

                      <td class="bodytextblack">Email (*)</td>

                      <td><input name="mem_email" type="text" class="textbox" /></td>

                    </tr>

                    <tr align="left" valign="top">

                      <td class="bodytextblack">No de téléphone (*)</td>

                      <td><input name="mem_tel_no" type="text" class="textbox" /></td>

                    </tr>

                    <tr align="left" valign="top">

                      <td class="bodytextblack">un message:</td>

                      <td><textarea name="enquiry" rows="5" cols="50" class="textbox"></textarea></td>

                    </tr>

                    <tr align="left" valign="top">

                      <td>&nbsp;</td>

                      <td><input type="submit" name="Submit" value="Send" onclick="Javascript: return Validate_Enquiry(document.frmEnquiry);" />

                        &nbsp;&nbsp;

                        <input name="reset" type="reset" value="Reset" /></td>

                    </tr>

                  </table>

              </form></td>
Php Code

Code: Select all

<?PHP
# ----------------------------------------------------
# -----
# -----  Forms To Go v2.6.11 by Bebosoft, Inc.
# -----
# -----  http://www.bebosoft.com/
# -----
# ----------------------------------------------------
# -----
# -----                 UNREGISTERED COPY
# -----
# -----              Forms To Go is shareware
# -----            Please register the software
# -----
# ----------------------------------------------------

error_reporting(7);

#----------
# Validate: Email

function check_email($email, $optional)
{
 if ( (strlen($email) == 0) && ($optional === true) ) {
  return true;
 } elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
  return true;
 } else {
  return false;
 }
}

if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
 $ClientIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
 $ClientIP = $_SERVER['REMOTE_ADDR'];
}

# RegisterGlobals OFF

$FTGmem_fname = $_POST['mem_fname'];
$FTGmem_email = $_POST['mem_email'];
$FTGmem_tel_no = $_POST['mem_tel_no'];
$FTGenquiry = $_POST['enquiry'];
$FTGT5 = $_POST['T5'];
$FTGT6 = $_POST['T6'];
$FTGT7 = $_POST['T7'];
$FTGT10 = $_POST['T10'];
$FTGT11 = $_POST['T11'];
$FTGT12 = $_POST['T12'];
$FTGS1 = $_POST['S1'];
$FTGB1 = $_POST['B1'];
$FTGB2 = $_POST['B2'];


if (get_magic_quotes_gpc) {
 $FTGmem_fname = stripslashes($FTGmem_fname);
 $FTGmem_email = stripslashes($FTGmem_email);
 $FTGmem_tel_no = stripslashes($FTGmem_tel_no);
 $FTGenquiry = stripslashes($FTGenquiry);
 $FTGT5 = stripslashes($FTGT5);
 $FTGT6 = stripslashes($FTGT6);
 $FTGT7 = stripslashes($FTGT7);
 $FTGT10 = stripslashes($FTGT10);
 $FTGT11 = stripslashes($FTGT11);
 $FTGT12 = stripslashes($FTGT12);
 $FTGS1 = stripslashes($FTGS1);
 $FTGB1 = stripslashes($FTGB1);
 $FTGB2 = stripslashes($FTGB2);
}
# Fields Validations

$validationFailed = false;

if ( (! check_email($FTGmem_email, false))) {
 $validationFailed = true;
}

# Redirect user to the error page

if ($validationFailed == true) {

 header("Location: enquiry_error.php");
 exit;

}


# Email to Form Owner

$emailTo = '"Meet Niki" <niraj@srijaniwebtech.com>';

$emailSubject = "Enquiry from website visitor";
$emailSubject = preg_replace('/[\x00-\x1F]/', '', $emailSubject);

$emailFrom = "$FTGT2";
$emailFrom = preg_replace('/[\x00-\x1F]/', '', $emailFrom);

$emailBody = "Name: $FTGmem_fname\n"
 . "Email Address: $FTGmem_email\n"
 . "Telephone: $FTGmem_tel_no\n"
 . "Messege: $FTGenquiry\n"
  . "\n"
 . "";

$emailHeader = "From: $emailFrom\n"
 . "Reply-To: $emailFrom\n"
 . "MIME-Version: 1.0\n"
 . "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
 . "Content-transfer-encoding: quoted-printable\n";

mail($emailTo, $emailSubject, $emailBody, $emailHeader);

# Redirect user to success page

header("Location: enquiry_finish.php");
exit;

# End of PHP script
?>

Re: contact form Error

Posted: Fri Dec 05, 2014 6:39 am
by Celauran
And what do you see in your mail logs?

Re: contact form Error

Posted: Fri Dec 05, 2014 6:50 am
by twinedev
Assuming that the PHP code you gave is for enquete.php, then you have nothing that is defining the FROM address in the e-mail, which is probably causing the mail server to not send it.

On an unrelated note, one of the many things that should be cleaned up:

Code: Select all

elseif ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email) ) {
should just be the following, especially since eregi is deprecated (can be removed at any time in future version of PHP)

Code: Select all

elseif ( filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
Even better, just replace that whole function with:

Code: Select all

function check_email( $email, $optional ) {
    return ( ( $optional && $email == '' ) || filter_var( $email, FILTER_VALIDATE_EMAIL ) );
}