FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need a simple Contact form





jayzee
i need a simple contact form ( in php with mysql)..?
simplyw00x
Try here - really good site. Easy to use too.
Ducksteina
You could also check http://www.hotscripts.com - there are MANY scripts...
bladesage
jayzee wrote:
i need a simple contact form ( in php with mysql)..?


Here,
Code:
<?php

$to = "you@yoursite.com"; //Change to your e-mail address
$subject = "Feedback"; //Change to the subject of the emails you will get

if(isset($_POST['message']))
 {
 $msg = $_POST['message'];
 $email = $_POST['email'];
 $name = $_POST['name'];
 mail($to, $subject, $msg);
 }

$thisdoc = $_SERVER['PHP_SELF'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Conyacy form</title>
</head>

<body>

<?php

if(!isset($_POST['message']))
 {
 print "<form action=\"$thisdoc\" method=\"post\">\n\n";
 print "Your name:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"name\"><br /><br />";
 print "Your e-mail address:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"email\"><br /><br />";
 print "Your message:<br />\n";
 print "<textarea name=\"message\" cols=\"60\" rows=\"4\">";
 print "</textarea><br /><br />";
 print "<input type=\"submit\" value=\"Send!\">";
 }

else if(isset($_POST['message']))
 {
 print "Thank you for your input!<br /><br />";
 print "Your message will be recieved shortly";
 }

?>

</body>
</html>


Save this as whatever.php, and edit the variables as instructed by the comments ('//').

If there are any problems, let me know, and I'll fix it up for you. I did whip this one up in a hurry, so problems shouldn't come as a surprise.
jayzee
bladesage wrote:
jayzee wrote:
i need a simple contact form ( in php with mysql)..?


Here,
Code:
<?php

$to = "you@yoursite.com"; //Change to your e-mail address
$subject = "Feedback"; //Change to the subject of the emails you will get

if(isset($_POST['message']))
 {
 $msg = $_POST['message'];
 $email = $_POST['email'];
 $name = $_POST['name'];
 mail($to, $subject, $msg);
 }

$thisdoc = $_SERVER['PHP_SELF'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Conyacy form</title>
</head>

<body>

<?php

if(!isset($_POST['message']))
 {
 print "<form action=\"$thisdoc\" method=\"post\">\n\n";
 print "Your name:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"name\"><br /><br />";
 print "Your e-mail address:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"email\"><br /><br />";
 print "Your message:<br />\n";
 print "<textarea name=\"message\" cols=\"60\" rows=\"4\">";
 print "</textarea><br /><br />";
 print "<input type=\"submit\" value=\"Send!\">";
 }

else if(isset($_POST['message']))
 {
 print "Thank you for your input!<br /><br />";
 print "Your message will be recieved shortly";
 }

?>

</body>
</html>


Save this as whatever.php, and edit the variables as instructed by the comments ('//').

If there are any problems, let me know, and I'll fix it up for you. I did whip this one up in a hurry, so problems shouldn't come as a surprise.


thanx a millions my friend it worked perfect..
and thanx to every1 else 2..Smile
bladesage
jayzee wrote:
bladesage wrote:
jayzee wrote:
i need a simple contact form ( in php with mysql)..?


Here,
Code:
<?php

$to = "you@yoursite.com"; //Change to your e-mail address
$subject = "Feedback"; //Change to the subject of the emails you will get

if(isset($_POST['message']))
 {
 $msg = $_POST['message'];
 $email = $_POST['email'];
 $name = $_POST['name'];
 mail($to, $subject, $msg);
 }

$thisdoc = $_SERVER['PHP_SELF'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Conyacy form</title>
</head>

<body>

<?php

if(!isset($_POST['message']))
 {
 print "<form action=\"$thisdoc\" method=\"post\">\n\n";
 print "Your name:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"name\"><br /><br />";
 print "Your e-mail address:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"email\"><br /><br />";
 print "Your message:<br />\n";
 print "<textarea name=\"message\" cols=\"60\" rows=\"4\">";
 print "</textarea><br /><br />";
 print "<input type=\"submit\" value=\"Send!\">";
 }

else if(isset($_POST['message']))
 {
 print "Thank you for your input!<br /><br />";
 print "Your message will be recieved shortly";
 }

?>

</body>
</html>


Save this as whatever.php, and edit the variables as instructed by the comments ('//').

If there are any problems, let me know, and I'll fix it up for you. I did whip this one up in a hurry, so problems shouldn't come as a surprise.


thanx a millions my friend it worked perfect..
and thanx to every1 else 2..Smile


You're very welcome ^_^
m0u53m4t
I read through it, and its correct to the point that if you enter a message it prints:
Quote:
Thank you for your input!

Your message will be recieved shortly


But it doesn't actually send the mail..
bladesage
m0u53m4t wrote:
I read through it, and its correct to the point that if you enter a message it prints:
Quote:
Thank you for your input!

Your message will be recieved shortly


But it doesn't actually send the mail..


Take a closer look.
Code:
if(isset($_POST['message']))
 {
 $msg = $_POST['message'];
 $email = $_POST['email'];
 $name = $_POST['name'];
 mail($to, $subject, $msg);
 }


Right there, I clearly used the mail() function almost at the beginning of the script.
harry4265
Thanks jayzee,
thats exactly what i needed, thanks to everyoen else for giving the help too, you helped me out too
bladesage
Okay everybody, hold up!

I see exactly what you meant, it only mails the message itself. I'll fix that.

Here's my revised code
Code:
<?php

$to = "you@yoursite.com"; //Change to your e-mail address
$subject = "Feedback"; //Change to the subject of the emails you will get

if(isset($_POST['message']))
 {
 $email = $_POST['email'];
 $name = $_POST['name'];
 $msg = "This is a response from one of your visitors.\n\n";
 $msg .= "Email:\n$email\n\nName:\n$name\n\n";
 $message = $_POST['message'];
 $msg .= "Message:\n$message";
 mail($to, $subject, $msg);
 }

$thisdoc = $_SERVER['PHP_SELF'];

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Conyacy form</title>
</head>

<body>

<?php

if(!isset($_POST['message']))
 {
 print "<form action=\"$thisdoc\" method=\"post\">\n\n";
 print "Your name:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"name\"><br /><br />";
 print "Your e-mail address:<br />\n";
 print "<input type=\"text\" size=\"60\" name=\"email\"><br /><br />";
 print "Your message:<br />\n";
 print "<textarea name=\"message\" cols=\"60\" rows=\"4\">";
 print "</textarea><br /><br />";
 print "<input type=\"submit\" value=\"Send!\">";
 }

else if(isset($_POST['message']))
 {
 print "Thank you for your input!<br /><br />";
 print "Your message will be recieved shortly";
 }

?>

</body>
</html>


Sorry everyone!
LostOverThere
Nice, thanks a ton!
Related topics
contact form
For those who need a contact form
I am trying to build a contact form using php and flash
contact form with IP feature ?
Email form script - 50 FRIH$
AJAX and PHP contact form
Contact Form prob
Need a Contact form from HTML/PHP
Need help to make my Flash contact form functioning!
Easy Contact Form with Instructions
Spam protection for contact form?
Contact form or email address?
Help with PHP contact form
Contact Form Issues
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.