/    Sign up×
Community /Pin to ProfileBookmark

Issue with a contact form

__(Added `[code]…[/code]` tags ~ MOD)__

Hello,

I have contact form on my website. It used to work well until now but my hosting server proceeded with a migration and now it does not work anymore. You will find here below the code. Is there a place/file where we need to specify the migration for this to work?

[code]
<?php
//variable formulaire envoi
$name=htmlspecialchars($_POST[‘name’]);
$company=htmlspecialchars($_POST[‘company’]);
$email=htmlspecialchars($_POST[’email’]);
$telephone=htmlspecialchars($_POST[‘telephone’]);
$type=htmlspecialchars($_POST[‘type’]);
$question=htmlspecialchars($_POST[‘message’]);

//variables mail
$headers =’From: “A&T website”<[email protected]>’.”n”;
$headers .=’Content-Type: text/html; charset=”utf-8″‘.”n”;
$headers .=’Content-Transfer-Encoding: 8bit’;

//corps message
$message=”
<!DOCTYPE HTML PUBLIC ‘-//W3C//DTD HTML 4.01 Transitional//EN’ ‘http://www.w3.org/TR/html4/loose.dtd’>
<html>
<head>
<meta http-equiv=’Content-Type’ content=’text/html; charset=utf-8′>
<title>Website Contact</title>
<style type=’text/css’>
<!–
body {
background-color: #EEE;
font-family: Tahoma, Geneva, sans-serif;
font-size: 13px;
}
hr {
height:1px;
}
–>
</style>
</head>
<body>
<table width=’650′ border=’0′ align=’center’ cellpadding=’0′ cellspacing=’0′ bgcolor=’#FFFFFF’>

<tr>
<td width=’25’ height=’60’>&nbsp;</td>
<td width=’600′ valign=’top’><p><img src=’http://www.abcd/abcd_logo.png’ align=’left’><br><br></p></td>
<td width=’25’>&nbsp;</td>
</tr>
<tr>
<td height=’292′>&nbsp;</td>
<td valign=’top’><strong><u>Website Contact</u></strong><br><br>
<table width=’602′ border=’0′ align=’center’>
<tr align=’left’>
<td width=’81’><strong>Name :</strong></td>
<td>”. $name .”</td>
<td width=’100′><strong>Email :</strong></td>
<td width=’182′>”. $email .”</td>
</tr>
<tr align=’left’>
<td><strong>Company</strong></td>
<td width=’249′>”. $company .”</td>
<td><strong>Phone</strong></td>
<td>”. $phone .”</td>
</tr>

</table>
<hr noshade color=’#683d14′ size=’1px’ width=’90%’>
<strong>Type : </strong> “. $type .” <br />
<strong>Message :</strong><br />
“. $question .”
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align=’center’><span style=’color:#999′>abcd – 2015</span></td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>
“;

if ( ereg(‘[email protected]|[email protected]|[email protected]|[email protected]’,$emmeteur) )
{
header(‘Location: message-send.php?send=no’);
}
elseif ( ereg(‘&lt;|<|url|link|http|wwww’,$question) )
{
header(‘Location: message-send.php?send=no’);
}
elseif (($name==””) || ($company==””) || ($email==””) || ($phone==””) || ($type==””) || ($question==””) )
{
header(‘Location: message-send.php?send=fieds’);
}

else mail(‘[email protected]’,’website contact’,$message,$headers);
header(‘Location: message-send.php?send=ok’);
?>
[/code]

to post a comment

8 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 24.2019 — Probably not much we can tell you without knowing what sort of error you are getting. If you don't have access to the PHP error logs or don't know where they are, you could add the following to display errors on the page itself (not something you typically want to do on a live site, but...):
<i>
</i>&lt;?php
ini_set('display_errors', true);
error_reporting(E_ALL);

// rest of code...
Copy linkTweet thisAlerts:
@danbluauthorSep 24.2019 — The strange things is that I inserted the code and nothing is happening. No error is showing??!! Any idea? I am totally lost on this one.
Copy linkTweet thisAlerts:
@NogDogSep 25.2019 — Are you by any chance using PHP 7 now? If so, the ereg() function would no longer be available, and you'd need to use preg_match(), instead. Note that you'd then need to add a delimiter at the beginning and end of the regular expressions -- typically a '/' character.
Copy linkTweet thisAlerts:
@danbluauthorSep 25.2019 — So just this would prevent the form from being sent without returning an error message?
Copy linkTweet thisAlerts:
@NogDogSep 25.2019 — @danblu#1609057

Well...I would expect to see an error like "Fatal error: Uncaught Error: Call to undefined function ereg()", but it's just something that caught my eye. All I can suggest without the ability to test it in your environment is to add debug code until you find out where things go astray.
<i>
</i>&lt;?php

&lt;?php
ini_set('display_errors', true);
error_reporting(E_ALL);

die("&lt;pre&gt;".print_r($_POST, 1)."&lt;/pre&gt;");

// rest of code...

Then see if the post data looks correct. If so, delete that and do something further down. If everything looks good, then put some debug output in each if/else block to find out where it gets to. And so on, and so on... :)
Copy linkTweet thisAlerts:
@danbluauthorOct 02.2019 — Hello, it is just not working. Is there a way for me to share with you the website in a private message?
Copy linkTweet thisAlerts:
@danbluauthorOct 03.2019 — Any way anybody can help me with that?
Copy linkTweet thisAlerts:
@SempervivumOct 04.2019 — Hallo danblu, I'm not a PHP expert myself, but I followed several discussions about contact forms and the experts say in unison:Don't use the built-in function mail() of PHP but use a mailer class like PHPMailer instead. Doing so you need not deal with headers and RFCxxxx which is much error prone.[/quote]I recommend to follow this recommendation.

And from my own experience I know that there can be reasons for a contact form not working which are not coding related: E. g. some providers do not accept when the from-address is not on the same domain. This will not result in an error message but will prevent the mail from being sent.
×

Success!

Help @danblu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...