Results 1 to 8 of 8

Thread: Free Mod

  1. #1
    Join Date
    Nov 2004
    Posts
    1,822

    Default Free Mod

    Hi, this is a rough guide to adding AJAX field validation.

    firstly, a new file, uploaded to the main indexU folder, copy this, and save it as "post_url.php"
    Code:
    <?
    include ("application.php");
    $url = $_REQUEST["url"];
    $query = " SELECT url
    FROM idx_link
    WHERE url = '$url'
    LIMIT 0 , 30 ";
    $result = $dbConn->FetchArray($query);
    $num = count($result);
    
    if($num > 0){
    //uurl already exists
    echo "Sorry your site is already Added.";
    }else{
    echo "Thanks, the URL seems fine!";
    }
    ?>
    Load up add form.

    at the top add this :
    Code:
    <script type="text/javascript">
    var http = false;
    
    if(navigator.appName == "Microsoft Internet Explorer") {
      http = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
      http = new XMLHttpRequest();
    }
    
    function validate2(url) {
      http.abort();
      http.open("GET", "post_url.php?url=" + url, true);
      http.onreadystatechange=function() {
        if(http.readyState == 4) {
          document.getElementById('message').innerHTML = http.responseText;
        }
      }
      http.send(null);
    }
    </script>
    almost done, just change this on the add_form.html :

    Code:
    <input type="text" size="40" name="url" value="<%$url%>" onBlur="validate2(this.value)" class="textbg">
    		  <div id="message"></div>
    Try it out!! to make it really cool, instead of the message load a little green tick or red cross image, use this template to validate phone numbers, usernames - allsorts of thigns on the form before its even submitted

    Im using it ont he admin panel when i add sites - i can see straight away if its a duplicate.
    Last edited by inspireme; 05-08-2008 at 05:11 AM.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  2. #2
    Join Date
    Oct 2007
    Location
    UK Essex
    Posts
    591

    Default

    could you post a print screen? plese

  3. #3
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Quote Originally Posted by echo@ View Post
    could you post a print screen? plese
    why? really isn't anything to see... ? its jsut a usability improvement - warns people if the site wont be accepted before they fill in the rest. Im using it to check sites im adding myself arent already listed...
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  4. #4
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Hmm, well it seems im very bad at explaining myself, people are confused. SO...

    try this :

    http://www.theleisureguide.co.uk/add.php

    go to the "url" bit

    type in a url and defocus theurl box (click somewhere else) it should say its okay to add the site.

    Now type in :
    http://www.activityuk.com/

    It should say its a duplicate....

    Hope it makes more sense now.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  5. #5
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    you can also try the postcode, type anything random in and it will say "thats fine" and then type this : BN9 9DS

    And it will tell you its already added.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

  6. #6
    Join Date
    Feb 2008
    Posts
    20

    Default

    But if you sail in without "/" , then he does not see as twice.

    Thus, with a sign less or more, then have no impact.

    I have added exactly these, therefore without "/" on end.
    He accepts directly http://www.activityuk.com

  7. #7
    Join Date
    Feb 2008
    Posts
    20

    Default

    I have activated these on my site.

    He gives report: Your site is already in our database.

    But to add continues simply. It is therefore nothing else then a report or this way?

  8. #8
    Join Date
    Nov 2004
    Posts
    1,822

    Default

    Yes... its to tell people not to add sites again... but as i said int he first post this is a method to do things, you can write whatever php code you want to validate the field. In the example i gave before you could change the sql query to say LIKE $url% and then it would warn about any page within the domain... Im nto saying this is a workign example. just useful code to help peopel with feedback and messages as they fill in the form.
    Main IndexU sites : | Campsite Directory | Tourist Guide | Places2B | AfterDirectory <-- Half price submission using coupon DP50 (from just $11 premium, and $10 basic permanent )

Similar Threads

  1. free templates
    By stephborel in forum Templates
    Replies: 3
    Last Post: 11-30-2007, 12:21 PM
  2. Free Version
    By banless in forum Indexu Lite
    Replies: 2
    Last Post: 05-19-2007, 07:20 PM
  3. Free homepages
    By Hart_House in forum v5.x
    Replies: 2
    Last Post: 04-04-2002, 07:28 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
  •