Linked Email Address in PHP contact form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Apryle
Forum Newbie
Posts: 7
Joined: Wed Jul 18, 2007 12:54 pm

Linked Email Address in PHP contact form

Post by Apryle »

pickle | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I have a php form at [url]http://www.estesparkweddings.com/contactus.shtml[/url]

the potential client enters an email address (along with other info) that is processed by the below php. When I receive the submitted form via email, the email address the client entered is not a hyperlink, just plain text.

The form is working great, so no need to pick apart my code, even if there is a more efficient way to do things (which there usually is). Anyone know how I can get the email address to show up in the email as a link instead of plain text? (I need it to be a universal solution as some of the folks accessing the form have yahoo email, some use Outlook, some use gmail, some use aol, etc.). Thanks!!

[syntax="php"]
<?php

// get posted data
$EmailFrom = "info@allyourssolutions.com";
$EmailTo = "apryle@allyourssolutions.com";
$Subject = "test request";
$Name = Trim(stripslashes($_POST['Name']));
$Street1 = Trim(stripslashes($_POST['Street1']));
$Street2 = Trim(stripslashes($_POST['Street2']));
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Tel = Trim(stripslashes($_POST['Tel']));
$email1 = Trim(stripslashes($_POST['email1']));
$confirmemail = Trim(stripslashes($_POST['confirmemail']));
$zip = Trim(stripslashes($_POST['zip']));
$bride = Trim(stripslashes($_POST['bride']));
$groom = Trim(stripslashes($_POST['groom']));
$preferredDate = Trim(stripslashes($_POST['preferredDate']));
$alternateDate = Trim(stripslashes($_POST['alternateDate']));
$guests = Trim(stripslashes($_POST['guests']));
$beauty = Trim(stripslashes($_POST['beauty']));
$cakes = Trim(stripslashes($_POST['cakes']));
$cermonySites = Trim(stripslashes($_POST['ceremonySites']));
$consultants = Trim(stripslashes($_POST['constultants']));
$florists = Trim(stripslashes($_POST['florists']));
$gifts = Trim(stripslashes($_POST['gifts']));
$invitations = Trim(stripslashes($_POST['invitations']));
$limos = Trim(stripslashes($_POST['limos']));
$honeymoons = Trim(stripslashes($_POST['honeymoons']));
$music = Trim(stripslashes($_POST['music']));
$rentals = Trim(stripslashes($_POST['rentals']));
$photographers = Trim(stripslashes($_POST['photographers']));
$receptions = Trim(stripslashes($_POST['receptions']));
$videographers = Trim(stripslashes($_POST['videographers']));
$officials = Trim(stripslashes($_POST['officials']));

// check for required fields
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($email1)=="") $validationOK=false;
if (Trim($confirmemail)=="") $validationOK=false;
if (Trim($guests)=="") $validationOK=false;
if (!is_numeric($guests)) $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error1.shtml\">";
exit;
}

// email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "email1: ";
$Body .= $email1;
$Body .= "\n";
$Body .= "confirmemail: ";
$Body .= $confirmemail;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Street1: ";
$Body .= $Street1;
$Body .= "\n";
$Body .= "Street2: ";
$Body .= $Street2;
$Body .= "\n";
$Body .= "City: ";
$Body .= $City;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "zip: ";
$Body .= $zip;
$Body .= "\n";
$Body .= "Bride Name: ";
$Body .= $bride;
$Body .= "\n";
$Body .= "Groom Name: ";
$Body .= $groom;
$Body .= "\n";
$Body .= "guests: ";
$Body .= $guests;
$Body .= "\n";
$Body .= "Preferred Date: ";
$Body .= $preferredDate;
$Body .= "\n";
$Body .= "Alternate Date: ";
$Body .= $alternateDate;
$Body .= "\n";
$Body .= "Ceremony Location: ";
$Body .= $ceremony;
$Body .= "\n";
$Body .= "\n";
$Body .= "Info has been requested in the following Categories:";
$Body .= "\n";

if ($beauty == beauty){
$Body .= "Beauty Information Requested ";
$Body .= "\n";
}
else{
$Body .= " ";
}

if ($cakes == cakes){
$Body .= "Cakes and Catering Information Requested ";
$Body .= "\n";
}
else{
$Body .= " ";
}

if ($ceremonySites == ceremonySites){
$Body .= "Ceremony Sites Information Requested ";
$Body .= "\n";
}
else{
$Body .= " ";
}

if ($consultants == consultants){
$Body .= "Consultants Information Requested ";
$Body .= "\n";
}
else{
$Body .= " ";
}


// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to thank you page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=thankyou.shtml\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error2.shtml\">";
}
?>
pickle | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

There's no way to do it without resorting to html email - which will likely cause a bunch more problems.

Oh, and use

Code: Select all

header("Location: blah.html");
rather than printing meta tags.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Make sure it's a full URL used when redirecting via header() though. ;)
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

feyd wrote:Make sure it's a full URL used when redirecting via header() though. ;)
Good point - I never realized that.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply