Results 1 to 5 of 5

Thread: Contact From Validation Help

  1. #1
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Contact From Validation Help

    Hello, I have a contact form here... http://livingfortodayband.co.uk/basement2/contact.php

    This is just a simple form with no validation or spam protection. It just works. I have chosen to start simple and work up as I am no expert in php, I don't know a lot to be fair...

    My next step is validation of the form fields but honestly I don't know where to start. I have followed a few tutorials and they have not worked so I was wondering if there is someone who would be willing to assist me in working this code out.

    The style I am going for is like this... http://junglejap.com/FormTest/

    I have found this page but I am not sure how to implement the code into my page... http://bassistance.de/jquery-plugins...in-validation/

    here is the form on the php page I am working in html:
    HTML Code:
    <form method="post" action="contact.php" id="contactform">
                <ol>
                  <li>
                    <label for="name">First Name <span class="required">*</span></label>
                    <input id="name" name="name" class="text">
                  </li>
                  <li>
                    <label for="email">Your email <span class="required">*</span></label>
                    <input id="email" name="email" class="text" />
                  </li>
                  <li>
                    <label for="artist">Band/Artist Name</label>
                    <input id="artist" name="artist" class="text">
                  </li>
                  <li>
                    <label for="subject">Subject<span class="required">*</span></label>
                    <input id="subject" name="subject" class="text">
                  </li>
                  <li>
                    <label for="message">Message <span class="required">*</span></label>
                    <textarea id="message" name="message" class="text" rows="6" cols="50"></textarea>
                  </li>
                  <li class="buttons">
                    <input name="imageField" id="imageField" src="images/send.jpg" class="send" type="image">
                    <div class="clr"></div>
                  </li>
              </ol>
          </form>
    I will be so grateful if someone can help me out in this...
    Thanks!

  2. #2
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    The method they are using in this example is javascript - http://junglejap.com/FormTest/ which for a simple contact form would probably be ok cause you aren't submitting anything to a database that truly needs to be validated for sql injection and other malicious things. The jquery example is cooler but still a version of javascript cause the fields are still only validated on client side and not fully on server side once it's finally submitted.

    I reality the best and friendliest way is to use javascript to try to enforce the form being filled out right, but if the person turns off javascript in their browser it won't tell them anything which is why you always need to validate on server side using php once the form has been fully submitted

  3. #3
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ok ... where do I start? I really don't even know where to look :/

  4. #4
    Join Date
    Sep 2010
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Contact form javascript validation

    Hello, I have a contact form here... http://livingfortodayband.co.uk/basement2/contact.php

    This is just a simple form with no validation or spam protection. It just works. I have chosen to start simple and work up as I am no expert in php, I don't know a lot to be fair...

    My next step is validation of the form fields but honestly I don't know where to start. I have followed a few tutorials and they have not worked so I was wondering if there is someone who would be willing to assist me in working this code out.

    The style I am going for is like this... http://junglejap.com/FormTest/

    I have found this page but I am not sure how to implement the code into my page... http://bassistance.de/jquery-plugins...in-validation/

    I have been told the styles above are done or can be done via javascript so i thought i'd request some specialist help as I have no idea in this field unfortunately.

    This is the php code above everything in the contact.php page:

    PHP Code:
    <?php

    /* Subject and Email Variables */

        
    $emailSubject 'Basement Studio Web Enquiry';
        
    $webMaster 'lukecottingham@hotmail.co.uk';
        
    /* Gathering Data Variables */

        
    $name $_POST['name'];
        
    $email $_POST['email'];
        
    $artist $_POST['artist'];
        
    $subject $_POST['subject'];
        
    $message $_POST['message'];
        
        
    $body = <<<EOD
    <br><hr><br>
    Name: 
    $name<br>
    Email: 
    $email<br>
    Artist: 
    $artist<br>
    Subject: 
    $subject<br>
    Message: 
    $message<br>
    EOD;

        
    $headers "From: $email\r\n";
        
    $headers .= "Content-type: text/html\r\n";
        
    $seccess mail($webMaster$emailSubject$body$headers);
        

        
    ?>
    Below is the form on the website:
    HTML Code:
    <form method="post" action="contact.php" id="contactform">
                <ol>
                  <li>
                    <label for="name">First Name <span class="required">*</span></label>
                    <input id="name" name="name" class="text">
                  </li>
                  <li>
                    <label for="email">Your email <span class="required">*</span></label>
                    <input id="email" name="email" class="text" />
                  </li>
                  <li>
                    <label for="artist">Band/Artist Name</label>
                    <input id="artist" name="artist" class="text">
                  </li>
                  <li>
                    <label for="subject">Subject<span class="required">*</span></label>
                    <input id="subject" name="subject" class="text">
                  </li>
                  <li>
                    <label for="message">Message <span class="required">*</span></label>
                    <textarea id="message" name="message" class="text" rows="6" cols="50"></textarea>
                  </li>
                  <li class="buttons">
                    <input name="imageField" id="imageField" src="images/send.jpg" class="send" type="image">
                    <div class="clr"></div>
                  </li>
              </ol>
          </form>
    I will be so grateful if someone can help me out in this...
    Thanks!

  5. #5
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    I've used this in the past and found it quite easy to use: http://livevalidation.com/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

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