Jump to content

contact form


j05hr

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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());

?>

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.