PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Contact php form for web
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Contact php form for web

Réponse
 
LinkBack Outils de la discussion
Vieux 17/02/2008, 23h47   #1
2007
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Contact php form for web

I have a web page running.
One thing is not working on it.
It is not sending the emails from the web,

I have the following entry in the *.php file - what is wrong with it?

mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders);

Please ee below for the full form.

Thanks

<?
// THIS IS THE BEGIINNING OF THE PHP CODE

$name = $_POST['name'];
$country = $_POST['country'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$error_msg="";
$msg="";

if(!$name){
$error_msg .= "Your name \n";
}
if($name){
$msg .= "Name: \t $name \n";
}

if(!$country){
$error_msg .= "Your country \n";
}
if($country){
$msg .= "Country: \t $country \n";
}

if(!$phone){
$error_msg .= "Your phone \n";
}
if($phone){
$msg .= "Phone: \t $phone \n";
}

if(!$email){
$error_msg .= "Your email \n";
}
if($email){
if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){
echo 'That is not a valid email address. Please<a
href="javascript:history.back()"> return </a> to the previous page
and try again.';
exit;
}
$msg .= "Email: \t $email \n";
}

if(!trim($comments)){
$error_msg .= "Your comments \n";
}
if($comments){
$msg .= "Comments: \t $comments \n";
}
$sender_email="";

if(!isset($name)){
if($name == ""){
$sender_name="noisevx.com Customer";
}
}else{
$sender_name=$name;
}
if(!isset($email)){
if($email == ""){
$sender_email="customer@noisevx.com";
}
}else{
$sender_email=$email;
}
if($error_msg != ""){
echo"You didn't fill in these required fields:<br>"
. nl2br($error_msg) .'<br>Please <a
href="javascript:history.back()"> return </a> to the'
." previous page and try again.";
exit;}
$mailheaders = "MIME-Version: 1.0\r\n";
$mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$mailheaders .= "From: $sender_name <$sender_email>\r\n";
$mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n";
mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders);
header("Location: http://www.xxx.com/index.html"); /* Redirect browser
*/
//THIS IS THE END OF THE PHP CODE ?>
  Réponse avec citation
Vieux 18/02/2008, 06h59   #2
Scott
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Contact php form for web

2007 wrote:
> I have a web page running.
> One thing is not working on it.
> It is not sending the emails from the web,
>
> I have the following entry in the *.php file - what is wrong with it?
>
> mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders);
>
> Please ee below for the full form.
>
> Thanks
>
> <?
> // THIS IS THE BEGIINNING OF THE PHP CODE
>
> $name = $_POST['name'];
> $country = $_POST['country'];
> $phone = $_POST['phone'];
> $email = $_POST['email'];
> $comments = $_POST['comments'];
> $error_msg="";
> $msg="";
>
> if(!$name){
> $error_msg .= "Your name \n";
> }
> if($name){
> $msg .= "Name: \t $name \n";
> }
>
> if(!$country){
> $error_msg .= "Your country \n";
> }
> if($country){
> $msg .= "Country: \t $country \n";
> }
>
> if(!$phone){
> $error_msg .= "Your phone \n";
> }
> if($phone){
> $msg .= "Phone: \t $phone \n";
> }
>
> if(!$email){
> $error_msg .= "Your email \n";
> }
> if($email){
> if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){
> echo 'That is not a valid email address. Please<a
> href="javascript:history.back()"> return </a> to the previous page
> and try again.';
> exit;
> }
> $msg .= "Email: \t $email \n";
> }
>
> if(!trim($comments)){
> $error_msg .= "Your comments \n";
> }
> if($comments){
> $msg .= "Comments: \t $comments \n";
> }
> $sender_email="";
>
> if(!isset($name)){
> if($name == ""){
> $sender_name="noisevx.com Customer";
> }
> }else{
> $sender_name=$name;
> }
> if(!isset($email)){
> if($email == ""){
> $sender_email="customer@noisevx.com";
> }
> }else{
> $sender_email=$email;
> }
> if($error_msg != ""){
> echo"You didn't fill in these required fields:<br>"
> . nl2br($error_msg) .'<br>Please <a
> href="javascript:history.back()"> return </a> to the'
> ." previous page and try again.";
> exit;}
> $mailheaders = "MIME-Version: 1.0\r\n";
> $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
> $mailheaders .= "From: $sender_name <$sender_email>\r\n";
> $mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n";
> mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders);
> header("Location: http://www.xxx.com/index.html"); /* Redirect browser
> */
> //THIS IS THE END OF THE PHP CODE ?>

You might try outputting your variables first to make sure they are
assigned what you expect them to be assigned. That is usually the first
place to look.

