PDA

View Full Version : A couple of quick php questions



The albati
September 10th, 2001, 00:23
I am wondering if there is a way to redirect someone to another webpage using php and not javascript.

Also, when I test for the pressence of a session variable using if (!$variable) {... it prints out a warning, saying undefined variable. Is there anyway around this warning other than disabling the warning level?

jm4n
September 10th, 2001, 01:04
You will need to send a "Location" header. In PHP, you can simply use a line like this:

header("Location: http://destination.url");

Make sure you don't attempt to output any HTML (which also means no whitespace before/after the <? ?> tags).

As for testing variables, you need to set your ErrorReporting level to not display "notice" type warnings. Most servers should be configured this way (it's the default in php.ini), but you can set this on a per-script basis as follows:

error_reporting(7);

Alternatively, you can do this site-wide in an .htaccess file (or other HTTP config file) by adding:

php_value error_reporting 7

(you can also use the constant values defined -- see your php.ini for details).

Hope this helps.

The albati
September 10th, 2001, 02:30
sweet, thanks for the fast and helpfull response.
.