I want a system where the submitted data from my input field has to be a URL and start with 'http://' or 'https://' in PHP. But when I submit the form it keeps alerting 'Invalid Link' can it be fixed?
<?php
if(isset($_POST['Title'])){
$Title=$_POST['Title'];
}if(isset($_POST['Description'])){
$Description=$_POST['Description'];
}if(isset($_POST['Link'])){
$Link=$_POST['Link'];
}
if(strlen($Title) <= 5){
echo "<script> alert('Title should be more than 5 characters!')</script>";
exit;
}
if(strlen($Description) <= 5){
echo "<script> alert('Description should be more than 5 characters!')</script>";
exit;
}
$contains = "https://drive.google.com/";
if(strlen($Link) <= 5 || !preg_match("/\b($contains)\b/", $Link)){
echo "<script> alert('INVALID LINK!') </script>";
exit;
}
else{
echo "<script> alert('DONE!') </script>";
}
?>
Thanks for your time.