you need to escape the / like so:
Code: Select all
<?php
<?php
if ($_POST['website'] != '' && !preg_match("/^(http|ftp):\/\//", $_POST['website'])) {
$_POST['website'] = 'http://'.$_POST['website'];
}
?>
?>
also notice i changed your & to &&
& is a bitwise operator. if you dont know what that is, your should probably avoid using it.
its also generally a bad idea and habit to get into to change the value of superglobals such as $_POST
you should do like this
Code: Select all
<?php
<?php
if ($_POST['website'] != '' && !preg_match("/^(http|ftp):\/\//", $_POST['website'])) {
$website = 'http://'.$_POST['website'];
}
?>
?>