Jump to content

[SOLVED] PHP url check - valid or 404?


andrewgarn

Recommended Posts

I've been looking at ways to check urls are valid. This current one just gives an error every time.

 

Requirements for the check are for a normal page to be valid, but a broken link and a 404 page NOT valid

 

$url = 'http://www.google.co.uk'';
echo $url;
$valid = @fsockopen("$url", 80, $errno, $errstr, 30);
if (!$valid) {
// Error Message
echo "URL not valid <br>";
?><meta http-equiv="Refresh" content="1; URL=register.php"><?
}    
else {

 

Anyone? I will continue looking for solutions

Link to comment
https://forums.phpfreaks.com/topic/110964-solved-php-url-check-valid-or-404/
Share on other sites

also could someone check this php function? I never seem to be good at ors in if functions...

 

<?php
if(!isset($_POST['username'] || $_POST['password'] || $email = $_POST['email']))
{
echo "Please complete all fields";
} 
else {
?> 

 

It gives: Parse error: parse error, unexpected T_BOOLEAN_OR, expecting ',' or ')' in register.php on line 64

You need to use a seperate isset() call for each variable:

if(!isset($_POST['username']) || !isset($_POST['password']) || !isset($email = $_POST['email']))) {

 

thanks, that fixed the synatax, but it doesnt actually work. I submit the form with empty fields and it still gets past the if function

 

<form name="login" method="post" action="register.php">
    <table border="0" width="225" align="center">
        <tr>
            <td width="219" bgcolor="#999999">
            <p align="center"><font color="white"><span style="font-size:12pt;"><b>Registration</b></span></font></p>
            </td>
        </tr>
        <tr>
            <td width="219">
                <table border="0" width="282" align="center">
                    <tr>
                        <td width="116"><span style="font-size:10pt;">Username:</span></td>
                        <td width="156"><input type="text" name="username"></td>
                    </tr>
                    <tr>
                        <td width="116"><span style="font-size:10pt;">Password:</span></td>
                        <td width="156"><input type="password" name="password"></td>
                    </tr>                
                    <tr>
                        <td width="116"><span style="font-size:10pt;">Email:</span></td>
                        <td width="156"><input type="text" name="email" maxlength="100"></td>
                    </tr>
    				<tr>
                        <td width="116"><span style="font-size:10pt;">Enable</span></td>
                        <td width="156"><SELECT NAME="track"><OPTION VALUE="Yes">Yes</OPTION><OPTION VALUE="No">No</OPTION></SELECT></td>
                    </tr>
                    <tr>
                        <td width="116"> </td>
                            <td width="156">
                                <p align="right"><input type="submit" name="submit" value="Submit"></p>
                            </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td width="219" bgcolor="#999999"> </td>
        </tr>
    </table>
    </form>  

 

if(!isset($_POST['username']) || !isset($_POST['password']) || !isset($_POST['email'])) 
{
echo "Please complete all fields";
}  
else {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.