jeudi 8 juin 2017

preg_match with 2 rules doesn't work

I want that preg_match accepts https:// and http:// but also urls without that like google.de sh.st and stuff like that

This if-Statement works, but it only accepts https:// and http:// urls if(!preg_match("/^[a-zA-Z]+[://]+[A-Za-z0-9-_]+\.+[A-Za-z0-9./%&=\?-_]+$/i", $flink)) { $html = "Error: invalid URL"; }

I tried this, but this doesn't work too...

$bd = "/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i";
$dbb = "/^[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i";
  if(!preg_match($bd, $flink)) /* || !preg_match($dbb, $flink)) */ {
    $html = "Error: invalid URL"; }

What is wrong ? The problem page is https://viid.su

Aucun commentaire:

Enregistrer un commentaire