logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 12-28-2011, 05:47 PM   #1
eason1
 
Join Date: Dec 2011
Posts: 2
Default PHP e mail form

I have been trying to create a simple e mail contact form in CS3 using a form I created in html which then should run a php form. However, when I preview the form and click on submit it tries to open the php file instead of running it. I get a pop up box asking whether I want to save it or open the php file. I am, thinking I have made a simple ommision or error.

Can anyone help. The php code is underneath this message.

Thanks

<?php # fourm.php


// Check if the form has been submitted:
if (isset($_POST['submitted'])) {
$errors = array(); // Initialize an error array.

// Check for a first name:
if (empty($_POST['first_name'])) {
$errors[] = 'You forgot to enter your first name.';
}

// Check for a last name:
if (empty($_POST['last_name'])) {
$errors[] = 'You forgot to enter your last name.';
}

// Check for an email address:
if (empty($_POST['email address'])) {
$errors[] = 'You forgot to enter your email address.';
}
// Check for an Telephone Number:
if (empty($_POST['Telephone Number'])) {
$errors[] = 'You forgot to enter your email address.';
}
// Check for comments:
if (empty($_POST['Comments'])) {
$errors[] = 'You forgot to leave any feedback.';
}

if (empty($errors)) { // If everything's OK.

/* Gathering Data Variables */
$firstname = $_POST['first_name'];
$lastname = $_POST['last_name'];
$email = $_POST['email'];
$Telephone Number = $_POST['Telephone Number'];
$Comments= $_POST['Comments'];


// Print a message:
echo "<h1>Thank you!</h1>
<p>Thank you for your ticket request</p>";

//Send Email:


/* Subject and Email Variables */
$sendToAddress = "season@all-saints.bardaglea.org.uk";
$emailSubject = "Feedback From Website";

$body = "Someone has submitted feedback on your website.\n\nFirst Name: $firstname\nLast Name: $lastname\nEmail: $email\nFeedback: $feedback";

$body = wordwrap($body, 70);


$headers = "From: $firstname $lastname <$email>\r\n";


$success = mail($sendToAddress, $emailSubject, $body, $headers);










exit();

} else { // Report the errors.

echo '<h1>Error!</h1>
<p class="error">The following error(s) occurred:<br />';
foreach ($errors as $msg) { // Print each error.
echo " - $msg<br />\n";
}
echo '</p><p>Please try again.</p><p><br /></p>';

} // End of if (empty($errors)) IF.

} // End of the main Submit conditional.
?>

<form name="contactform" method="post" action="SSform.php">
<table width="450px">
<tr>
<td valign="top">
<label for="first_name">First Name *</label>
</td>
<td valign="top">
<input type="text" name="first_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top"">
<label for="last_name">Last Name *</label>
</td>
<td valign="top">
<input type="text" name="last_name" maxlength="50" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="email">Email Address *</label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="telephone">Telephone Number</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="30" size="30">
</td>
</tr>
<tr>
<td valign="top">
<label for="comments">Comments *</label>
</td>
<td valign="top">
<textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit"></td>
</tr>
</table>
</form>
eason1 is offline   Reply With Quote
Old 12-29-2011, 12:27 AM   #2
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

your server(all-saints.bardaglea.org.uk) shows
server: Microsoft-IIS/7.0
x-powered-by: ASP.NET
it is not enabled for php
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 12-29-2011, 10:17 AM   #3
eason1
 
Join Date: Dec 2011
Posts: 2
Default php

Many thanks.
So if I find a host that's pho enabled this may solve the problem?
Thanks again.
eason1 is offline   Reply With Quote
Old 12-29-2011, 12:43 PM   #4
domedia
Administrator
domedia's Avatar
 
Join Date: Dec 2003
Posts: 9,730
Default

Yes, or use a server side technology that is supported by your current host.
domedia is offline   Reply With Quote
Old 12-30-2011, 10:02 PM   #5
edbr
edbr's Avatar
 
Join Date: Aug 2005
Location: Bali
Posts: 11,164
Default

you could google for ASP form to mail , try hotscripts or use a perl script. Normally your host will have one on the server
__________________
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:26 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com