passing integer into url as parameter phpjavascript - Stack Overflow

i want to save my website from url injection for that purpose i am using the following line to call ano

i want to save my website from url injection for that purpose i am using the following line to call another page with an integer id as an parameter here's the code

'<button onclick=window.location.href="admin_leadbox2.php?id=' + alert(typeof(parseInt(data[i].client_id))) + '">VIEW DETAILS</button>';

the alert is showing me that infact the data being passed in the url is a number
now when i get the id from the url and check its type in php it is giving me an string here's the php code

$id=$_REQUEST["id"];
echo "<script>console.log('".gettype($id)."')</script>";

i know that i can convert the string received in the url into integer like i did in javascript to do my work but for my case to prevent url injection i only want to receive an integer type data! what is the problem? thanks in advance

i want to save my website from url injection for that purpose i am using the following line to call another page with an integer id as an parameter here's the code

'<button onclick=window.location.href="admin_leadbox2.php?id=' + alert(typeof(parseInt(data[i].client_id))) + '">VIEW DETAILS</button>';

the alert is showing me that infact the data being passed in the url is a number
now when i get the id from the url and check its type in php it is giving me an string here's the php code

$id=$_REQUEST["id"];
echo "<script>console.log('".gettype($id)."')</script>";

i know that i can convert the string received in the url into integer like i did in javascript to do my work but for my case to prevent url injection i only want to receive an integer type data! what is the problem? thanks in advance

Share Improve this question edited Oct 28, 2016 at 11:11 uneeb asked Oct 28, 2016 at 11:09 uneebuneeb 891 silver badge11 bronze badges 9
  • 1 It's meant to be a string. Hence it's known as a query string – Clyde Lobo Commented Oct 28, 2016 at 11:11
  • cant i just pass an integer? look at this article derby-web-design-agency.co.uk/blog-post/… – uneeb Commented Oct 28, 2016 at 11:12
  • no. you can cast it to integer in your php code - when you get it from $_GET – krasipenkov Commented Oct 28, 2016 at 11:12
  • Possible duplicate of Validating whether $_REQUEST contents is an int – Clyde Lobo Commented Oct 28, 2016 at 11:14
  • 1 By the way, it doesn't matter what gets passed in the query string as your users / visitors will probably be able to manipulate it. You always need validadion on the server side. – jeroen Commented Oct 28, 2016 at 11:17
 |  Show 4 more ments

1 Answer 1

Reset to default 4

A URL is a string. A URL, or query parameters within it, has no types. Here, this is what your URL looks like:

admin_leadbox2.php?id=42

This is all the information that the puter has too. There's no hidden flag to mark "42" as an integer. It's just the characters 4 and 2. In a string. No different from "42foo", which would quite obviously be a string.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744641754a4585483.html

相关推荐

  • passing integer into url as parameter phpjavascript - Stack Overflow

    i want to save my website from url injection for that purpose i am using the following line to call ano

    2天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
['keyword'] : $thread['subject']; $header['description'] = $thread['description'] ? $thread['description'] : $thread['brief']; $_SESSION['fid'] = $fid; if ($ajax) { empty($conf['api_on']) and message(0, lang('closed')); $apilist['header'] = $header; $apilist['extra'] = $extra; $apilist['access'] = $access; $apilist['thread'] = well_thread_safe_info($thread); $apilist['thread_data'] = $data; $apilist['forum'] = $forum; $apilist['imagelist'] = $imagelist; $apilist['filelist'] = $thread['filelist']; $apilist['threadlist'] = $threadlist; message(0, $apilist); } else { include _include(theme_load('single_page', $fid)); } break; default: message(-1, lang('data_malformation')); break; } ?>