SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    calif
    Posts
    743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding "Must Agree To Terms" to Register Form

    How can I add a "Must Agree To Terms" to this Register Form so, that they must check that they read the Terms (from a linked page) in order to Submit?

    Here is the basic Registration Form code:

    Code:
    <form action='form_handle.php' method='post'>
    <table border='0' padding='0' spacing='0' >
    <tr>
    <td>Company Name:</td>
    <td><input type='text' size='35' name='company_name'></td>
    </tr>
    
    <tr>
    <td>Address:</td>
    <td><input type='text' size='20' name='address'></td>
    </tr>
    
    <tr>
    <td>City:</td>
    <td><input type='text' size='20' name='city'></td>
    </tr>
    <tr>
    <td>State:</td>
    <td><input type='text' size='4' name='ztate'></td>
    </tr>
    
    <tr>
    <td>Zip:</td>
    <td><input type='text' size='9' name='zip'></td>
    </tr>
    
    <tr>
    <td>Contact Name:</td>
    <td><input type='text' size='20' name='contact_name'></td>
    </tr>
    
    <tr>
    <td>Phone Number:</td>
    <td><input type='text' size='15' name='phone_number'></td>
    </tr>
    <tr>
    <td>Email Address:</td>
    <td><input type='text' size='15' name='email_address'></td>
    </tr>
    
    <tr>
    <td>Description:</td>
    <td><textarea name='Description' rows='10' cols='80'></textarea></td>
    </tr>
    
    <tr>
    <td colspan='2' align='right'><input type='submit' value = 'Register'></td>
    </tr>
    
    </table>
    </form>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XHTML code
    Code:
    <input type="checkbox" name="agree" id="agree" value="agree" /> <label for='agree'>Do you agree to the terms?</label>
    Javascript validation:
    Code:
    function validate()
    {
    if(false == document.getElementById("agree").checked)
    {
    alert("If you agree with the terms, check the Agree check box");
    }
    }
    Serverside (PHP):
    Code:
    if(empty($_POST['agree']) || $_POST['agree'] != 'agree')
    {
    echo "If you agree with the terms, check the Agree check box";
    exit;
    }


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
  •