PDA

View Full Version : PHP Help needed



SWestwood
30 Mar 2011, 05:34 PM
Hi Guys,

I need to make a page of a website with a form and then the form details emailed to someone.

I believe that there is no way to do this via CSS & HTML alone, is this correct?

I do not know php at all, although I have given this a bash via a coding book I have, but it does not seem to work.

Can someone tell me what I have done wrong or help me in any way as I am starting to get frustrated?

Cheers

Sarah

Code:-

<?php
if (array_key_exists('Notify', $_POST)) {
$to = 'notify@got-the-concept.co.uk';
$subject = 'Notify when Live';
$expected = array('Name', 'Email Address');
$required = array('Name', 'Email Address');
$headers = 'From: My website<notify@got-the-concept.co.uk>';
$process = 'process_mail.inc.php';
if (file_exists($process) && is_readable($process)) {
include($process);
}
else {
$mailSent = false;
mail($to, 'Server Problem', "$process cannot be read", $headers);
}
}
?>
<?php
if ($POST && isset($missing) && (!empty($missing)) {
?>
<p class="warning"> Not all required fields were filled in. </p>
<?php
}else if ($POST && !$mailSent) {
?>
<p class="warning">Sorry, there was a problem sending your message. Please try later. </p>
<?php
}
elseif ($POST && $mailSent) {
?>
<p> <strong>Your message has been sent. Thank you for your feedback. </strong> </p>
<?php } ?>
<form action="<?php echo $_SERVER['PHP SELF']; ?>" method="post">
<input type="hidden" name="subject" value="notify me from site" />
<input type="hidden" name="redirect" value="http://www.got-the-concept.co.uk/notify2.html" />
<p> <strong> Name </strong> </p> <br /> <input type="text" name="Name" size="30" />
<p> <strong> Email Address </strong> </p> <br /> <input type="text" name="Email Address" size="30" />
<p> <input type="button" name="Notify" value="Notify" /> </p>
</form>

Alan
31 Mar 2011, 08:48 AM
Issue has been solved off site.