SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: Email & Database submission
-
Jun 10, 2007, 05:29 #1
Email & Database submission
Once this form is submitted the info goes to database, but for some reason its im not getting a copy to my email which i should be, im not understanding why? what code will i need to add or modify to get a copy to my email account...
PHP Code:<?php
require_once('db.inc.php');
if (isset($_POST['sell_submit'])) {
if ($_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
echo 'Please hit the back button and fill up the 2 fields.';
exit();
} elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
echo 'Email not valid.';
exit();
} else {
$to = 'info@email.com';
$eol = "\r\n";
$subject = 'WEBSITE (Sell Business)';
$headers .= 'From: Website Business<info@email.com>'.$eol;
$headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
$headers .= 'MIME-Version: 1.0 '.$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$body = 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
$body .= 'Email: '.$_POST['email'].'<br>';
$body .= 'Business Type: '.$_POST['biz_type'].'<br>';
$body .= 'Warm Regards,<br><br>';
$body .= 'WEBSITE<br>';
$body .= 'www.website.com<br>';
$body .= 'www.website.com';
mail($to, $subject, $body, $headers);
}
?>Last edited by dannbkk; Jun 11, 2007 at 01:34.
Learn SEO - Join the community at GSEO.net
SEO Book - SEO Revenge eBook
Make Money Programs - No Fluff!
Make Money Online
-
Jun 10, 2007, 06:03 #2
- Join Date
- Jun 2007
- Location
- The Netherlands
- Posts
- 112
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You forgot one } at the end to close the
Code php:if (isset($_POST['sell_submit'])) {
Last edited by Servyces; Jun 13, 2007 at 10:44.
Servyces.com
Where it’s all about you.
Your partner in online solutions.
Visit our website at http://www.servyces.com/
-
Jun 10, 2007, 19:53 #3
what do you mean? it appears i have closed it.
Learn SEO - Join the community at GSEO.net
SEO Book - SEO Revenge eBook
Make Money Programs - No Fluff!
Make Money Online
-
Jun 10, 2007, 23:09 #4
Nope, you need another bracket at the end of the script.
-
Jun 10, 2007, 23:12 #5
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Jun 10, 2007, 23:40 #6
- Join Date
- Jun 2007
- Location
- The Netherlands
- Posts
- 112
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Brackets are deceivable things
And using indent as stated can indeed help you spot this. See the example below.
PHP Code:<?php
require_once('db.inc.php');
if (isset($_POST['sell_submit'])) {
if ($_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
echo 'Please hit the back button and fill up the 2 fields.';
exit();
} elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
echo 'Email not valid.';
exit();
} else {
$to = 'info@email.com';
$eol = "\r\n";
$subject = 'WEBSITE (Sell Business)';
$headers .= 'From: Website Business<info@email.com>'.$eol;
$headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
$headers .= 'MIME-Version: 1.0 '.$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$body = 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
$body .= 'Email: '.$_POST['email'].'<br>';
$body .= 'Business Type: '.$_POST['biz_type'].'<br>';
$body .= 'Warm Regards,<br><br>';
$body .= 'WEBSITE<br>';
$body .= 'www.website.com<br>';
$body .= 'www.website.com';
mail($to, $subject, $body, $headers);
} // <--- Your script ended here
} // <--- Add this one to close everything.
?>Last edited by Servyces; Jun 13, 2007 at 10:31.
Servyces.com
Where it’s all about you.
Your partner in online solutions.
Visit our website at http://www.servyces.com/
-
Jun 11, 2007, 03:02 #7
I have added the extra quote but its still not doing what i want it to...
As i say i want to be able to have a copy of the information they submit to my email aswell. At the moment its only submitting to the database?Learn SEO - Join the community at GSEO.net
SEO Book - SEO Revenge eBook
Make Money Programs - No Fluff!
Make Money Online
-
Jun 11, 2007, 07:57 #8
- Join Date
- Jun 2007
- Location
- The Netherlands
- Posts
- 112
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think I am spotting the problem. You are only appending the $headers, you do never initialize it. Also, I added a debug part so you can see if the server actually mails anything (or at least tries to). See the comments below
PHP Code:<?php
require_once('db.inc.php');
if (isset($_POST['sell_submit'])) {
if ($_POST['biz_type'] == 'Business Type' || $_POST['email'] == 'Email Address') {
echo 'Please hit the back button and fill up the 2 fields.';
exit();
} elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) {
echo 'Email not valid.';
exit();
} else {
$to = 'info@email.com';
$eol = "\r\n";
$subject = 'WEBSITE (Sell Business)';
$headers = 'From: Website Business<info@email.com>'.$eol; // <--- Start here with $headers = and not with $headers .= !
$headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
$headers .= 'MIME-Version: 1.0 '.$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$body = 'Someone had submitted the form at sell-submit.php and here\'s the informations,<br>';
$body .= 'Email: '.$_POST['email'].'<br>';
$body .= 'Business Type: '.$_POST['biz_type'].'<br>';
$body .= 'Warm Regards,<br><br>';
$body .= 'WEBSITE<br>';
$body .= 'www.website.com<br>';
$body .= 'www.website.com';
$mail_it = mail($to, $subject, $body, $headers); // <--- Mind the $mail_it = here !
}
}
// Add this code to check if the mail function was executed.
if(!$mail_it) {
echo 'Oops, something went wrong.';
} else {
echo 'Mail sent.';
}
?>Last edited by Servyces; Jun 13, 2007 at 10:30.
Servyces.com
Where it’s all about you.
Your partner in online solutions.
Visit our website at http://www.servyces.com/
-
Jun 14, 2007, 19:36 #9
Let me allaborate, I am getting the email but i am getting the wrong information to my email when i submit on the form i am getting this info ;
$body = 'Dear '.$name.',<br><br>';
$body .= 'Thankyou for submitting your interest in business for sale at Elite Property Group.<br>';
$body .= 'We have captured your details for the business you are interested in and will be contacting you shortly.
when i should be getting the info that has been submitted such as;
userid, name, email, phone, enquiry, reference, status) VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";
hope that makes sense and you can help me out?
It came up with the error, oops, something went wrong'
actually this was the form and code i needed it on;
PHP Code:<?php
require_once('db.inc.php');
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = ereg_replace("[^0-9+ ]", "", $_POST['phone']);
$enquiry = ereg_replace("\n", "<br>", $_POST['enquiry']);
$reference = $_POST['reference'];
echo $biz_id;
if (empty($name) || empty($email) || empty($phone) || empty($enquiry)) {
echo 'Please fill up all the forms.';
} elseif (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo 'Email is not validate.';
} else {
$query = "INSERT INTO mailing_list (userid, name, email, phone, enquiry, reference, status) VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";
mysql_query($query) or die("MySQL Error :" . mysql_error());
$eol = "\r\n";
$title = 'BUSINESS GROUP (Enquiry)';
$email = 'info@email.com';
$headers = 'From: Business Groups<info@anotheremail.com>'.$eol;
$headers .= 'Content-Type: text/html; charset=ISO-8859-1 '.$eol;
$headers .= 'MIME-Version: 1.0 '.$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion().$eol;
$body = 'Dear '.$name.',<br><br>';
$body .= 'Thankyou for submitting your interest in business for sale at Elite Property Group.<br>';
$body .= 'We have captured your details for the business you are interested in and will be contacting you shortly.<br><br>';
$body .= 'Warm Regards,<br><br>';
$body .= 'Business Group<br>';
$body .= 'www.website.com<br>';
$body .= 'www.website2.com';
mail($email, $title, $body, $headers);
echo 'Thank you, we will get back to you as soon as possible.<br>';
}
}
// Add this code to check if the mail function was executed.
if(!$mail_it) {
echo 'Oops, something went wrong.';
} else {
echo 'Mail sent.';
}
?>Learn SEO - Join the community at GSEO.net
SEO Book - SEO Revenge eBook
Make Money Programs - No Fluff!
Make Money Online
-
Jun 14, 2007, 20:21 #10
- Join Date
- Aug 2005
- Posts
- 453
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
VALUES ('', '$name', '$email', '$phone', '$enquiry', '$reference', 'open')";
The single quotes mean use these values as literals, not use these variables...Computers and Fire ...
In the hands of the inexperienced or uneducated,
the results can be disastrous.
While the professional can tame, master even conquer.
-
Jun 14, 2007, 21:04 #11
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Jun 14, 2007, 21:44 #12
how do i get the information of theses values also sent to my email so like the sellers name once filled his email and everything else etc. as its now not emailing me with that info which it should.. please help...
$name = $_POST['name'];
$email = $_POST['email'];
$phone = ereg_replace("[^0-9+ ]", "", $_POST['phone']);
$enquiry = ereg_replace("\n", "<br>", $_POST['enquiry']);
$reference = $_POST['reference'];Learn SEO - Join the community at GSEO.net
SEO Book - SEO Revenge eBook
Make Money Programs - No Fluff!
Make Money Online
Bookmarks