Web Url validation

There is a small error in the code | I’ll fix it soon. If you know it, let me know as well

<?php //php protion ?>


// Firstly I have defined the variables here and set them to empty values
$websiteErr = ""; 

     $web = $_post["site"];

    if (!preg_match("/b(?:(?:https?|ftp)://|www.)[-a-z0-9+&@#/%?=~_|!:,.;]*[-a-z0-9+&@#/%=~_|]/i",$web)) {
      $websiteErr = "Invalid URL";



<?php //html portion ?>

<html lang="en">
<meta charset="UTF-8">
<title>Simple html form by TALHA SHOAIB</title>

<h3>Web Url validation | code avaialble at <a href="https://techkwave.blogspot.com/">Tech wave</a></h3>

        <form action="" method="post">
            <label>Website Url:</label>
            <input type="text" name="site">
            <span style="color: red;">*<?php echo $websiteErr; ?></span>
            <input type="submit" name="btn" value="Button">

Share it in your network:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.



You have successfully subscribed to my email list. Now you will be recieving latest wordpress tips and tricks directly in your mail box.

Don’t worry! I won’t spam you