Some help needed

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
Reikiii
Forum Newbie
Posts: 2
Joined: Sat Jun 27, 2009 4:41 pm

Some help needed

Post by Reikiii »

I have purchased a great template and I have problems to implement the contact form function. The source code is listed below. Any help is much welcomed. Where do I need to make changes? Are there any errors?

Thank you very much!!!

Cindy

<?php

$your_name = $_GET['your_name'];
$your_phone = $_GET['telephone'];
$your_email = $_GET['your_email'];
$your_message = $_GET['message'];




$headers .= 'Content-type: text/html; charset=iso-8859-1';

$content = "<html><head><title>Contact letter</title></head><body><br>";
$content .= "Name: <b>" . $your_name . "</b><br>";
$content .= "Phone: <b>" . $your_phone . "</b><br>";
$content .= "E-mail: <b>" . $your_email . "</b><br><hr><br>";
$content .= $your_message;
$content .= "<br></body></html>";

mail($recipient,$subject,$content,$headers); <br>
$recipient = "info@mywebsite.com";
$subject = "Contact request";
$headers = "From: info@mywebsite.com";

?>
<html>
<body bgcolor="#282E2C">
<div align="center" style="margin-top:60px;color:#FFFFFF;font-size:11px;font-family:Tahoma;font-weight:bold">
Your message was sent. Cindy will contact you shortly. Thank you.
</div>
</body>
</html>
<script>resizeTo(600, 600)</script>



There is another file called 'activescript' as follows:

<%
for i=1 to 7
message=Request("message")
next
message=message + Request("message")
smtpServer = "smtp.1and1.com"
smtpPort = 25


name = Request("Your_Name:")
Set myMail = CreateObject("CDO.Message")
myMail.Subject = "from " & name
myMail.From = Request("Your_Email:")
myMail.To = Request("info@youremail.com")
myMail.HTMLBody = "<html><head><title>Contact letter</title></head><body><br>" & message & "</body></html>"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config ... /sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config ... smtpserver") = smtpServer
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/config ... serverport") = smtpPort
myMail.Configuration.Fields.Update
myMail.Send

%>
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Some help needed

Post by Darhazer »

It seems that PHP and ASP are mixed in the code above. However for the PHP part:

Code: Select all

mail($recipient,$subject,$content,$headers); <br>
$recipient = "info@mywebsite.com";
$subject = "Contact request";
$headers = "From: info@mywebsite.com";
Should be rewritten as:

Code: Select all

 
$recipient = "info@mywebsite.com";
$subject = "Contact request";
$headers .= "\r\nFrom: info@mywebsite.com";
mail($recipient,$subject,$content,$headers);
 
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: Some help needed

Post by a94060 »

Darhazer wrote:It seems that PHP and ASP are mixed in the code above. However for the PHP part:

Code: Select all

mail($recipient,$subject,$content,$headers); <br>
$recipient = "info@mywebsite.com";
$subject = "Contact request";
$headers = "From: info@mywebsite.com";
Should be rewritten as:

Code: Select all

 
$recipient = "info@mywebsite.com";
$subject = "Contact request";
$headers .= "\r\nFrom: info@mywebsite.com";
mail($recipient,$subject,$content,$headers);
 
like Darhazer shows in his code, you are calling the mail function before you are assigning the variables any values. The code posted by Darhazer assigns the variable values first,then mails them (the proper way). Most likely,you are getting blank emails (which must be your problem)
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Some help needed

Post by califdon »

With templates as bad as those finding suckers to actually pay for them, I think I'll go into business!
Reikiii
Forum Newbie
Posts: 2
Joined: Sat Jun 27, 2009 4:41 pm

Re: Some help needed

Post by Reikiii »

Thanks so much guys! It worked right away. I totally appreciate your help... Thank you. Cindy.
Post Reply