Jump to content

php, how to catch if a variable is never sent (post or get)


rickyj

Recommended Posts

Hi,

 

I'm running into something that seems quite trivial. I'm primarily a java programmer, but am creating a web site that has a bit of php code.

 

The problem is, I have created a search page in php that querries a db, and returns to self with the results.

 

One of the problems im having is that if a user goes directly to search php, then there is an error thrown because there is no variable sent to this page.

 

I need a way of "catching" this error without having to define.

 

I have tried something like:

 

php:

 

if(  $_POST['myVar'] == NULL ){

$variableDefinedfromMyVar = "no search submited";

}

 

 

// problem is "$_POST['myVar']" thows an error since myVar is undefined

 

I also need to catch other nonsubmitted variables but cant see how ???? any suggestions

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.