Click to See Complete Forum and Search --> : problem with contact form script.


roondog
07-01-2007, 02:13 PM
I have a from that can be seen here (http://www.roondogid.co.uk/test/claudia)
and use the following php code:


<?php
if(isset($_POST['submit'])){

if($_POST['contact'] = 'fans'){

$to = 'roondog@roondogid.co.uk';
$subject = 'Claudia Romani Fans';
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo 'Thanks for contacting Claudia Romani your support is appreciated. Back to <a href="./index.html">Home</a>';

}else{

if($_POST['contact'] = 'modelling'){

$to = 'mark@roondogid.co.uk';
$subject = 'Claudia Romani Fans';
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo 'Thanks for contacting Claudia Romani your support is appreciated. Back to <a href="./index.html">Home</a>';
}
}

}
?>


I'm getting the message to display but the e-mail isn't sent. Any ideas?

metrostars
07-01-2007, 02:19 PM
where's you mail() command?

roondog
07-01-2007, 02:22 PM
i use the same script on another site but without the differing e-mail addresses.
whoops just checked again. you are right i am stoopid.
Thanks

MrCoder
07-01-2007, 02:33 PM
Its always the little things that catch us all out :)

roondog
07-01-2007, 02:34 PM
I've got it to send e-mails now but it won't change the address it sends to

MrCoder
07-01-2007, 02:43 PM
Paste the new code?

roondog
07-01-2007, 02:45 PM
<?php
if(isset($_POST['submit'])){

if($_POST['contact'] = 'fans'){

$to = 'roondog@roondogid.co.uk';
$subject = 'Claudia Romani Fans';
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo 'Thanks for contacting Claudia Romani your support is appreciated. Back to <a href="./index.html">Home</a>';
mail($to, $subject, $body);
}else{

if($_POST['contact'] = 'modelling'){

$to = 'mark@roondogid.co.uk';
$subject = 'Claudia Romani Fans';
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];

$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

echo 'Thanks for contacting Claudia Romani your support is appreciated. Back to <a href="./index.html">Home</a>';
mail($to, $subject, $body);
}
}
}
?>

MrCoder
07-01-2007, 02:52 PM
<?php
if(isset($_POST['submit']))
{
$valid = false;

if($_POST['contact'] == 'fans')
{
$to = 'roondog@roondogid.co.uk';
$subject = 'Claudia Romani Fans';
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

$valid = true;
}
elseif($_POST['contact'] == 'modelling')
{
$to = 'mark@roondogid.co.uk';
$subject = 'Claudia Romani Fans';
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

$valid = true;
}

if($valid)
{
echo 'Thanks for contacting Claudia Romani your support is appreciated. Back to <a href="./index.html">Home</a>';
mail($to, $subject, $body);
} else {
echo 'Bad contact';
}
}
?>


Try that.

roondog
07-01-2007, 02:56 PM
perfect thanks. I'm slowly getting the hang of this php thing.

MrCoder
07-01-2007, 03:01 PM
Glad to hear it, and glad I could help :)