Jump to content
Larry Ullman's Book Forums

Undefined Variable With Form Validation


Recommended Posts

In the following code I am validating a url in a practice page I am using from the stuff I learned in the book­. When I enter an invalid url in my form, I get an $url undefined error when running the code below. I am guessing the error is pretty easy to spot, but I am new at this. 

 

if (filter_var($scrubbed['url'], FILTER_VALIDATE_URL)){

$url = mysqli_real_escape_string($dbc, $scrubbed['url']);

} else {

echo '<p class="error">Please enter a valid url</p>';

}

Link to comment
Share on other sites

 Share

×
×
  • Create New...