473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

creating a mail.php script that pulls email from database

Hello all,

I know html but am sort of lost when it comes to PHP. I don't really know where to even begin to explain my problem.

I am working on a site that deals with real estate. I have created a form on a basic html page( real estate listing page). This form calls a mail.php page to send the contents of the form to the person to whom it is supposed to go (property owner). I setup a test and it all works fine. But here is where the problem begins.

The form I created is on about one hundred pages( for each of the different properties) and they each need to go to different email addresses (property owner of the specific house). The owner's email address is in the database and I have the name of the field. I do not know how to get the mail.php page to "call" the database and insert the email address. I believe that the database we use is Perl. I also need to add a bcc: area in the code but I am not sure how.

The code is below.


[code] <?php
// ************Begin Configure***************
//Put where you want the email to go
$mailto = "me@myemail.com";
//Put your subject in here
$subject = "Real estate Inquiry";
//Put where to redirect to after sending the email
$redirect = "thank_you.html";
// ************End Configure****************


foreach($HTTP_POST_VARS as $key => $value) {

$message .= $key . ': ' . $value;
$message .= "\n"; //Note the double quotes

}
if (@mail($mailto, $subject, $message)) {

header("Location: $redirect");
} else {
// This echo's the error message if the email did not send.
// You could change the text in between the <p> tags.
echo('<p>Mail could not be sent. Please use your back button to try again.</p>');
}
?> [code]

Thank you very much for any help.

Lauren
Jan 31 '08 #1
1 1632
pedalpete
110 100+
Hi Lauren,

To start with, I suspect your database is not Perl, as Perl is a programming language, and as far as I know, not a database.

Now, as far as getting the e-mail addresses and bcc for the mail page, I suspect you are either using different domains, or page variables from the page which the form was linked to. Eg. does your mail.php?property=PROPERTY_ID or something like that?

You can then use the property_id in a query on the mail page so you can find the correct e-mail address from the database.
If you are using different domains, you can use $_SERVER['HTTP_HOST']
to get the domain name and then pass that into the query to get the e-mail address.

I hope that helps.
Pete
Feb 1 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: pee2pee | last post by:
Hi, I have below code: <html> <head> <title>Contacting Worldpay, Please wait.......</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body...
4
by: Giobibo | last post by:
I use the following code to send e-mails with PHP: if(@mail(....)) { //Send OK } else { //Send Bad } But how can I verify that a message was really sent (in case of "Sent
6
by: Dim St Thomas | last post by:
I am a developer working on a database client program. I am testing this program on a Windows XP machine (1.5 GHz AMD chip, 480 Mb RAM, 60 Gb disk) This machine has Oracle 9.2.0.1.0 and RedBrick...
3
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with...
1
by: Chuck | last post by:
I have a form that pulls info from a database. My problem is with the setup of the form if it pulls to much information it throws the whole balance off and messes the table up. I am looking for...
4
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text...
2
by: MostlyH2O | last post by:
Hi Folks, I run a small website for a membership organization - and I have created an ASP front end for an access database that allows the board members to manage their membership roster (names,...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
uranuskid
by: uranuskid | last post by:
Hey folks, I was going to include a contact form on my website. Well, in the first place that seemed an easy thing to do with a form that prompts a PHP file validating the input vaiables and using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.