1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP Process for my Contact form

Discussion in 'Web Development' started by xRazz, Apr 14, 2014.

  1. xRazz

    xRazz New Member

    Hello guys I need a contact.php for this coz when i bought a Website template....theres no process that will send the things heres the form:


    <br /><br />
    HTML:
    <form id="ajax-contact-form" action="#">
         
          <div class="form-box">
            <label>Name <small>(required)</small></label>
            <input type="text" name="name" class="text">
          </div><!-- End Box -->
         
          <div class="form-box">
            <label>Email <small>(required)</small></label>
            <input type="text" name="email" class="text">
          </div><!-- End Box -->
         
          <div class="form-box last">
            <label>Subject </label>
            <input type="text" name="subject" class="text">
          </div><!-- End Box -->
         
          <div class="form-box big">
            <label>Message <small>(required)</small> </label>
            <textarea name="message"></textarea>
          </div><!-- End Box -->
         
          <div class="clearfix"></div>
         
          <input type="submit" name="submit" value="Send Message" class="button medium color" />
         
          </form>



    Please help......u can pm me at scorpzon981@gmail.com

    xRazz
     
  2. Yen

    Yen Programmer Verified Member

    Hi xRazz,

    Assuming you already have your website domain set up with a hosting provider or some server hosting that provides PHP backend processing, the simplest way to do up your contact.php is:

    PHP:
    <?php
    /* Obtain the form variable values */
    $name $_POST['name'];
    $email $_POST['email'];
    $subject $_POST['subject'];
    $message $_POST['message'];

    /*
    * Form a ~~~ delimited record from your data
    */
    $data "$name~~~$email~~~$subject~~~$message";

    /*
    * Store the (text) record into a file
    */
    $fp fopen("records.dat""a+"); // Create/Open a file for appending data to it
    fwrite($fp"$data\n");
    fclose($fp);
    This is the simplest form. There's no consideration for security, no validation done on your data
    and no checks for duplicates etc.

    If you want to store the data in a database (e.g. MySQL DB), you really need to check out some tutorials on the web (or from youtube) on how to do this. There are loads of such tutorials.

    Regards,

    Yen