Search....

Sunday 21 October 2018

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 ?>

<?php

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

if(isset($_post["btn"])){
     $web = $_post["site"];

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

    }


?>


<?php //html portion ?>

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple html form by TALHA SHOAIB</title>
</head>
<body>

<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>
            <br>
            <input type="submit" name="btn" value="Button">
        </form>
</body>
</html>

No comments:

Post a Comment

Semester project - E commerce site - with source code

Here is the link to get soure code for semester project of ecommerce site. Click me to download