Page 1 of 1

Form working, yet email isn't received?

Posted: Thu Jun 05, 2008 6:28 pm
by Heyzoos
Please learn how to use the [ code=php] BBcode tags when you list code in the forum. There's a Code button right there at the top of the topic entry window, or you can just insert the tags as you enter your post. I have done this for you below. It really helps us read your code. Thank you.
califdon


Hi,

I've had the following form working great on a website and it would send the email with the data. A couple of days ago however, the form still accepts the information and goes to the 'thank you' page, yet now the email isn't coming through... Any ideas?

I've tried using different email addresses from different servers and have also tried testing the following, but no luck:

Code: Select all

<?php
 
mail('email@domain.com', 'test', 'test');
 
?>
Here's the code I'm using for the pages:

On the form page:

Code: Select all

<form action="process.php" method="POST">
 
[b][u]On the 'process' page:[/u][/b]
 
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','name');
pt_register('POST','email');
pt_register('POST','S1');
pt_register('POST','Tour1');
pt_register('POST','T1');
pt_register('POST','Adults1');
pt_register('POST','FirstName');
pt_register('POST','SecondName');
pt_register('POST','Children1');
pt_register('POST','Children2');
pt_register('POST','Departure1');
pt_register('POST','Tour2');
pt_register('POST','T2');
pt_register('POST','Adults2');
pt_register('POST','FirstName2');
pt_register('POST','SecondName2');
pt_register('POST','Children21');
pt_register('POST','Children22');
pt_register('POST','Departure2');
pt_register('POST','Comments');
pt_register('POST','Cardtype');
pt_register('POST','Cardname');
pt_register('POST','Carddate');
pt_register('POST','Cardnumber');
pt_register('POST','Howfound');
if($email=="" ){
$errors=1;
$error.="<li>Please fill in your email address.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$name."
Email: ".$email."
Pickup Address and Phone Number: ".$S1."
1st Tour: ".$Tour1."
Options: ".$T1."
Number of Adults: ".$Adults1."
Name of 1st Adult: ".$FirstName."
Name of 2nd Adult: ".$SecondName."
Number of Children: ".$Children1."
Names and Ages: ".$Children2."
Departure Date: ".$Departure1."
2nd Tour: ".$Tour2."
Options: ".$T2."
Number of Adults: ".$Adults2."
Name of 1st Adult: ".$FirstName2."
Name of 2nd Adult: ".$SecondName2."
Number of Children: ".$Children21."
Names and Ages: ".$Children22."
Departure Date: ".$Departure2."
Comments: ".$Comments."
Credit Cart Type: ".$Cardtype."
Card Holder Name: ".$Cardname."
Expiry Date: ".$Carddate."
Card Number: ".$Cardnumber."
How they found the website: ".$Howfound."
";
$message = stripslashes($message);
mail("sales@mydomain.com","New Booking!",$message,"From: Online Booking Received");
 
header("Refresh: 0;url=http://www.mydomain.com/thanks.html");
?><?php 
}
?>
On the 'global' page:

Code: Select all

<?php
 
function pt_register()
{
  $num_args = func_num_args();
   $vars = array();
 
   if ($num_args >= 2) {
       $method = strtoupper(func_get_arg(0));
 
       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
     }
 
       $varname = "HTTP_{$method}_VARS";
      global ${$varname};
 
       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);
 
           if (isset(${$varname}[$parameter])) {
               global $$parameter;
               $$parameter = ${$varname}[$parameter];
          }
 
       }
 
   } else {
       die('You must specify at least two arguments');
   }
 
}
 
?>
:banghead:

Re: Form working, yet email isn't received?

Posted: Fri Jun 06, 2008 1:02 am
by RobertGonzalez
Try using a library like Swiftmailer. The error handling in it is top class.