issue sending mail from website

Hi guys,

I am having an issue with the form on site here at http://www.detergentingredients.com/contact.html

is it maybe something to do with the process.php ?
jonathanduane2010Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
Yes - definitely - it doesn't exist !!

Submit your form and you'll get a 404 Page Not Found error /phpform/use/contact_form/process.php
0
jonathanduane2010Author Commented:
ok i have put one in there, but it just hangs on the page

<?php
if(isset($_POST['submit'])) {
   $to = 'jonathanduane@iradio.ie' ;     //put your email address on which you want to receive the information
   $subject = 'hello';   //set the subject of email.
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $message = "<table><tr><td>Your Name</td><td>".$_POST['name']."</td></tr>
               <tr><td>E-Mail</td><td>".$_POST['email']."</td></tr>
               <tr><td>Contact No</td><td>".$_POST['contact']."</td></tr>
               <tr><td>Message</td><td>".$_POST['message']."</td>
               </tr></table>" ;
   mail($to, $subject, $message, $headers);
   header('Location: contact.php');
}
?>

Open in new window


is this correct
0
Chris StanyonWebDevCommented:
Not quite.

Your code will only get called if there is a POST key of 'submit':

if(isset($_POST['submit'])) {

There isn't one in your form. You need to give your submit button a name of 'submit':

<input type='submit' value='Submit Form' name='submit'>

Something else of note, You're creating the message using the following form fields:

name
email
contact
message

But your form actually has these fields:

Name
Email
Company
Telephone
Comments
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

jonathanduane2010Author Commented:
sorry, i just found that process.php online

how does this look

<?php
if(isset($_POST['submit'])) {
   $to = 'jonathanduane@iradio.ie' ;     //put your email address on which you want to receive the information
   $subject = 'hello';   //set the subject of email.
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $message = "<table><tr><td>Your Name</td><td>".$_POST['name']."</td></tr>
				<input type='submit' value='Submit Form' name='submit'> 
               <tr><td>E-Mail</td><td>".$_POST['email']."</td></tr>
               <tr><td>Company No</td><td>".$_POST['Company']."</td></tr>
               <tr><td>Telephone</td><td>".$_POST['Telephone']."</td>
			   <tr><td>Comments</td><td>".$_POST['Comments']."</td>
               </tr></table>" ;
   mail($to, $subject, $message, $headers);
   header('Location: contact.php');
}
?>

Open in new window

0
Ray PaseurCommented:
Is the mail() function working correctly when you isolate it and test it (without using the form)?  It returns a value that you can test for success or failure, and you would want to test this in your script and trigger an error or throw an exception if that return value indicated a failure of the function.  A good indicator does not guarantee success of the entire email process, but it would eliminate the need to consider one point of failure and that would help us move on to the next things that should be checked.

Important reading here:
http://php.net/manual/en/mail.requirements.php
http://php.net/manual/en/function.mail.php
0
Chris StanyonWebDevCommented:
You seem to have added the submit button in your process.php script. That's not what I meant. You need to update the submit button in your form.
0
jonathanduane2010Author Commented:
ok i have done that, but no change
0
Chris StanyonWebDevCommented:
You've now got 2 submit buttons on your form - you need one one, that includes the name attribute. Your form was fine as it was - you just needed to add name="submit" to it.

Once you've done that, add some simple logging to your PHP script. It'll help you figure out what's going on.

<?php
//Turn on error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);

if(isset($_POST['submit'])) {
   $to = 'jonathanduane@iradio.ie' ;     //put your email address on which you want to receive the information
   $subject = 'hello';   //set the subject of email.
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $message = "<table><tr><td>Your Name</td><td>".$_POST['Name']."</td></tr>
               <tr><td>E-Mail</td><td>".$_POST['Email']."</td></tr>
               <tr><td>Company No</td><td>".$_POST['Company']."</td></tr>
               <tr><td>Telephone</td><td>".$_POST['Telephone']."</td>
			   <tr><td>Comments</td><td>".$_POST['Comments']."</td>
               </tr></table>" ;
   $mailsent = mail($to, $subject, $message, $headers);
   if ($mailsent) {
      header('Location: contact.php');
   }
   else
   {
      echo "The mail was not sent";
   }

} else {
   echo "No POST data was found";
}
?>

Open in new window


Once you've got that working, you'll really need to extend yout script to check that the POST array actually contains data and that the data contained is exactly what you need.
0
Ray PaseurCommented:
How to work with forms in PHP:
http://php.net/manual/en/tutorial.forms.php

You can use var_dump($_POST) to print out the contents of the "request" variables.  This is usually a good starting point when you're developing an application that depends on posted variables from an HTML form.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.