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
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 12:08 am
ok i got a form on my website.. when people fill it out and everything it brings them to another page which emails the form to be ... it all works good. however i wanted to know how to make a email that uses php and html in it...
this is the html/php script that needs to be emailed to me..
Code: Select all
<html>
<div align="center"><center><table WIDTH="600" BORDER="0">
<tr>
<td ALIGN="center" VALIGN="top" style="border: 1px"><font COLOR="#000000"><b>General
Information</b></font></td>
</tr>
<tr>
<td ALIGN="center" style="border: 1px"><table WIDTH="590" CELLPADDING="2" CELLSPACING="0"
BORDER="0">
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Name:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$realname</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Address:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$address</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">City:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$City <b>State:</b> $State
<b>ZIP:</b> $Zip</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">County:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$County <b>Email:</b> $email</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Residence of:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$ResidenceOf
If township, enter name</font>$EnterTownship</td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Phone Day:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$DayPhone( <b>Night:</b> $NightPhone</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Date of Birth:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1"> $DateOfBirth Do you use tobacco in any form? $TobaccoUse </font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Amount of <br>
Coverage:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1"> $AmountOfCoverage </font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Type of <br>
Coverage<br>
Desired?</font></b></td>
<td ALIGN="LEFT" VALIGN="middle"><font SIZE="-1"><div align="left"><p>$TypeOfLife</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"></td>
<td ALIGN="LEFT" VALIGN="TOP"></td>
</tr>
</table>
</td>
</tr>
</table>
</center></div><div align="center"><center><table WIDTH="600" BORDER="0">
<tr>
<td ALIGN="center" VALIGN="top"><font COLOR="#000000"><b>Additional Comments:</b></font></td>
</tr>
<tr>
<td ALIGN="CENTER"><table WIDTH="590" CELLPADDING="2" CELLSPACING="0" BORDER="0">
<tr>
<td ALIGN="center"><table BORDER="0" CELLSPACING="0" width="585">
<tr>
<td ALIGN="center" width="618"><font SIZE="-1">Please give any additional comments about
the coverage you desire:<br>
$comments</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center></div><div align="center"><center><table BORDER="0" CELLPADDING="5">
<tr>
</tr>
</table>
</center></div></td>
</tr>
</table>
</center></div>
</form>
<p align="center"><strong><i>Thank you for your time in submitting this life insurance
quote form. <br>
</i><em>Please allow 1 day for quotation.</em></strong><br>
</p>
</body>
</html>
the mail script is...
Code: Select all
<?
mail("nickman013@mac.com,nick@regionalplanning.com,angela@regionalplanning.com",
"Regional Planning Home Quote Submission Form","Submitted Content
EMAIL STUFF HERE!
?>
<html>
<form name="redirect">
<center>
<font face="Arial"><b>You will be redirected in:<br><br>
<form>
<input type="text" size="3" name="redirect2">
</form>
seconds</b></font>
</center>
<script>
<!--
//change below target URL to your own
var targetURL="http://regionalplanning.com"
//change the second to start counting down from
var countdownfrom=5
var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if (currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
window.location=targetURL
return
}
setTimeout("countredirect()",1000)
}
countredirect()
//-->
</script>
</html>
where it says EMAIL STUFF HERE i would put the php/html script in.. however it will not work.. howdo i do this?
feyd | please post php code using
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 14, 2005 12:14 am
have the first file actually be a script that creates the html as a string. Store all that inside a function that returns this string for you to email.
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 12:16 am
feyd, thank you for responding very fast.
i am quite a noobie at this .. can you please tell me this in noob words. thank you again
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 14, 2005 12:21 am
create a string using the first file's HTML (the file you want to send).
store this string for use by your script (I'd suggest creating a function )
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 12:25 am
thanks again for the quick response...
this is probly simple to you to do...
this will probly take me 3-4 weeks lol... thanks alot
also... is there a easier tutorial or somthing than the one you provided me?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 14, 2005 12:38 am
here's a quick head start example:
Code: Select all
function generateEmail($realname, $address)
{
return <<<STOP
<html>
<div align="center"><center><table WIDTH="600" BORDER="0">
<tr>
<td ALIGN="center" VALIGN="top" style="border: 1px"><font COLOR="#000000"><b>General
Information</b></font></td>
</tr>
<tr>
<td ALIGN="center" style="border: 1px"><table WIDTH="590" CELLPADDING="2" CELLSPACING="0"
BORDER="0">
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Name:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$realname</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Address:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$address
STOP;
}
// ..........
mail("nickman013@mac.com,nick@regionalplanning.com,angela@regionalplanning.com",
"Regional Planning Home Quote Submission Form",generateEmail($realname, $address));
You'll have to add more function arguments as you add more parts of the email. The string example I used above is a heredoc, which is talked about on the string page of the manual I linked to earlier. The function page (linked to earlier) will explain what arguments are and how they are added to a function's call to pass the data into the function.
This assumes you know all the variables used inside the HTML at the time of creating the email (which you should, don't you?)
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 12:49 am
ok i think i did it right
Code: Select all
function generateEmail($realname, $Address, $City, $State, $Zip, $County, $email, $ResidenceOf, $EnterTownship, $DayPhone, $NightPhone, $DateOfBirth, $TobaccoUse, $AmountOfCoverage, $TypeOfLife, $comments)
{
return <<<STOP
<html>
<div align="center"><center><table WIDTH="600" BORDER="0">
<tr>
<td ALIGN="center" VALIGN="top" style="border: 1px"><font COLOR="#000000"><b>General
Information</b></font></td>
</tr>
<tr>
<td ALIGN="center" style="border: 1px"><table WIDTH="590" CELLPADDING="2" CELLSPACING="0"
BORDER="0">
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Name:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$realname</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Address:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"
><font SIZE="-1">$address</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">City:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$City <b>State:</b> $State
<b>ZIP:</b> $Zip</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">County:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$County <b>Email:</b> $email</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Residence of:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$ResidenceOf
If township, enter name</font>$EnterTownship</td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Phone Day:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1">$DayPhone( <b>Night:</b> $NightPhone</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Date of Birth:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1"> $DateOfBirth Do you use tobacco in any form? $TobaccoUse </font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Amount of <br>
Coverage:</font></b></td>
<td ALIGN="LEFT" VALIGN="TOP"><font SIZE="-1"> $AmountOfCoverage </font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"><b><font SIZE="-1">Type of <br>
Coverage<br>
Desired?</font></b></td>
<td ALIGN="LEFT" VALIGN="middle"><font SIZE="-1"><div align="left"><p>$TypeOfLife</font></td>
</tr>
<tr>
<td ALIGN="right" VALIGN="bottom"></td>
<td ALIGN="LEFT" VALIGN="TOP"></td>
</tr>
</table>
</td>
</tr>
</table>
</center></div><div align="center"><center><table WIDTH="600" BORDER="0">
<tr>
<td ALIGN="center" VALIGN="top"><font COLOR="#000000"><b>Additional Comments:</b></font></td>
</tr>
<tr>
<td ALIGN="CENTER"><table WIDTH="590" CELLPADDING="2" CELLSPACING="0" BORDER="0">
<tr>
<td ALIGN="center"><table BORDER="0" CELLSPACING="0" width="585">
<tr>
<td ALIGN="center" width="618"><font SIZE="-1">Please give any additional comments about
the coverage you desire:<br>
$comments</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</center></div><div align="center"><center><table BORDER="0" CELLPADDING="5">
<tr>
</tr>
</table>
</center></div></td>
</tr>
</table>
</center></div>
</form>
STOP;
}
// ..........
mail("nickman013@mac.com,nick@regionalplanning.com,angela@regionalplanning.com",
"Regional Planning Home Quote Submission Form",generateEmail($realname, $Address, $City, $State, $Zip, $County, $email, $ResidenceOf, $EnterTownship, $DayPhone, $NightPhone, $DateOfBirth, $TobaccoUse, $AmountOfCoverage, $TypeOfLife, $comments);
feyd | please use Code: Select all
tags when posting php code.[/color]
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 1:38 am
due to the help of feyd i got this working...
feyd helped me on MSN messenger and he didnt give up or ignore me like most other people would have.
feyd tryed to solve the problem and it didnt work the first time so he figured out what was wrong and he fixed it for me.
i wish i could have known about these forums a while ago
thanks again feyd
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Aug 14, 2005 1:42 am
Afterall, Feyd is the allknowing god...
what was the problem?
what was the fix?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 14, 2005 1:50 am
the lowdown:
nickman013's server is running php3 ("dear lord!" you say!)
So although my initial suggestion is perfectly valid for php4 (I did not know it was php3 at that time), we had to change that around to a bigass quoted string. (Wee!)
that's the gist.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun Aug 14, 2005 1:51 am
For the love of god, upgrade.
If that's not possible in the futur mention you are using php3.. it's a whole new ball game.
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 1:53 am
i can upgrade... its the owners web host anyway (earthlink), they got the site like 5 years ago and we can move to their new servers but it will take 2 days and at the time we didnt have time to move to the new server. but when we do i will have everythig updated
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 14, 2005 1:58 am
from personal experience.. "move away from the Earthlink, please step away from the Earthlink, sir."
I've had waking nightmares dealing with them.. not fun. I'm not going to suggest where to go,
and no one else should either (or you'll face my wrath "Yes, you. I'm talking to you, the guy in the red shirt and Harry Potter style glasses. ") as a hell of a lot of hosts are talked about in
Web Hosting
nickman013
Forum Regular
Posts: 764 Joined: Sun Aug 14, 2005 12:02 am
Location: Long Island, New York
Post
by nickman013 » Sun Aug 14, 2005 9:32 am
its business hosting from earthlink if it makes a difference.
what kind of problems did you have with them?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 14, 2005 7:33 pm
their support for a client's hosting account.. it was just super painful to deal with them..