Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jdl8422

macrumors 6502
Original poster
Jul 5, 2006
491
0
Louisiana
I am designing a site in dreamweaver using HTML. I have all the pages done except a contact page. I know how to insert a form and get it the way I want it to look. My problem is function. I know there has to a script, like PHP, but I am not sure if I need anything else. Like a service to send the email. Please Help.
 

timmillwood

macrumors 6502a
Apr 7, 2006
955
1
Try something like

Code:
<?php
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<p align=\"center\">You need to enter a valid e-mail address<br><a href=\"index.php\">Click here</a> to go back</p>\n";
}
else
{
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<p align=\"center\">Please fill in the form<br><a href=\"index.php\">Click here</a> to go back</p>\n";
}
else
{
$todayis = date("l, F j, Y, g:i a") ;

$attn = $attn ; 
$subject = $attn; 

$notes = stripcslashes($notes); 

$message = "Sent on: $todayis [GMT] \n
Regarding: $attn \n
Enquiry: $notes \n 
From: $visitor ($visitormail)\n
Browser Info: $httpagent \n
";

$from = "From: $visitormail\r\n";


mail("YOUR EMAIL ADDRESS", $subject, $message, $from);

if($cc == "yes") {
mail($visitormail, $subject, $message, "From:YOUR EMAIL ADDRESS\r\n");

$copy = "This has been copied to $visitormail";
}
?>
    
    </p>
</div>
<p align="center"><b>
Thank you for you email, we will try to reply to the address <?php echo $visitormail ?> asap. </b>

<?php
}
}
?>
 

jdl8422

macrumors 6502
Original poster
Jul 5, 2006
491
0
Louisiana
ok, so i make a page with the PHP and save it but does it have to be named anything special. Also how does the script interact with the form. Im sorry if I do not know what i am talking about, I am pretty new to PHP and scripts
 

janitorC7

macrumors 6502a
Feb 10, 2006
640
20
California
no offense but I don't think that you have the experience to do this.

if you trust me with information I would be more than happy to do it for you as it would only take me a few min.

But just as easy would be using a web service such as My Contact Form.

Which is step by step and does it for you, and then gives a snippet of code that you paste right into DW.

Janitorc7
 

jdl8422

macrumors 6502
Original poster
Jul 5, 2006
491
0
Louisiana
I wanted to know how to do it so I can do it on furture projects. I found a tutorial on how to do it and it did work. The only problem is when I put it on the table for existing site it doesnt work anymore. That is why i came here in the first place
 

operator

macrumors regular
Oct 29, 2006
110
0
Canada
THe logic behind most of these forms is simple. WHen the page loads, there is usually an "if" statement asking if the form has been submitted ... if so, then it process the form, and spits out a thank you message or something similar. If not, it will display the form. These are usually 'multipurpose' pages. It's sort of like have 2 pages built into the 1 file. Hope I didn't confuse you - I'm just trying to help you understand the logic.
 

CanadaRAM

macrumors G5
I wanted to know how to do it so I can do it on furture projects. I found a tutorial on how to do it and it did work. The only problem is when I put it on the table for existing site it doesnt work anymore. That is why i came here in the first place

How you do a form is dependant on the host server the site is on. You have to work with the tools that are installed on the server.

What did your website host say when you called them?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.