This question already has answers here:
How to check if $_GET is empty?
(8 answers)
Closed 4 years ago.
There is a way to determine if there is any $_GET value (not with a specific key) passed in a GET request ? I'm not sure the syntax
isset($_GET)
is valide
$_GET is array so use count instead of isset.
<?php
if(count($_GET) >0){
//valid
}
?>
Related
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 3 years ago.
So I have this url:
Api.php?action=signup&name=Kalle&email=kalle#hiof.no&password=kalle&studieretning=IT&year=2000
To get the name out is it correct to have
echo $_POST['name'];
Cause in my case this ain't working
If you are using the querystring (which you are) then data arrives to PHP in the $_GET array not the $_POST array
So that would be
echo $_GET['name'];
This question already has answers here:
Check if a variable is undefined in PHP
(8 answers)
Closed 4 years ago.
What's the best way of checking if an object property in php is undefined?
You can use is_null
Or
!isset($object)
Example :
I want to check if the input is undefined. So, I can show errors.
if (!isset($_POST['myInput'])) { echo "error"; } else { // do the code }
This question already has answers here:
Check if multiple strings are empty [duplicate]
(7 answers)
Closed 5 years ago.
I have more than 30 fields in a form, and can't believe that I must write an array to check if any of them is empty (likehere)
I need something like js
$_POST[].each function{
if this is empty...
}
and hope that 'php' as so glorified language has something like this or similar.
Try this:
foreach($_POST as $post)
{
if( !empty($post) )
{
// your code here
}
}
This question already has answers here:
GET URL parameter in PHP
(7 answers)
Closed 7 years ago.
I have a client url[www.mysite.com/page.aspx]
when we put this url in browser then it revert the automatically
with this url
[www.mysite.com/page.aspx?|&CC=121&DD=123&AA=323|&CC=321&DD=555&AA=000]
Now we want to fetch that parameter value in php page through php or jquery.
Kindly Help and give the best suggestions.
You can simply use GET
$cc = $_GET['CC'];
$dd = $_GET['DD'];
You can access those values using $_REQUEST or $_GET
This question already has answers here:
Check if url contains parameters [duplicate]
(3 answers)
How to verify if $_GET exists?
(7 answers)
Closed 9 years ago.
I have lots of PHP statements along the lines of:
$getvalue = $_GET['valueiwant'];
In some scenarios not all variables are available. So, let's say 'valueiwant' doesn't exist in the URL string, how can I return a value based on the fact it doesn't exist?
For example if 'valueiwant' can't be found set $getvalue to -1
Currently it appears the value defaults to 0 and I need to be equal less than 0 if it doesn't exist.
Any ideas?
thanks
I always use
$getvalue=isset($_GET['valueiwant'])?$_GET['valueiwant']:-1;
Use of the isset() function checks if the offset exists, and returns a boolean value indicating it's existence.
This means that you can structure an if statement around the output.