PHP emailing
Hi!
I am trying to find a sample code for emailing a form.
I have seen those on apptools website.
It`s not quite what i`m looking for.
I need a form with only 1 text field and a submit button.
The field should be for email adresses.
What i need it to do is send me an email with the textfield
message( in this case a person's email adress) and also send to
that certain email adress ( the one entered in the text field ) an
email with something for example, a link to another website.
Thanks.
Read, "Validating your forms with PHP" - here:
http://sourtea.com/articles.php
Shane H
[email protected]
http://www.avenuedesigners.com
=============================================
Web Dev Articles, Photography, and more:
http://sourtea.com
=============================================
Proud GAWDS Member
http://www.gawds.org/showmember.php?memberid=1495
Delivering accessible websites to all ...
=============================================
"dwkd" <[email protected]> wrote in message
news:ee89ok$a59$[email protected]..
> Hi!
> I am trying to find a sample code for emailing a form.
> I have seen those on apptools website.
> It`s not quite what i`m looking for.
> I need a form with only 1 text field and a submit
button.
> The field should be for email adresses.
> What i need it to do is send me an email with the
textfield message( in
> this
> case a person's email adress) and also send to that
certain email adress
> ( the
> one entered in the text field ) an email with something
for example, a
> link to
> another website.
>
> Thanks.
>
Similar Messages
-
PHP Email Form is not Emailing
HI,
I made a PHP email form and i was wondering if i did it
correct. I try to send a email but for some reason it wont work
here is the PHP code:
<?php
$emailSubject = 'Computer Question!';
$webMaster = '[email protected]';
$nameField = $_POST ['name'];
$phoneField = $_POST ['phone'];
$emailField = $_POST ['email'];
$questionField = $_POST ['question'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
Question: $question <br>
EOD;
$headers = "From: $email\r\n";
$headers .="Content=type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
/* Results Rendered as HTML */
$theResults = <<<EOD
?>
Here is the Email form:
:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" method="post"
action="Contact form 505 test 2.php">
<table width="70%" border="1" cellpadding="6">
<tr>
<th width="16%" scope="col"><div align="right">
<label for="name">Name:</label>
</div></th>
<th width="84%" scope="col"><div align="left">
<input name="name" type="text" id="name" size="35"
maxlength="60" />
</div></th>
</tr>
<tr>
<th scope="row"><div align="right">
<label for="phone ">Phone Number</label>
</div></th>
<td><div align="left">
<input name="phone " type="text" id="phone " size="35"
maxlength="13" />
</div></td>
</tr>
<tr>
<th scope="row"><div align="right">
<label for="email">Email:</label>
</div></th>
<td><div align="left">
<input name="email" type="text" id="email" size="35"
maxlength="40" />
</div></td>
</tr>
<tr>
<th scope="row"><div align="right">
<label for="question">Question:</label>
</div></th>
<td><div align="left">
<textarea name="question" cols="26" rows="8"
id="question"></textarea>
</div></td>
</tr>
<tr>
<th scope="row"> </th>
<td><label for="Send Email"></label>
<input type="submit" name="Send Email" id="Send Email"
value="Submit" /></td>
</tr>
</table>
</form>
</body>
</html>
Any help would be appreciated!
thanks.oO(jumpman310)
> I made a PHP email form and i was wondering if i did it
correct. I try to send
>a email but for some reason it wont work here is the PHP
code:
Next time please be more specific. "won't work" isn't really
helpful.
Anyway, the first thing to fix is the error reporting on your
testing
server, obviously it's not configured properly. In your
php.ini these
directives have to be set:
error_reporting = E_ALL|E_STRICT
display_errors = on
You should get some notices from your script. After fixing
those issues,
you should also read about header injection and how to
prevent it. Your
script is vulnerable and can be abused for sending spam. Also
consider
to use a class like PHPMailer to make things more secure and
convenient.
Some further notes about your form markup:
* It's very good that you make use of labels for your form
controls, but
in some cases the IDs of these controls contain spaces, which
is not
allowed.
* You don't really need a label for a submit button.
* Consider to drop all those div elements in the table
headers - you
don't need them. Use CSS to style the labels the way you
want, e.g.
form th {text-align: right}
I also use this:
label:hover {outline: 1px dotted #666}
* Check the markup of the "Name" row. The 'scope' attribute
is incorrect
and the form control should be inside a 'td', not a 'th'.
Micha -
PHP email form checkbox values?
Hello,
I'm creating a php email form which part of it consists of a few checkboxes that I need to get the values of. My php knowledge isn't that great therefore I used a tutorial to successfully create the bulk of the form.
I currently have 7 checkboxes set up as such:
<input type="checkbox" id="grade_5" name="grade[]" value="Grade 5" />
Each of these are named "grade[]" to be stored in an array called "grade".
I know that the values are successfully stored in the array as they show up in the browser when I echo the array.
$grade = $_POST['grade'];
$N = count($grade);
for($i=0; $i < $N; $i++) {
echo($grade[$i] . " ");
So, the part I am having trouble with is getting the values to show up in the body of the email.
$body = "
Grade Level(s): $grade
All that is returned in this case is the word "Array" instead of the desired checked grade values.
Any help is much appreciated! Thank you in advance!
*Note: All other values (textboxes, selection dropdowns, etc.) are already successfully sent to the email.danedmonds wrote:
All that is returned in this case is the word "Array" instead of the desired checked grade values.
That's because $grade is an array. If you want to access the values, you need to use a loop. Alternatively, use implode() to turn it into a comma-separated string, like this:
$grade = implode(', ', $grade); -
Radio Buttons for Flash PHP email.
Hi.
I need to add a sign-up form for services to a flash AS2 web site.
I found a very simple example of a Flash/ PHP email form at Kirupa.
It works fine, but I need to add some radio buttons.
My web site will offer various services.
Ideally I would like to be able for viewers to sign up for a service by clicking the appropriate right radio buttons
F.ex;
• Service 1
• Service 2
• Service 3
• Service 4
The email should reflect the choices made by listing the text on the selected services (radio buttons).
Please download the FLA and the PHP file (at the bottom of the tutorial) here:
http://www.kirupa.com/developer/actionscript/flash_php_email.htm
I have uploaded a working version here:
http://gggraphic.com/flash_mail/simple_flash_mail.php
How do I add and script the radio buttons with both AS and the PHP to make it happen?
Thank you on beforehand for your help
ggaardeHi Again
Maybe check buttons would be a more natural option for this. You should be able to select more than one service.
Thanks
ggaarde -
Is the "PHP Email Server Behaviors Pack" extension legit?
There are two comments for the extension PHP Email Server
Behaviors Pack V1.1.1, both of which indicate that this is not a
legit product.
Has anyone purchased this extension and had success with it?
davidThe responses on the Exchange indicate that the users there
bought it and
got no product. You will notice it didn't have company
approval. I would
stay away from it, if it were me. There is an email address
listed on the
product page for support .. you might try writing to them and
asking some
questions.
Nancy
"elvis is dead" <[email protected]> wrote in
message
news:fjs2f0$pqc$[email protected]..
> There are two comments for the extension PHP Email
Server Behaviors Pack
> V1.1.1, both of which indicate that this is not a legit
product.
>
> Has anyone purchased this extension and had success with
it?
>
> david
> -
How to send php email using email from recordset?
Hi
I know the headers to use for php mail(), and I use it for
the contact form for my viewers in order to contact the directory
listing's email address ( of which I have hidden by using the words
'Email Us' and use the id to carry through to the form).
I have sucessfully used the $to = [email protected] but when I
want to use the $row_?['email'] it will not send.
Any suggestions? I use a recordset to retrieve the id of the
listing to the contact form.
I will want to follow the same procedure for my jobseekers to
contact employers job adverts.
Thanks
TheresaHi,
There are many sms gateways that have their own api to send sms. You can use them for sms. (They will charge you for the sms!!!)
Moderator edit: Link removed
Thanks
Edited by: PhHein on 20.10.2010 16:11 -
Convert PHP Email Code to Using SMTP Authentication
One of my contact forms no longer is able to send (it used to until some server updates were made), for it keeps posting the following error:
Warning: mail() [function.mail]: SMTP server response: 501 5.1.7 Invalid address in C:\contact.php on line 71
This form does work on three other servers, so obviously the form is in working order but not on this particular server.
I was recommended to "set the PHP script up to log in to the SMTP server" using this example:
http://email.about.com/od/emailprogrammingtips/qt/PHP_Email_SMTP_Authentication.htm
I've only gotten this far and cannot figure out how to actually create it to SEND:
<?php
// set flag to indicate whether mail has been sent
$mailSent = false;
if (array_key_exists('eList', $_POST)) {
// mail processing script
// remove escape characters from POST array
if (get_magic_quotes_gpc()) {
function stripslashes_deep($value) {
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
$_POST = array_map('stripslashes_deep', $_POST);
$email = $_POST['email'];
// check for valid email address
$pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
if (!preg_match($pattern, trim($email))) {
$error['email'] = 'Please enter a valid email address';
// validate the input, beginning with name
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your First Name';
$lname = trim($_POST['lname']);
if (empty($lname)) {
$error['lname'] = 'Please enter your Last Name';
$department = $_POST['department'];
if ($_POST['department'] == '') {
$error['department'] = 'Please select a Department';
// check the content of the text area
$messageBody = trim($_POST['message']);
if (empty($messageBody)) {
$error['message'] = 'Please enter your message';
// initialize variables
if (!empty($_POST['url'])) {
$to = '[email protected]';//
$subject = 'Suspected as SPAM';
$host = 'smptout.serverserver.net';
$username = 'username';
$password = 'password';
} else {
$to = '[email protected]';//
$subject = 'Here we are';
$host = 'smptout.serverserver.net';
$username = 'username';
$password = 'password';
$SpamErrorMessage = "No URLs permitted";
if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$lname")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();}
if (preg_match("/http/i", "$messageBody")) {echo "$SpamErrorMessage"; exit();} // check for spam
//build the message
$smtp = Mail::factory('smtp',
array('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$message = "To: $department\r\n\r\n";
$message .= "From: $name $lname\r\n";
$message .= "$email\r\n\r\n";
$message .= "Question/Comment: $messageBody";
//build the additional headers
$additionalHeaders = "From: Contact <[email protected]>\r\n";
$additionalHeaders .= "Reply-To: $email";
//send the email if there are not errors
if (!isset($error)) {
$mailSent = mail($to, $subject, $message, $additionalHeaders);
// check that the mail was sent successfully
if (!$mailSent) {
$error['notSent'] = 'Sorry, there was a problem sending your mail. Please try later.';
?>
Thank you for your help!Anyone?
-
PHP email form - issue with who it's from
Hi,
I've got a referral page on my site where the user puts in their details and a friends details and the form fires off a email to the friend. The form is in HTML and posts it to a PHP file. The problem is I get in the email for who it's from:
from
"Scott Bradshaw"@server74.ukservers.net
I don't want the
@server74.ukservers.net
in their.
Is this an issue with PHP files and forms or is their a way round it? I know I could do a mailto: form but don't want to. What are my options?
Thanks, ScottI'm making the website for someone and they had the hosting set up already but thanks for telling me. I think this is right what I've done:
function detectSuspect($val, &$ok) {
if (preg_match('/Content-Type:|Cc:|Bcc:/i', $val)) {
$ok = false;
$YourName = Trim(stripslashes($_POST['YourName']));
$YourEmail = Trim(stripslashes($_POST['YourEmail']));
$RefName = Trim(stripslashes($_POST['RefName']));
$RefEmail = Trim(stripslashes($_POST['RefEmail']));
$EmailFrom = $YourEmail;
$Subject = $RefName;
$EmailTo = $RefEmail;
// validation
$validationOK=true;
detectSuspect($YourName, $validationOK);
detectSuspect($YourEmail, $validationOK);
detectSuspect($RefName, $validationOK);
detectSuspect($RefEmail, $validationOK);
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
exit;
// prepare email body text
$Body = "Hi $RefName,
$YourName thought you would be interested in viewing this online video called A
tale of 2 customers (< 3 mins).
www.easybench.org/ataleof2customers3";
$Body2 = "";
$Body2 .= "User Name: ";
$Body2 .= $YourName;
$Body2 .= "\n";
$Body2 .= "User Email: ";
$Body2 .= $YourEmail;
$Body2 .= "\n";
$Body2 .= "Referral Name: ";
$Body2 .= $RefName;
$Body2 .= "\n";
$Body2 .= "Referral Email: ";
$Body2 .= $RefEmail;
$Body2 .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom<$EmailFrom>");
mail("[email protected]", "Referral details", $Body2, "From: [email protected]");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou2.html\">";
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
?>
I've also got a feedback form thing too, the script above wouldn't work for it I guess as it's protecting against different thing but what's the best way to protect the feedback form? I've heard of a honeypot thing where create hidden form field.
Thanks, Scott -
PHP Email Attachment Trouble Shooting
I am having problems finding a good example php script to send an attachment in my email form. I have written many scripts. Can someone help me? I will attach my current script below.
<?php
$subject = 'Online Application Candidate';
$emailadd = '[email protected]';
$url = 'http://www.mydomain.com/Form/application_recieved.htm';
$req = '0';
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
$tmp_name = $_FILES['file']['tmp_name'];
$type = $_FILES['file']['type'];
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$text = "MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$text . "\n\n";
"--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$Form_Attachments}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$text = "Application Results:\n\n";
$space = ' ';
$line = '
foreach ($_POST as $key => $value)
if ($req == '1')
if ($value == '')
{echo "$key is empty";die;}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
function heal($str) {
$injections = array('/(\n+)/i',
'/(\r+)/i',
'/(\t+)/i',
'/(%0A+)/i',
'/(%0D+)/i',
'/(%08+)/i',
'/(%09+)/i'
$str= preg_replace($injections,'',$str);
return $str;
function isInjected($str) {
$injections = array('(\n+)',
'(\r+)',
'(\t+)',
'(%0A+)',
'(%0D+)',
'(%08+)',
'(%09+)'
$inject = join('|', $injections);
$inject = "/$inject/i";
if(preg_match($inject,$str)) {
return true;
else {
return false;
$allowedExts = array("doc", "docx", "xml", "xls", "xlsx", "pdf");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "application/doc")
|| ($_FILES["file"]["type"] == "application/docx")
|| ($_FILES["file"]["type"] == "application/xml")
|| ($_FILES["file"]["type"] == "application/xls")
|| ($_FILES["file"]["type"] == "application/xlsx")
|| ($_FILES["file"]["type"] == "application/pdf"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
if ($_FILES["file"]["error"] > 0)
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
else
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
echo $_FILES["file"]["name"] . " already exists. ";
else
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
else
echo "Invalid file";
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>No trouble at all: http://www.telstra.com.au/account-services/mobile-support/?deviceId=8455#tab-messaging-email
-
Simple php email form, on X-serve 10.39 unlimited
hello! thank you for looking at this.
i'm being asked to add a contact form to my company's website. i'm not a designer or anything. i'm just feeling my way through things barely.
i've implemented this code on the site: http://www.freecontactform.com/email_form.php
things seem to be working ok, except a test email is never recieved in the end. i excpe this is something with the server side handling of the email parts of the code.
but i have almost no clue about what to check on the server to fix this.
i realize there are problably other threads that could maybe help me, but i know very little and thought it might be faster to post a new thread, because the boss wants this done tomorrow.
i am using server admin 10.3 v106, 2003
thanks for any help!it looks like i'm running php 4.4.7
one of my concerns is that this version might be too old to handle the script. -
Help with ActionScript/PHP email form
Hey guys, hope someone can help me out with this!
Haven't programmed in a while, but a friend asked me to look
at this and figure out why it isn't working. It's a simple form,
with the text boxes labeled inTxt_1, inTxt_2 ..... inTxt_13.
The ActionScript looks like this ...
Code:
submit.onRelease = function () {
var loadv = new LoadVars();
loadv._level0.mc1.inTxt_1 = _level0.mc1.inTxt_1.text;
loadv._level0.mc1.inTxt_2 = _level0.mc1.inTxt_2.text;
loadv._level0.mc1.inTxt_3 = _level0.mc1.inTxt_3.text;
loadv._level0.mc1.inTxt_4 = _level0.mc1.inTxt_4.text;
loadv._level0.mc1.inTxt_5 = _level0.mc1.inTxt_5.text;
loadv._level0.mc1.inTxt_6 = _level0.mc1.inTxt_6.text;
loadv._level0.mc1.inTxt_7 = _level0.mc1.inTxt_7.text;
loadv._level0.mc1.inTxt_8 = _level0.mc1.inTxt_8.text;
loadv._level0.mc1.inTxt_9 = _level0.mc1.inTxt_9.text;
loadv._level0.mc1.inTxt_10 = _level0.mc1.inTxt_10.text;
loadv._level0.mc1.inTxt_11 = _level0.mc1.inTxt_11.text;
loadv.send("email.php",loadv,"POST");
(Quick question ... why is the _level0.mc1 part needed? Or is
it even required?)
Here's the PHP ...
Code:
<?php
$To = "[email protected]";
$subject = "site reply";
$Name = $_POST["inTxt_1"];
$Email = $_POST["inTxt_2"];
$Company = $_POST["inTxt_3"];
$Position = $_POST["inTxt_4"];
$Address = $_POST["inTxt_5"];
$Address1 = $_POST["inTxt_6"];
$Address2 = $_POST["inTxt_7"];
$ZipCode = $_POST["inTxt_8"];
$Country = $_POST["inTxt_9"];
$Tel = $_POST["inTxt_10"];
$Enquiry = $_POST["enquiry"];
$Comments = $_POST["inTxt_11"];
\$headers = "From: " . $_POST["inTxt_1"]. "<" .
$_POST["inTxt_2"] .">\r\n";
$headers .= "Reply-To: " . $_POST["inTxt_2"] . "\r\n";
$headers .= "Return-path: " . $_POST["inTxt_2"];
$message = "Name: $Name\n";
$message .= "Position: $Position\n";
$message .= "Company: $Company\n";
$message .= "Email: $Email\n";
$message .= "Address: $Address\n";
$message .= "Address1: $Address1\n";
$message .= "Address2: $Address2\n";
$message .= "Zip Code: $ZipCode\n";
$message .= "Country: $Country\n";
$message .= "Enquiry: $Enquiry\n";
$message .= "Phone: $Tel\n";
$message .= "Comments: $Comments\n";
mail($To, $subject, $message, $headers);
Print "Your mail has been sent";
?>
(Another question - why does the one $headers line have a /
infront of it? Should it be there?)
Now when I submit it, "Your mail has been sent" appears on
the screen, but I don't receive an e-mail. Can anyone help me??
Thanks so much!!
~Ganjall those loadv._level0.mc1.whatever variables are incorrect.
they should be: -
PHP Email form, need help...
Heya,
I have a flash form that uses PHP to send the data to an
email, but it causes all of the data to display on the same line
with no spaces when recieved via email, can anyone help? Thanks!
Code:
<?php
$sendTo = "[email protected]";
$subject = "Contact Form from Cabinet Source Website";
$headers = "From: " . $_POST["name"] ." ". $_POST["phone"] .
"<" . $_POST["comments"] .">\r\n";
$headers .= "Reply-To: " . $_POST["name"] . "\r\n";
$headers .= "Return-path: " . $_POST["name"];
$message = $_POST["comments"];
mail($sendTo, $subject, $message, $headers);
?>As bregent says, the names of the variables you're assigning at the top of the script don't match the variables that you're adding to the $body.
Another problem is that you're using lowercase for the $_POST array. For example, you have $_post['gt']. PHP is case-sensitive. It should be $_POST['gt'].
Even when you get those problems sorted out, the script is extremely insecure because you're not checking any of the values submitted. In particular, you're assigning the value of the 'gt' input field to the From: header. This will lay the form wide open to attack by spammers. (Google for "email header injection" to understand the problem.)
If you want to put a value from the form into the headers, you must first make sure it's safe. For example, I see that gt is meant to be an Xbox Live gamertag. Assuming it must contain only letters and numbers, you should sanitize it like this before inserting it into the headers:
$gt = filter_input(INPUT_POST, 'gt', FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/^[a-zA-Z0-9]+$/'))); -
I'm sending a php form to an email address. The form does
send to my email and a message sent page is working for the user
filling in the form. However, I need to put the name, address, and
phone number included with the message that is sent to the e-mail.
This is the code that I am using:
<?php
$to = "[email protected]";
$subject = $_POST['subject'];
$body = $_POST['body'];
$headers = "From: [email protected]" .
$_POST['[email protected]'] . "\n";
mail($to,$subject,$body,$headers);
?>
I've tried putting $name = $_POST['name']; in the code, put
it doesn't seem to work. Is something like this possible. If so,
where do I add the code so I can include more information on the
form (name, address and phone number)?
Thanks for any help you can give me.A simpler way would be to just use successive concatenation
rather than
heredoc, at least I think. Use this -
> $reply_message_subject = $_POST['subject'];//Subject of
new message from
> form
> $reply_message_body = $_POST['body'];//Body of new
message from form add
> all
> the text you want and links
Then use this -
$reply_message_body .= "\n\rName = ".$_POST['name'];
$reply_message_body .= "\n\rnickname = ".$_POST['nickname'];
$reply_message_body .= "\n\rdog-name = ".$_POST['dog-name'];
etc., etc., etc.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com
- Template Triage!
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
http://www.macromedia.com/support/search/
- Macromedia (MM) Technotes
==================
"MikeL7" <[email protected]> wrote in
message
news:f8elib$p93$[email protected]..
> The heredoc MAIL function is what you want here is one i
made from your
> info:
> i am not sure about your mailheaders line, sending an
email from yourself
> to
> yourself, i guess with the info on the form, but try
this:
>
> $to = "[email protected]";
> $reply_message_subject = $_POST['subject'];//Subject of
new message from
> form
> $reply_message_body = $_POST['body'];//Body of new
message from form add
> all
> the text you want and links
> $config_mailheaders = "From: [email protected]";
>
> //this is the actual email sent
> $reply_body=<<<_MAIL_
>
http://adobe.com/
> so you can see this is where you put more info
>
http://google.com/
> $reply_message_body
> thanks for filling out the form
>
>
> _MAIL_;
> //end actual email
>
>
> mail($to, $reply_subject, $reply_body,
$config_mailheaders);//Send email
>
> -
Hi
I have a php file which generates an email from a form in a
website I have designed. I just want to make some areas of the
final generated email in bold text. I know if people have plain
text only selected in their email client they won't see the bold
text, but at least it will reach a certain percentage of users.
the line in question is -
$body ="Booking request details from website:\n\n";
I have tried putting <b></b> and
<strong></strong>, inside the inverted commas, outside
etc, plus tried different declarations within the <head>,
nothing works! What am I doing wrong?
I am a beginner with this php stuff, please be kind!
Thanks.oO(BarryGBrown)
> I have a php file which generates an email from a form
in a website I have
>designed. I just want to make some areas of the final
generated email in bold
>text. I know if people have plain text only selected in
their email client they
>won't see the bold text, but at least it will reach a
certain percentage of
>users.
You can't do bold text in a normal email. Plain text is just
that -
plain text. For anything more you need HTML. _If_ you should
need it.
Usually plain text serves pretty well and is the most
efficient way.
> the line in question is -
>
> $body ="Booking request details from website:\n\n";
>
> I have tried putting and ,
syntax is used in some forum software, but besides that it
has
no meaning whatsoever.
>inside the inverted commas, outside
>etc, plus tried different declarations within the
<head>, nothing works! What
>am I doing wrong?
You would have to create an entire HTML email with all the
required
headers and boundaries. Quite difficult to do by hand with
PHP's mail()
function.
> I am a beginner with this php stuff, please be kind!
Then you should start simple with plain text. There are some
classes out
there which make it easy to generate text and HTML emails
(phpmailer for
example), but you should be familiar with PHP coding if you
want to use
them.
Micha -
PHP email form with Validation - not working
Hello;
I am new to using php. I usually use coldfusion or asp but this site requires me to write in php. I have a form I am trying to get to work and right now.. it doesn't do anyhting but remember what you put in the fields. It doesn't want to send, and it won't execute the validation script for the fields that are required. Can anyone help me make this work? I'm confused and a definate newbie to PHP.
Here is my code:
<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$errName = "";
$errEmail = "";
$errPhone = "";
if(isset($_POST['submit'])) {
if($_POST["ac"]=="login"){
$FORMOK = TRUE; // $FORMOK acts as a flag. If you enter any of the conditionals below, // it gets set to FALSE, and the e-mail will not be sent.
// First Name
if(preg_match("/^[a-zA-Z -]+$/", $_POST["name"]) === 0) {
$errName = '<div class="errtext">Please enter you name.</div>';
$FORMOK = FALSE;
// Email
if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $_POST["email"]) === 0) { $errEmail = '<div class="errtext">Please enter a valid email.</div>';
$FORMOK = FALSE;
// Phone
if(preg_match("/^[a-zA-Z -]+$/", $_POST["phone"]) === 0) {
$errPhone = '<div class="errtext">Please enter your phone number.</div>';
$FORMOK = FALSE;
if($FORMOK) {
$to = "[email protected]";
$subject = "my. - Contact Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$phone_field = $_POST['phone'];
$city_field = $_POST['city'];
$state_field = $_POST['state'];
$message = $_POST['comment'];
$message = "
Name: $name_field
Email: $email_field
Phone: $phone_field
City: $city_field
State: $state_field
Message: $message";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: <[email protected]>' . "\r\n";
$headers .= '[From] <$email_field>' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
header("Location: thankyou.php")
// I have no idea what these next 3 lines are for. You may just want to get rid of them.
ini_set("sendmail_from","[Send from]");
ini_set("SMTP","[mail server]");
mail($to, $subject, $message, $headers);
} else {
echo "Error!";
?>
<form method="post" action="<?php $PHP_SELF ?>" id="commentForm">
<input name="name" size="40" value="<?php echo $_POST["name"]; ?>" type="text">
<?php if(isset($errName)) echo $errName; ?>
<input name="email" size="40" value="<?php echo $_POST["email"]; ?>" type="text">
<?php if(isset($errEmail)) echo $errEmail; ?>
<input name="phone" size="40" value="<?php echo $_POST["phone"]; ?>" type="text" id="phone">
<?php if(isset($errPhone)) echo $errPhone; ?>
<input name="city" size="40" value="<?php echo $_POST["city"]; ?>" type="text" id="city">
<input name="state" size="40" value="<?php echo $_POST["state"]; ?>" type="text" id="state">
<textarea name="comment" cols="30" rows="10" id="comment"><?php echo $_POST["comment"]; ?></textarea>
<input type="submit" value="Submit" name="submit" class="contact-submit" />
</form>
It seems pretty simple.. but it's not working at all. I would also like this page to submit to it's self, and when it actually does send an email, to just make the form disappear and replace it with the thank you text instead of sending you to another page. I also do not need to use an smtp server, it goes directly to the network server when sent.
I'm really sorry to ask all of this, I'm trying to learn this language and need to make this work.
Thank you for anyones help in advance..oO(BarryGBrown)
> I have a php file which generates an email from a form
in a website I have
>designed. I just want to make some areas of the final
generated email in bold
>text. I know if people have plain text only selected in
their email client they
>won't see the bold text, but at least it will reach a
certain percentage of
>users.
You can't do bold text in a normal email. Plain text is just
that -
plain text. For anything more you need HTML. _If_ you should
need it.
Usually plain text serves pretty well and is the most
efficient way.
> the line in question is -
>
> $body ="Booking request details from website:\n\n";
>
> I have tried putting and ,
syntax is used in some forum software, but besides that it
has
no meaning whatsoever.
>inside the inverted commas, outside
>etc, plus tried different declarations within the
<head>, nothing works! What
>am I doing wrong?
You would have to create an entire HTML email with all the
required
headers and boundaries. Quite difficult to do by hand with
PHP's mail()
function.
> I am a beginner with this php stuff, please be kind!
Then you should start simple with plain text. There are some
classes out
there which make it easy to generate text and HTML emails
(phpmailer for
example), but you should be familiar with PHP coding if you
want to use
them.
Micha -
Need help adapting David Powers PHP email form script please!
Hi all,
I'm fairly inexperienced with PHP and I'm trying to adapt the David Powers email form script from THE ESSENTIAL GUIDE TO DREAMWEAVER CS4 WITH CSS, AJAX, AND PHP.
I've created a basic form so that visitors to the site can request a telephone call back from the site owner. The form asks the visitor for their name, telephone number and to select a time of day suitable for the telephone call to be made using radio buttons selecting between morning and afternoon.
I'd like to achieve my goal with minimal validation error messages and would like to redirect to another page when a message is sent successfully. It is also important that in the spirit of the David Powers script I'm trying to work with, that it filters out suspect input, avoids email header injection attacks and blocks submission by spam bots.
There may be a really simple solution to this since I don't want users to be able to enter an email address at all but I don't know enough to be able to figure it out just yet.
I'd be grateful for any advice.
See below for the code for the form including PHP so far...
Thanks to everyone looking in in advance
Karl.GEAtkins wrote:
> I am using the redirect to a personal page from page 515
of The Essential
> Guide to DWCS3 in the following form:
$_SESSION[MM_Username].php in the "if
> login succeeds" field.
Thank you for reminding me. There's a mistake in the book,
which I
discovered over the Christmas period, so forgot to send to
friends of ED
for the errata page.
Don't use $_SESSION[MM_Username]. Use $loginUsername instead.
It then works.
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Maybe you are looking for
-
Looking for an Answer About Upgrading
Hello Droid Friends, I am looking to upgrade from a Samsung 510 still on the Alltel network, to the Incredible and I am still a bit worried I don't have all the answers I need. I have talked to 3 different associates and have had totally different an
-
Hi All, Item with LOV defined and i wnat to dispaly the lov based on : for Ex if :P1_item >=1 then select ename d, ename r from emp; else select deptno d, deptno r from dept; end if; it is not working any idea? I am getting error ERR-1000 Unable to d
-
Migration guidelines to goto Lion, iOS5 and iCloud
hello I'm using a MacBook Pro ( running OSX 10.6.8 ) an iPhone4 ( iOS 4.3.5 ) and an iPad2 ( iOS 4.3.5 ) all three sync email ( mutilple pop accounts ), calendar and contacts using MobileMe - all works fine now I would like to goto Lion, iOS5 and iCl
-
Samsung 244T on Mac OS X - does it rotate to portrait mode?
I'm thinking of buying a Samsung 24" LCD panel - one of it's more interesting features (for me, at least) is the ability to rotate the panel from landscape to portrait mode - does anyone know if this feature works for sure in MacOS X? Dual 2GHz G5
-
EventListeners for multiple remote object calls
Hi all, I have a Flex component that is displaying content from multiple (specifically two) remote object calls. I can call both remote methods, get the results back, pass them off to their respective ItemRenderers, etc. with no trouble. What I need,