Character in email body if value empty
up vote
0
down vote
favorite
I have an iPad app that sends data to a PHP page using a post with body method and this works fine. On receiving this data the PHP page sends a notification email with some of the information from the body.
For one user I am getting this:

For some reason the for this user the app does not send the id or email and the body string looks like:
id=&posted_by=admin&email=
The reason for no id or email obviously needs to be fixed but in the meantime I am trying to catch this occurrence in the php page using:
if ($_POST['id'] == '' OR $_POST['id'] === NULL) {
.... do something...
}
However, this does not work. What would the value of $_POST['id'] be if its value had not been included in the body?
php html post
add a comment |
up vote
0
down vote
favorite
I have an iPad app that sends data to a PHP page using a post with body method and this works fine. On receiving this data the PHP page sends a notification email with some of the information from the body.
For one user I am getting this:

For some reason the for this user the app does not send the id or email and the body string looks like:
id=&posted_by=admin&email=
The reason for no id or email obviously needs to be fixed but in the meantime I am trying to catch this occurrence in the php page using:
if ($_POST['id'] == '' OR $_POST['id'] === NULL) {
.... do something...
}
However, this does not work. What would the value of $_POST['id'] be if its value had not been included in the body?
php html post
1
Are you sure this is a$_POST? This looks like a$_GET
– Lithilion
Nov 8 at 10:15
You should try $_REQUEST['id'].
– Gufran Hasan
Nov 8 at 10:16
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have an iPad app that sends data to a PHP page using a post with body method and this works fine. On receiving this data the PHP page sends a notification email with some of the information from the body.
For one user I am getting this:

For some reason the for this user the app does not send the id or email and the body string looks like:
id=&posted_by=admin&email=
The reason for no id or email obviously needs to be fixed but in the meantime I am trying to catch this occurrence in the php page using:
if ($_POST['id'] == '' OR $_POST['id'] === NULL) {
.... do something...
}
However, this does not work. What would the value of $_POST['id'] be if its value had not been included in the body?
php html post
I have an iPad app that sends data to a PHP page using a post with body method and this works fine. On receiving this data the PHP page sends a notification email with some of the information from the body.
For one user I am getting this:

For some reason the for this user the app does not send the id or email and the body string looks like:
id=&posted_by=admin&email=
The reason for no id or email obviously needs to be fixed but in the meantime I am trying to catch this occurrence in the php page using:
if ($_POST['id'] == '' OR $_POST['id'] === NULL) {
.... do something...
}
However, this does not work. What would the value of $_POST['id'] be if its value had not been included in the body?
php html post
php html post
edited Nov 8 at 10:29
Gufran Hasan
3,16031225
3,16031225
asked Nov 8 at 10:13
RGriffiths
2,233114376
2,233114376
1
Are you sure this is a$_POST? This looks like a$_GET
– Lithilion
Nov 8 at 10:15
You should try $_REQUEST['id'].
– Gufran Hasan
Nov 8 at 10:16
add a comment |
1
Are you sure this is a$_POST? This looks like a$_GET
– Lithilion
Nov 8 at 10:15
You should try $_REQUEST['id'].
– Gufran Hasan
Nov 8 at 10:16
1
1
Are you sure this is a
$_POST? This looks like a $_GET– Lithilion
Nov 8 at 10:15
Are you sure this is a
$_POST? This looks like a $_GET– Lithilion
Nov 8 at 10:15
You should try $_REQUEST['id'].
– Gufran Hasan
Nov 8 at 10:16
You should try $_REQUEST['id'].
– Gufran Hasan
Nov 8 at 10:16
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
The value of $_POST['id'] will be a warning unset variable id when it does not set in the body.
Before getting the value of $_POST['id'] you should use isset() function as:
if(isset($_POST['id']) && !empty($_POST['id'])){
// do something
}else{
// else part
}
Note: If you have no idea which type of method used to send data then you should use $_REQUEST['id'], it works for both GET and POST methods.
1
Of course - perfect
– RGriffiths
Nov 8 at 10:23
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
The value of $_POST['id'] will be a warning unset variable id when it does not set in the body.
Before getting the value of $_POST['id'] you should use isset() function as:
if(isset($_POST['id']) && !empty($_POST['id'])){
// do something
}else{
// else part
}
Note: If you have no idea which type of method used to send data then you should use $_REQUEST['id'], it works for both GET and POST methods.
1
Of course - perfect
– RGriffiths
Nov 8 at 10:23
add a comment |
up vote
3
down vote
accepted
The value of $_POST['id'] will be a warning unset variable id when it does not set in the body.
Before getting the value of $_POST['id'] you should use isset() function as:
if(isset($_POST['id']) && !empty($_POST['id'])){
// do something
}else{
// else part
}
Note: If you have no idea which type of method used to send data then you should use $_REQUEST['id'], it works for both GET and POST methods.
1
Of course - perfect
– RGriffiths
Nov 8 at 10:23
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
The value of $_POST['id'] will be a warning unset variable id when it does not set in the body.
Before getting the value of $_POST['id'] you should use isset() function as:
if(isset($_POST['id']) && !empty($_POST['id'])){
// do something
}else{
// else part
}
Note: If you have no idea which type of method used to send data then you should use $_REQUEST['id'], it works for both GET and POST methods.
The value of $_POST['id'] will be a warning unset variable id when it does not set in the body.
Before getting the value of $_POST['id'] you should use isset() function as:
if(isset($_POST['id']) && !empty($_POST['id'])){
// do something
}else{
// else part
}
Note: If you have no idea which type of method used to send data then you should use $_REQUEST['id'], it works for both GET and POST methods.
edited Nov 8 at 10:34
answered Nov 8 at 10:20
Gufran Hasan
3,16031225
3,16031225
1
Of course - perfect
– RGriffiths
Nov 8 at 10:23
add a comment |
1
Of course - perfect
– RGriffiths
Nov 8 at 10:23
1
1
Of course - perfect
– RGriffiths
Nov 8 at 10:23
Of course - perfect
– RGriffiths
Nov 8 at 10:23
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205563%2fcharacter-in-email-body-if-value-empty%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Are you sure this is a
$_POST? This looks like a$_GET– Lithilion
Nov 8 at 10:15
You should try $_REQUEST['id'].
– Gufran Hasan
Nov 8 at 10:16