i need a simple contact form ( in php with mysql)..?
Need a simple Contact form
Try here - really good site. Easy to use too.
You could also check http://www.hotscripts.com - there are MANY scripts...
| 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.
| bladesage wrote: | ||||
Here,
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..
| jayzee wrote: | ||||||
thanx a millions my friend it worked perfect.. and thanx to every1 else 2.. |
You're very welcome ^_^
I read through it, and its correct to the point that if you enter a message it prints:
But it doesn't actually send the mail..
| Quote: |
| Thank you for your input!
Your message will be recieved shortly |
But it doesn't actually send the mail..
| m0u53m4t wrote: | ||
I read through it, and its correct to the point that if you enter a message it prints:
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.
Thanks jayzee,
thats exactly what i needed, thanks to everyoen else for giving the help too, you helped me out too
thats exactly what i needed, thanks to everyoen else for giving the help too, you helped me out too
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
Sorry everyone!
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!
Nice, thanks a ton!
Related topics
