Results 1 to 2 of 2

Thread: Contact form

  1. #1
    Join Date
    May 2009
    Posts
    4

    Contact form

    Hi all,
    I develop my site and I would like to add a contact form.

    Something like that :
    Code:
    <form method="POST" action="mailto:a@yahoo.com?" name="form1" id="form1" onsubmit="return validateFormOnSubmit(this);">
    fullname : <input value="" size="45" id="name" name="name" type="text">
    Email :	   <input value="" size="45" id="email" name="email" type="text">
    subject	   <input value="" size="45" id="sub" name="sub" type="text">
    MEssage : <textarea rows="4" cols="45" id="notes" name="notes">
             </textarea>
    <input value="ok" id="1" name="1" type="submit">
    </form>
    An user types all the fields and I would like to see all the information in my e-mail a@yahoo.com.

    Any help ??


    Thanks

  2. #2
    Join Date
    Feb 2007
    Location
    Ireland
    Posts
    1,007
    Quote Originally Posted by katerina View Post
    Hi all,
    I develop my site and I would like to add a contact form.

    Something like that :
    Code:
    <form method="POST" action="mailto:a@yahoo.com?" name="form1" id="form1" onsubmit="return validateFormOnSubmit(this);">
    fullname : <input value="" size="45" id="name" name="name" type="text">
    Email :	   <input value="" size="45" id="email" name="email" type="text">
    subject	   <input value="" size="45" id="sub" name="sub" type="text">
    MEssage : <textarea rows="4" cols="45" id="notes" name="notes">
             </textarea>
    <input value="ok" id="1" name="1" type="submit">
    </form>
    An user types all the fields and I would like to see all the information in my e-mail a@yahoo.com.

    Any help ??


    Thanks
    Just a few notes:

    Your validation can be bypassed if Javascript has been turned off. Javascript is generally only used to save time and provide a more pleasent user experience.

    Your action must be targeting a script that will process the form's post variables. (method="post"). Such as contact_form.php.

    The contact_form.php will access PHP's POST array (it's where post variables are stored) and deal with them in whatever way you want. A basic contact form would go like this:

    PHP Code:
    <?php
       
    if(isset($_POST['name']) && !empty($_POST['name']))
       {
          
    $name $_POST['name'];
          (isset(
    $_POST['email']) && !empty($_POST['email']) ? $email $_POST['email'] : $email '';
          (isset(
    $_POST['sub']) && !empty($_POST['sub']) ? $sub $_POST['sub'] : $sub '';
          (isset(
    $_POST['notes']) && !empty($_POST['notes']) ? $notes $_POST['notes'] : $notes '';

          if(!empty(
    $name) && !empty($email) && !empty($sub) && !empty($notes))
          {
             
    $headers ''// Insert your headers here
             
    if(mail('a@yahoo.com',$sub,$notes,$headers))
                echo 
    "Message sent successfully.";
             else
                echo 
    "Message failed. Contact an administrator.";
          }
          else
             echo 
    "You did not enter all the required information.";
       }
    ?>
    Simple as that. Bear in mind that there is no validation on this script, and it is very insecure. But you'll figure it out.
    “The best thing about a boolean is even if you are wrong, you are only off by a bit.”

Similar Threads

  1. Creating Required Fields for a Contact Form
    By Bonanza84 in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 02 Apr 2009, 11:03 AM
  2. A Free Contact Form
    By Panospheric in forum The Lounge
    Replies: 0
    Last Post: 06 May 2007, 07:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •