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:



enter image description here



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?










share|improve this question




















  • 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















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:



enter image description here



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?










share|improve this question




















  • 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













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:



enter image description here



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?










share|improve this question















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:



enter image description here



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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












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.






share|improve this answer



















  • 1




    Of course - perfect
    – RGriffiths
    Nov 8 at 10:23











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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
































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.






share|improve this answer



















  • 1




    Of course - perfect
    – RGriffiths
    Nov 8 at 10:23















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.






share|improve this answer



















  • 1




    Of course - perfect
    – RGriffiths
    Nov 8 at 10:23













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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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














  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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




















































































Popular posts from this blog

Landwehr

Reims

Schenkenzell