PDA

View Full Version : Simple contact form.


Creative Insanity
02-12-2006, 01:47 AM
Just incase anyone wants a simple contact for here ya go:

<?php

//variables (change)

$youremail = "name@domain.com";
// your email address

$subject = "Contact";
// the subject of the email

$thankyou = "thankyou.php";
// thank you page

// leave below alone and do not change!

if($email == ""){
?>
No email address added. Please go back.

<?php
}elseif($name == ""){
?>
No name added. Please go back.

<?php
}elseif($message == ""){
?>
No message added. Please go back.

<?php
}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
<?php
}
?>
Now save this as what every you want.. for this post I will call it contact.php

Now the form you add to your html document where you want it.

<form action="contact.php" method="post">
Name <input type="text" name="name">

Email addess <input type="text" name="email">

Message

<textarea name="message" cols="40" rows="5"></textarea>

<input type="submit" value="send">

</form>

davidj
02-13-2006, 08:50 AM
CI

Please create a script forum outside of this topic where you can point people to
then you can make sticky scripts in that forum. Saves clogging up this topic with sticky's

dsmalls
03-07-2006, 01:16 AM
Creative Insanity,
This is a great, simple script. Thanks.
I use apache as my server and I was wondering if you had any links on how to configure Apache to work with php.

LeoNeo
03-09-2006, 04:11 PM
Just incase anyone wants a simple contact for here ya go:

<?php

//variables (change)

$youremail = "name@domain.com";
// your email address

$subject = "Contact";
// the subject of the email

$thankyou = "thankyou.php";
// thank you page

// leave below alone and do not change!

if($email == ""){
?>
No email address added. Please go back.

<?php
}elseif($name == ""){
?>
No name added. Please go back.

<?php
}elseif($message == ""){
?>
No message added. Please go back.

<?php
}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
<?php
}
?>
Now save this as what every you want.. for this post I will call it contact.php

Now the form you add to your html document where you want it.

<form action="contact.php" method="post">
Name <input type="text" name="name">

Email addess <input type="text" name="email">

Message

<textarea name="message" cols="40" rows="5"></textarea>

<input type="submit" value="send">

</form>

CI

What version of php is that.

I've got a site with fasthosts for a deaf charity and FH prefer php 5 or above.

davidj
03-09-2006, 04:15 PM
PHP 5.x is the latest version

LeoNeo
03-09-2006, 04:40 PM
Thanks

Creative Insanity
03-09-2006, 07:49 PM
The script will work with php4.x and above. I use 4 on my development server.

LeoNeo
03-09-2006, 08:01 PM
If you check my post that is under this one you'll know why i asked.:)

Fasthosts my hosting company does not support php4 :wink:

Creative Insanity
03-09-2006, 08:23 PM
If it has php5 then it supports php4 as each version is just an enhancement of the previous and just new stuff added and no old stuff is removed.

LeoNeo
03-09-2006, 09:04 PM
Ok CI

I'll try and see what happens.

Is it possible you could view my other post and let me know what to do as i get quite confused sometimes.

:cry:

LeoNeo
03-09-2006, 09:35 PM
CI

I just sorted it out, it feels so good when you get something right.

Thanks for all the info you give on this site it reallys helps.

:D ..... :D ..... :D ..... :D ..... :D