I'm trying to test if for existing URLs in a user form field and need a little guidance. I am a placement student and told the place I'm working for I'm not great with PHP and here I am working with PHP.
This is looking like the best I've tried thus far:
$file = [url];
$file_headers = @get_headers($file);
if($file_headers[0] == 'HTTP/1.1 404 Not Found') {
$exists = false;
}
else {
$exists = true;
}
if ($_POST[code] == '') {
header("Location: index.php");
exit;
}
else if ($exists == false){
print("URL is not valid");
}
else {
$query = "INSERT INTO redirects
SET code = '$_POST[code]',
url = '$_POST[url]',
requester = '$_POST[requester]',
date = '$_POST[iw_start]',
webperson = '$_POST[webperson]',
active = '$_POST[active]'";
mysql_query ($query, $link);
}
?>
Am I on the right path?
*BEFORE YOU ANSWER: THE SQL QUERY IS NOT MINE. PLEASE KEEP THAT IN MIND.