Jump to content

[SOLVED] How to check for empty querystring in PHP ?


lonewolf217

Recommended Posts

I have a php page that displays data from a database.  there is an option on the page to delete a row.  If the user chooses to delete the row, he goes to the delete.php page which will process the delete, then redirect back to the original page.

 

My issue is with a piece of code on this main page where I do this

$query = $_GET['name'];
if(strlen($query) != 0) {
$query = str_replace(' ','%20',$query);
echo "<br>The file " . $query . " was successfully uploaded.<br><br>";
}

 

if i am loading this page without having deleted the file, the $_GET should be empty, but I am getting an error

 

PHP Notice: Undefined index: name in view.php

 

how do I change it so that if the querystring really is empty, it will not do anything here and continue with the rest of the code

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.