j05hr Posted October 30, 2008 Share Posted October 30, 2008 I need php code for my website to process a form, i want it to be sent to a database and to an email address. I know this is something really simple but when i google it, it just comes up with forms processing it to an email address. Would anyone be able to point me in the right direction? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/ Share on other sites More sharing options...
Maq Posted October 30, 2008 Share Posted October 30, 2008 This is simple but takes some time. Do you have anything done yet? If yes, please post it so we don't waste our time rewriting existing code. Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-678901 Share on other sites More sharing options...
j05hr Posted October 30, 2008 Author Share Posted October 30, 2008 i don't have any code for it, i have the database setup for it but that's it. A guy was helping me on here about a month ago but he got ill and i kind of need it now. The form can be seen at http://www.jasongold.org/contact1.html Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-678907 Share on other sites More sharing options...
kenrbnsn Posted October 30, 2008 Share Posted October 30, 2008 If you want someone to write the code for you please post in the Freelancing area. Ken Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-678910 Share on other sites More sharing options...
j05hr Posted October 30, 2008 Author Share Posted October 30, 2008 i don't want someone to write the code for me, i asked if anyone could point me in the right direction of a tutorial or something and Maq asked if I've got any code already? Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-678912 Share on other sites More sharing options...
Maq Posted October 30, 2008 Share Posted October 30, 2008 I think this is a bigger task than what you think. If you need help with specific parts I'll be glad to help. Some pointers: 1) Submit to itself for error checking. 2) If it validates use the send mail function to send the values of the fields. 3) What kind of DB is it? MySQL I assume, there are plenty of tutorials and threads on how to store this info. Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-678914 Share on other sites More sharing options...
j05hr Posted October 31, 2008 Author Share Posted October 31, 2008 Yeah it's a MySQL DB. Would you be able to point me in the direction of the right sort of tutorials? Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-678918 Share on other sites More sharing options...
Maq Posted October 31, 2008 Share Posted October 31, 2008 I already did. If you want a source for tutorials I would go to either tizag.com or w3schools.com. They are both excellent for finding basic scripts/tutorials with correct standards. Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679402 Share on other sites More sharing options...
j05hr Posted October 31, 2008 Author Share Posted October 31, 2008 I've tried to look around for some codes on it as i'm not going to be able to teach myself how to do it that quickly using w3schools or the like. I found this and instead of trying to make it work for my form i've just copied the one they have and i can't get it to work, can you see a problem with the code as no matter how much i try, i can't get it to work and it says. The requested URL /â€sendform.php†was not found on this server. and i don't understand why this is as senform.php is in my server? dbconnect.php <?php $host= “localhost”; $dbuser =”your database username here”; $dbpass = “your database password here”; $dbname = “your database name here”; $connection = mysql_connect($host, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); ?> sendform.php <?php include ‘dbconnect.php’; $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['article']; $company = $_POST['company']; $mailmsg.= ‘Name: ‘ . $name . “\n”; $mailmsg.= ‘Email: ‘ . $email . “\n”; $mailmsg.= ‘Article: ‘ . $article . “\n”; $mailmsg.= ‘Company: ‘ . $company . “\n”; $query = mysql_query(”INSERT INTO emails (name, company, email, article) VALUES (’$name’,'$email’,'$company’, ‘$article’)”) or die(mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679541 Share on other sites More sharing options...
kenrbnsn Posted October 31, 2008 Share Posted October 31, 2008 Get rid of the weird quotes: ‘ and ’ should be replaced with ' “ and ” should be replaced with " Ken Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679558 Share on other sites More sharing options...
Maq Posted October 31, 2008 Share Posted October 31, 2008 Well if it's on your server and it's not recognizing it, it's probably because you're not in the right directory or you're not calling the correct page. Match the directory with the URL you're using. Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679566 Share on other sites More sharing options...
j05hr Posted October 31, 2008 Author Share Posted October 31, 2008 I'm in the right directory as i've used php before and i changed the quoted but still nothing. Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679580 Share on other sites More sharing options...
kenrbnsn Posted October 31, 2008 Share Posted October 31, 2008 You're doing the query, but not sending any email. Ken Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679581 Share on other sites More sharing options...
j05hr Posted October 31, 2008 Author Share Posted October 31, 2008 But then it shouldn't come up saying the page doesn't exsist when it does? Quote Link to comment https://forums.phpfreaks.com/topic/130803-contact-form/#findComment-679584 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.