Error on contact page php
Solved
Bartofer
Posted messages
20
Status
Member
-
Bartofer Posted messages 20 Status Member -
Bartofer Posted messages 20 Status Member -
Hello
I used the Ge-Net contact manager,
but after installing it, I get an error on the site page: "Deprecated: Function ereg() is deprecated in /htdocs/public/www/Pages/contact.php on line 44".
I checked the site in question, and I even recreated a new manager, but the codes are correct...
I left a message for Ge-Net, but since I haven't received a response, I turn to your expertise.
The site in question is Fil-etoffe, and the "contact" page.
Here is the code for the PHP part:
<?php
// Text color of the fields if user input error
$color_font_warn="#FF0000";
// Background color of the fields if user input error
$color_form_warn="#FFCC66";
// Do not modify anything below if you are not sure of what you are doing!
if(isset($_POST['submit'])){
$erreur="";
// Cleaning the entries
while(list($var,$val)=each($_POST)){
if(!is_array($val)){
$$var=strip_tags($val);
}else{
while(list($arvar,$arval)=each($val)){
$$var[$arvar]=strip_tags($arval);
}
}
}
// Formatting the entries
$f_1=strip_tags(trim($f_1));
$f_2=strip_tags(trim($f_2));
$f_3=strip_tags(trim($f_3));
$f_4=strip_tags(trim($f_4));
// Field verification
if(strlen($f_1)<2){
$erreur.="<li><span class='txterror'>The field « Name, First name » is empty or incomplete.</span>";
$errf_1=1;
}
if(strlen($f_2)<2){
$erreur.="<li><span class='txterror'>The field « Postal Code, City » is empty or incomplete.</span>";
$errf_2=1;
}
if(strlen($f_4)<2){
$erreur.="<li><span class='txterror'>The field « E-mail » is empty or incomplete.</span>";
$errf_4=1;
}else{
if(!ereg('^[-!#$%&\'*+\./0-9=?A-Z^_'a-z{|}~]+'.
'@'.
'[-!#$%&\'*+\/0-9=?A-Z^_'a-z{|}~]+\.'.
'[-!#$%&\'*+\./0-9=?A-Z^_'a-z{|}~]+$',
$f_4)){
$erreur.="<li><span class='txterror'>The syntax of your email address is not correct.</span>";
$errf_4=1;
}
}
if(strlen($f_5)<2){
$erreur.="<li><span class='txterror'>The field « Your request » is empty or incomplete.</span>";
$errf_5=1;
}
if($erreur==""){
// Creating the message
$titre="Message from your site";
$tete="From:Site@Fil-etoffe.fr\n";
$corps.="Name, First name : ".$f_1."\n";
$corps.="Postal Code, City : ".$f_2."\n";
$corps.="Telephone : ".$f_3."\n";
$corps.="Your E-mail : ".$f_4."\n";
$corps.="Your request : ".$f_5."\n";
if(mail("StellaB@fil-etoffe.fr", $titre, stripslashes($corps), $tete)){
$ok_mail="true";
}else{
$erreur.="<li><span class='txterror'>An error occurred while sending the message, please try again.</span>";
}
}
}
?>
Thank you for helping me resolve this little issue.
I used the Ge-Net contact manager,
but after installing it, I get an error on the site page: "Deprecated: Function ereg() is deprecated in /htdocs/public/www/Pages/contact.php on line 44".
I checked the site in question, and I even recreated a new manager, but the codes are correct...
I left a message for Ge-Net, but since I haven't received a response, I turn to your expertise.
The site in question is Fil-etoffe, and the "contact" page.
Here is the code for the PHP part:
<?php
// Text color of the fields if user input error
$color_font_warn="#FF0000";
// Background color of the fields if user input error
$color_form_warn="#FFCC66";
// Do not modify anything below if you are not sure of what you are doing!
if(isset($_POST['submit'])){
$erreur="";
// Cleaning the entries
while(list($var,$val)=each($_POST)){
if(!is_array($val)){
$$var=strip_tags($val);
}else{
while(list($arvar,$arval)=each($val)){
$$var[$arvar]=strip_tags($arval);
}
}
}
// Formatting the entries
$f_1=strip_tags(trim($f_1));
$f_2=strip_tags(trim($f_2));
$f_3=strip_tags(trim($f_3));
$f_4=strip_tags(trim($f_4));
// Field verification
if(strlen($f_1)<2){
$erreur.="<li><span class='txterror'>The field « Name, First name » is empty or incomplete.</span>";
$errf_1=1;
}
if(strlen($f_2)<2){
$erreur.="<li><span class='txterror'>The field « Postal Code, City » is empty or incomplete.</span>";
$errf_2=1;
}
if(strlen($f_4)<2){
$erreur.="<li><span class='txterror'>The field « E-mail » is empty or incomplete.</span>";
$errf_4=1;
}else{
if(!ereg('^[-!#$%&\'*+\./0-9=?A-Z^_'a-z{|}~]+'.
'@'.
'[-!#$%&\'*+\/0-9=?A-Z^_'a-z{|}~]+\.'.
'[-!#$%&\'*+\./0-9=?A-Z^_'a-z{|}~]+$',
$f_4)){
$erreur.="<li><span class='txterror'>The syntax of your email address is not correct.</span>";
$errf_4=1;
}
}
if(strlen($f_5)<2){
$erreur.="<li><span class='txterror'>The field « Your request » is empty or incomplete.</span>";
$errf_5=1;
}
if($erreur==""){
// Creating the message
$titre="Message from your site";
$tete="From:Site@Fil-etoffe.fr\n";
$corps.="Name, First name : ".$f_1."\n";
$corps.="Postal Code, City : ".$f_2."\n";
$corps.="Telephone : ".$f_3."\n";
$corps.="Your E-mail : ".$f_4."\n";
$corps.="Your request : ".$f_5."\n";
if(mail("StellaB@fil-etoffe.fr", $titre, stripslashes($corps), $tete)){
$ok_mail="true";
}else{
$erreur.="<li><span class='txterror'>An error occurred while sending the message, please try again.</span>";
}
}
}
?>
Thank you for helping me resolve this little issue.
5 answers
Hello,
You need to change the function ereg() to the function preg_match() https://www.php.net/manual/en/function.preg-match.php
--
A stupid question leads to a stupid answer!
A poorly formulated question leads to a random answer!
You need to change the function ereg() to the function preg_match() https://www.php.net/manual/en/function.preg-match.php
--
A stupid question leads to a stupid answer!
A poorly formulated question leads to a random answer!