Hello.

I have a database with a "contact" field which is either an email address or a weblink.

I have a php page which displays the data from contact, but I don't know how to differentiate whether to have the <A href="http://$contact_value"> link or the <A href ="mailto:$contact_value">

RIght now it is hardcoded for mailto as 99% of the entries are email, but there are a few websites listed for the contact for the balance.

    You can use PHP Filter
    and let filter_var() use EMAIL or URL filter

    Validation Filters:
    http://www.php.net/manual/en/filter.filters.validate.php
    - FILTER_VALIDATE_EMAIL
    - FILTER_VALIDATE_URL

    Here is the [man]filter_var[/man] function and some examples:
    http://www.php.net/manual/en/filter.examples.validation.php

    Like

    <?php
    
    $email_a = 'joe@example.com';
    $email_b = 'bogus';
    
    if (filter_var($email_a, FILTER_VALIDATE_EMAIL)) {
        echo "This (email_a) email address is considered valid.";
    }
    if (filter_var($email_b, FILTER_VALIDATE_EMAIL)) {
        echo "This (email_b) email address is considered valid.";
    }
    
    ?>
      Write a Reply...