Something as simple as:

$msg = stripslashes($msg);
echo "Message:<br>".$msg."<br>";
echo "Mail Headers:<br>".$mailheaders;

Always check your inputs.

Then check to make sure the mail() function is working.

$result = mail("abc7@gmail.com ","Contact",stripslashes($msg),
$mailheaders);
if(!$result) {
echo "Mail function not sending mail.<br>";
}

This will not tell you if the mail is deliverable, but will tell you if
the function sent the data to the server.

You way also want to ensure all your opening and closing tags are:

<?php
{code}
?>

Using the short tag <? can give you many headaches down the road.

Hopefully that will you narrow down the problem.

Scotty
  Réponse avec citation
Vieux 18/02/2008, 15h21   #3
thib´
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Contact php form for web

Scott wrote:
> 2007 wrote:
>> I have a web page running.
>> One thing is not working on it.
>> It is not sending the emails from the web,
>>
>> I have the following entry in the *.php file - what is wrong with it?
>>
>> mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders);
>>
>> Please ee below for the full form.
>>
>> Thanks
>>
>> <?
>> // THIS IS THE BEGIINNING OF THE PHP CODE
>>
>> $name = $_POST['name'];
>> $country = $_POST['country'];
>> $phone = $_POST['phone'];
>> $email = $_POST['email'];
>> $comments = $_POST['comments'];
>> $error_msg="";
>> $msg="";
>>
>> if(!$name){
>> $error_msg .= "Your name \n";
>> }
>> if($name){
>> $msg .= "Name: \t $name \n";
>> }
>>
>> if(!$country){
>> $error_msg .= "Your country \n";
>> }
>> if($country){
>> $msg .= "Country: \t $country \n";
>> }
>>
>> if(!$phone){
>> $error_msg .= "Your phone \n";
>> }
>> if($phone){
>> $msg .= "Phone: \t $phone \n";
>> }
>>
>> if(!$email){
>> $error_msg .= "Your email \n";
>> }
>> if($email){
>> if(!eregi("^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){
>> echo 'That is not a valid email address. Please<a
>> href="javascript:history.back()"> return </a> to the previous page
>> and try again.';
>> exit;
>> }
>> $msg .= "Email: \t $email \n";
>> }
>>
>> if(!trim($comments)){
>> $error_msg .= "Your comments \n";
>> }
>> if($comments){
>> $msg .= "Comments: \t $comments \n";
>> }
>> $sender_email="";
>>
>> if(!isset($name)){
>> if($name == ""){
>> $sender_name="noisevx.com Customer";
>> }
>> }else{
>> $sender_name=$name;
>> }
>> if(!isset($email)){
>> if($email == ""){
>> $sender_email="customer@noisevx.com";
>> }
>> }else{
>> $sender_email=$email;
>> }
>> if($error_msg != ""){
>> echo"You didn't fill in these required fields:<br>"
>> . nl2br($error_msg) .'<br>Please <a
>> href="javascript:history.back()"> return </a> to the'
>> ." previous page and try again.";
>> exit;}
>> $mailheaders = "MIME-Version: 1.0\r\n";
>> $mailheaders .= "Content-type: text/plain; charset=iso-8859-1\r\n";
>> $mailheaders .= "From: $sender_name <$sender_email>\r\n";
>> $mailheaders .= "Reply-To: $sender_email <$sender_email>\r\n";
>> mail("abc7@gmail.com ","Contact",stripslashes($msg), $mailheaders);
>> header("Location: http://www.xxx.com/index.html"); /* Redirect browser
>> */
>> //THIS IS THE END OF THE PHP CODE ?>

> You might try outputting your variables first to make sure they are
> assigned what you expect them to be assigned. That is usually the first
> place to look.
>
> Something as simple as:
>
> $msg = stripslashes($msg);
> echo "Message:<br>".$msg."<br>";
> echo "Mail Headers:<br>".$mailheaders;
>
> Always check your inputs.
>
> Then check to make sure the mail() function is working.
>
> $result = mail("abc7@gmail.com ","Contact",stripslashes($msg),
> $mailheaders);
> if(!$result) {
> echo "Mail function not sending mail.<br>";
> }
>
> This will not tell you if the mail is deliverable, but will tell you if
> the function sent the data to the server.
>
> You way also want to ensure all your opening and closing tags are:
>
> <?php
> {code}
> ?>
>
> Using the short tag <? can give you many headaches down the road.
>
> Hopefully that will you narrow down the problem.
>
> Scotty


Also, read about the 'else' keyword .

-thib´
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h22.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,48885 seconds with 11 queries