Link to home
Start Free TrialLog in
Avatar of MOSTAGHASSI
MOSTAGHASSIFlag for United States of America

asked on

How can define this $_GET["page"] variable on my page?

Hello;

Above a page i have used these 2 lines:

 $pagenum = utf8_decode(htmlspecialchars($_GET["page"])); //these 2`lines are for injection protection.
 $pagenum = mysql_real_escape_string($pagenum);

Open in new window


but in error log of php i get a notice that :

PHP Notice:  Undefined index: page

Open in new window


please let me know that where and how can define the variable 'page'?

Thanks
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

$_GET["page"] only comes from a variable in a query string named 'page'.  It can come from a form using 'get' or it can simply be part of the query string in a URL.
http://www.mysite.com/yourpage?page=thispage

Open in new window

http://php.net/manual/en/reserved.variables.get.php
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is how and why you want to move to the MySQLi or PDO extensions.  It's important to move to the currently supported extensions because after Jan 1, 2017, there is no supported PHP release that continues to support MySQL.
https://www.experts-exchange.com/articles/11177/PHP-MySQL-Deprecated-as-of-PHP-5-5-0.html

PHP external variables are handled this way:
http://php.net/manual/en/reserved.variables.get.php
http://php.net/manual/en/language.variables.external.php

See also:
http://php.net/manual/en/book.filter.php
Avatar of MOSTAGHASSI

ASKER

Thanks for all comments,specially regarding mysqli.
You are welcome.