Jump to content

Simple issue


amam

Recommended Posts

Hello,

 

I don't have any php knowledge and am having a hard time trying to implement the following:

 

- a drupal node is getting a numeric parameter with the URL in the following form "http://the.url/?X=123"

- what I want is for the script to check if the value has been passed with the URL, then use it in a form... if the entered URL was "http://the.url" without the X variable, then use a default value of 321.

 

<?php $_GET['X']; if (isset($X)) { print $X ; } else print "321" ?>

 

Thanks in advance for your help.

Link to comment
https://forums.phpfreaks.com/topic/219808-simple-issue/
Share on other sites

I usuly use

mysql_escape_string($_GET['']);

to add slashes

 

but there are lots of ways to make string safe

 

you will need

 

is_numeric($X);

 

so u can try

 

if(is_numeric($X)){

echo "its a number";

} else {

echo "not a number";

}

 

I think safty is allways 1st so yes validation is allways a good thing

Link to comment
https://forums.phpfreaks.com/topic/219808-simple-issue/#findComment-1139487
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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