简体   繁体   中英

Fixing PHP Notices and Warnings?

I'm getting notices and warnings for this BMR Calculator PHP script, but I'm not sure whats causing them at all since these messages are only showing up in Firefox. Heres a screenshot

I added the php/html directly to my template file and turned php on for that file is that correct? Here is the php/html

Your issue is with:

$gender    = $_REQUEST['gender'];
$met       = $_REQUEST['metric'];

They're not defined in the query string or the posted data.

You could resolve the issue with an isset check.

# If gender is not set, set it to male by default.
$gender = isset( $_REQUEST['gender'] ) ? $_REQUEST['gender'] : 'male'; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM