I need to make a contact form on a website that will send comments to an email. I have designed the html file but i'm not sure where to beggin with adding the file or code that will support this function. So far i have learnt that it can be done by php file or some code on the web page, but i'm not quiet certain yet on how to do it. Any clear tutorials will be appreciated or just some guideline

This is my html form

<form action="#" method="post">
          <div class="form_settings">
            <p><span>Name</span><input class="contact" type="text" name="your_name" value="" /></p>
            <p><span>Email Address</span><input class="contact" type="text" name="your_email" value="" /></p>
            <p><span>Message</span><textarea class="contact textarea" rows="8" cols="50" name="your_enquiry"></textarea></p>
            <p style="padding-top: 15px"><span>&nbsp;</span><input class="submit" type="submit" name="contact_submitted" value="submit" /></p>

Recommended Answers

All 3 Replies

The server side scripting language you ultmiately choose will depend on what you are comfortable working with AND what your web server is configured to run. For example, if you code in PHP or ASP.NET, your web server needs to have the appropriate server side code to be able to intrepret the scripting language.

PHP is a bit more flexible in terms of implementation (runs on Windows, Linux...various web server platforms IIS, Apache), where ASP.NET runs on Windows IIS.

One platform is not necessarily better than the other. Each has its advantages and disadvatages. You can start at these web sites to get a better feel for each.




If you want to use PHP, you can find useful tutorials if you search on the net for "php tutortial contact form".
Or check this page: PHP Sending E-mails

Hope this helps you bud, it is the php version of your form stripped down, and with a little bit of whats going on


// Create an array to get the data from the form
  $arr = array("email", "n", "e", "m", "submit");
foreach ($arr as $value) // loop through the array to get your values to work with
    $$value = $_REQUEST[$value] ; // this will create your values for php
$subval = "submit"; // if you change the submit value, change it here too, a basic switch.
    if($submit=="$subval") // checks if the submit button was pressed by checking its value
    echo"The submit button was pressed with a value of $submit";
    if(!$email=="") // this is for spam, if its not empty then stop processing
    die("Sorry, that is not allowed. email:$email");
    if($email=="") // if the spam check is empty, then do something like echo the result to view or insert into mail function

$to = "youremail@domain.com"; // change this to your email
$from = $e; // send it from the person who filled out the form
$subject = "My subject"; // the subject
$txt = $m; // the message

$headers = "From: $from";
mail($to,$subject,$txt,$headers); // mail it to your email, from the other persons email

    echo "Name: $n
    <br />
    Email: $e
    <br />
    Message: $m
   <br /> Message sent to $to.";

    // the form action below will default to the current page address when empty

<form action="" method="post">
<div style="display:none;">If you can see the following box, don't fill it in.
<input type="text" name="email" value="" /></div>

Name<input type="text" name="n" value="" />
<br />
Email Address<input type="text" name="e" value="" />
<br />
Message<textarea rows="8" cols="50" name="m"></textarea>
<br />
<input type="submit" name="submit" value="submit" />

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.