PDA

View Full Version : Contact Form in HTML Site




jdl8422
Jun 15, 2007, 03:15 PM
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
Jun 15, 2007, 03:21 PM
Try something like



<?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
Jun 15, 2007, 03:30 PM
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
Jun 15, 2007, 04:18 PM
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 (http://www.mycontactform.com/).

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
Jun 15, 2007, 04:51 PM
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
Jun 15, 2007, 08:50 PM
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
Jun 15, 2007, 08:59 PM
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?