Forums

PHP

This topic is locked

ASP to PHP

Posted 11 Dec 2004 22:20:57
1
has voted
11 Dec 2004 22:20:57 Richard Wood posted:
Does any body know how to change/translate the following ASP script into a working PHP version. The script send data from a form to my e-mail. Ive also included the code for the page with the form. Thank you for any help.

ASP script follows

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"www.w3.org/TR/html4/loose.dtd">
%@LANGUAGE="_VBSCRIPT" %>
<%
'///////////////// send cdo email.

'content of the email
mailbody= "<font size=2 face=verdana>"
mailbody=mailbody & Replace(Request.Form("message", vbCrLf, "<br />" & "<br>" & "<br>"
mailbody=mailbody & "<strong>" & "FirstName: " & "</strong>" & Request.Form("firstname" & "<br>"
mailbody=mailbody & "<strong>" & "Lastname: " & "</strong>" & Request.Form("lastname" & "<br>"
mailbody=mailbody & "<strong>" & "Telephone: " & "</strong>" & Request.Form("phonenumber" & "<br>"
mailbody=mailbody & "<strong>" & "Email: " & "</strong>" & Request.Form("email" & "<br>"
mailbody=mailbody & "<strong>" & "Contact me by: " & "</strong>" & Request.Form("radiobutton" & "<br>" & "<BR>"
mailbody=mailbody & "<strong>" & "Address: " & "</strong>" &
mailbody=mailbody & "Sent at " & Now()

'variables to send the email
Set objCDO = Server.CreateObject("Cdonts.NewMail"
objCDO.BodyFormat =0 ' 0 is a plain text, 0 "zero" is a HTML
objCDO.MailFormat = 1 ' 1 is a plain text, 0 "zero" is mime format
objCDO.To = " " ' put your email address here
objCDO.From = Request.Form("email"
objCDO.Subject ="Enquiry from the tempestdesignworks Website"
objCDO.Body =mailbody
objCDO.Send
Set objCDO = Nothing

'///////////////// send cdo email. end

%>
<html>
<head>
<title>thankyou Page</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #3B391A;
}
a {
font-size: 10px;
}
a:link {
color: #666666;
text-decoration: none;
}
a:visited {
color: #333333;
text-decoration: none;
}
a:hover {
color: #000000;
text-decoration: underline;
}
a:active {
text-decoration: none;
}
-->
</style></head>

<body bgcolor="#FFFFFF" >

<p align="center">thankyou, your email has been sent...
</p>
<p align="center"> </p>
<p align="center"><a href="javascript:history.go(-1)">back</a></p>
</body>
</html>

Form Script Follows

<form name="form1" method="post" action="www.benpaulowens.com/cgi-bin/thanks.asp" enctype="text/plain">
<table width="100%" height="280" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="40" colspan="3" align="right" valign="top"><p align="justify" class="generalText">please enter your details in the form below, and i will endeavor to get back to you... </p>
<p align="justify" class="generalText">alternatively you can phone me on 0791 9201881 </p>
<p>  </p></td>
</tr>
<tr>
<td width="99" height="40" align="right" valign="top" class="generalText">first name</td>
<td width="251" height="40" colspan="2" align="left" valign="middle"><p>
<input name="firstname" type="text" class="generalText" id="first name" size="10">
</p>
</td>
</tr>
<tr>
<td width="99" height="40" align="right" valign="top" class="generalText">last name </td>
<td width="251" height="40" colspan="2" align="left" valign="middle"><p align="left">
<input name="lastname" type="text" class="generalText" id="last name" size="10">
</p>
</td>
</tr>
<tr>
<td width="99" height="40" align="right" valign="top" class="generalText">phone number </td>
<td width="251" height="40" colspan="2" align="left" valign="middle"><p align="left">
<input name="phonenumber" type="text" class="generalText" id="phone number" size="12">
</p>
</td>
</tr>
<tr>
<td width="99" height="40" align="right" valign="top"><div align="right" class="generalText">e-mail </div></td>
<td width="251" height="40" colspan="2" align="left" valign="middle"><p align="left">
<input name="email" type="text" class="generalText" id="e-mail" size="25">
</p>
</td>
</tr>
<tr>
<td width="99" height="40" align="center" valign="top"><div align="right"><span class="generalText">how would you like to be contacted </span></div></td>
<td width="251" height="40" colspan="2" align="center" valign="top"><div align="left"><span class="generalText">phone
<input name="radiobutton" type="radio" value="phone" checked>
e-mail
<input name="radiobutton" type="radio" value="e-mail">
</span> </div></td>
</tr>
<tr>
<td align="center" valign="bottom"><div align="right"></div> <div align="right"></div></td>
<td colspan="2" align="center" valign="bottom"><div align="left"><span class="style1">
</span></div></td>
</tr>
<tr>
<td align="center" valign="top"><div align="right" class="generalText">message </div>
<div align="right"></div></td>
<td colspan="2" align="center" valign="bottom"><div align="left"><span class="style1">
<textarea name="message" cols="26" rows="10" wrap="virtual" class="generalText" id="message">enter your message here...</textarea>
</span></div></td>
</tr>
<tr>
<td align="center" valign="bottom"> </td>
<td colspan="2" align="center" valign="bottom"><div align="left"><span class="style1">
</span></div></td>
</tr>
<tr class="generalText">
<td align="center" valign="bottom"><div align="right">
<input name="Submit" type="submit" onClick="MM_validateForm('first name','','R','last name','','R','phone number','','RisNum','e-mail','','RisEmail');return document.MM_returnValue" value="submit">
</div></td>
<td align="center" valign="bottom"><div align="center"><span class="style1">
</span></div></td>
<td align="center" valign="bottom"><div align="left"><span class="style1">
<input type="reset" name="Reset" value="reset"
onClick="reload">
</span></div></td>
</tr>
</table>
</form>

The web address for the form is www.tempestdesignworks.com and navigate thru to "contact"

Replies

Replied 31 Dec 2004 17:16:59
31 Dec 2004 17:16:59 Dave Thomas replied:
there used to be a program around a while ago called asp2php that converted all the syntax.

try havin a look for it

Regards,
Dave

[DWMX 2004]|[FlashMX 2004 Pro]|[SQL]|[Access2000]|[ASP/VBScript]|[XP-Pro]
Replied 31 Dec 2004 18:55:26
31 Dec 2004 18:55:26 Chris Charlton replied:
Also, PHP.net (home of PHP) has wonderful online documentation that's always worth the look.

<b>PHP Mail function(s)/info:</b>
<ul><li>www.php.net/mail</li><li>Variables from outside PHP "HTML Forms (GET and POST)" - www.php.net/manual/en/language.variables.external.php</li><li>...after the above is read, you might want to read: www.php.net/faq.html</li></ul>

Also, here on DMXzone are some <b>Premium Articles</b>:
<ul><li>Creating a Simple Email Form in PHP - www.dmxzone.com/showDetail.asp?TypeId=28&NewsId=5669</li><li>PHP Basics: email contact forms - www.dmxzone.com/showDetail.asp?TypeId=28&NewsId=6637</li><li>PHP: Registration and confirmation email system #1 - www.dmxzone.com/showDetail.asp?TypeId=28&NewsId=6497</li></ul>

And, of course, there's <b>extensions</b> to help less keyboard strain: Smart Mailer PHP (www.dmxzone.com/showDetail.asp?TypeId=3&NewsId=5628), and you can check www.macromedia.com/exchange/ to see others that would be available.

Hope these help. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

~~~~~~~~~~~~~~~
Chris Charlton

Sr. Developer - www.fingerprintMedia.com

Reply to this topic