/    Sign up×
Community /Pin to ProfileBookmark

empty $_POST , is getting me crazy

Im trying to make a form , because im showing some table rows and i need a checkbox to delete them. The problem is that the $_POST is empty all the time and i ran out of ideas. I checked the code 100 times and it looks ok for me. Can you please give me a hand.

[CODE] print ‘<form name=”formmsg” id=”formmsg” method=”post” action=”http://apps.facebook.com/********/read.php?delete=selected’;if($_GET[‘pageno’]){echo ‘&pageno=’.$_GET[‘pageno’];}
print ‘” target=”_top”>’;
print ‘<table id=”tablamensajes” class=”tabla”><tr><td><div class=”cabezerabox”>&nbsp;</div></td><td style=”width:100px”><div class=”cabezerabox”>Received</div></td><td style=”width:400px”><div class=”cabezerabox”>Mensaje</div></td><td><div class=”cabezerabox”>Sender</div></td></tr>’;
$id=0;
for ($i=0; $i< count($mensa); $i++){
$resumen=ucfirst(strtolower(substr($mensa[$i][‘mensaje’],0,70)));
$id=$id+1;
print ‘<tr ><td class=”check”><input type=”checkbox” name=”chkIdMsg[‘.$i.’]” value=”‘. $mensa[$i][‘idMsg’] . ‘”></td><td class=”mensajes”>’. $mensa[$i][‘fecha’] . ‘</td><td id=”‘.$id .'” class=”filas” onclick=”mostrarOcultar(this)”><a href=”#” onclick=”function(); return false;”>’. $resumen . ‘…</a></td><td class=”mensajes”><a href=”#” onclick=”function(); return false;”><img src=”images/who.png” height=”30px” width=”30px”></img></a></td></tr>’;

$id=$id+1;
print ‘<tr id=”‘.$id .'” class=”filasocultas”><td colspan=”4″ class=”mensajeentero”>’. nl2br($mensa[$i][‘mensaje’]). ‘</td></tr>’;
}
print ‘<tr><td colspan=”4″> &nbsp;&nbsp;&nbsp;&nbsp;<img src=”images/arrow.png”></img>&nbsp;&nbsp;<a href=”#” onclick=”marcarTodos()”>Select All&nbsp;&nbsp;/Unselect All</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=”#” onclick=”document.formmsg.submit();”><img src=”images/drop.png”>Delete Selected</img></a><input type=”text” name=”text” value=”testtext”><input type=”submit” value=”testsubmit”></td><tr>’;
print ‘</table></form>’;

}
if($_GET[‘delete’]== ‘selected’){
var_dump($_POST);
print $_POST[‘text’];
print $text;[/CODE]

to post a comment
PHP

9 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiJan 19.2009 — Is http://apps.facebook.com/********/read.php the script containing the above code?
Copy linkTweet thisAlerts:
@chifliiiiiauthorJan 19.2009 — yes it is. Thats also why i have to use target="_top" as is a iframe
Copy linkTweet thisAlerts:
@JunkMaleJan 20.2009 — You are creating a form, you can not expect the POST array to contain anything unless the form is submitted, when the form is sent, the POST arrays get filled with the data as go the GET arrays.

What you need to do is to test if the form is being submitted, if it is, process it, if it is not a form submission then output a form.
Copy linkTweet thisAlerts:
@chifliiiiiauthorJan 20.2009 — The form is submited with the <input type="submit" value="testsubmit"> . MY original idea was using a text link and javascript to submit the form like you can see on <a href="#" onclick="document.formmsg.submit();"> At the end i put that button because i was not sure where the problem was. I still dont know where the problem is.
Copy linkTweet thisAlerts:
@JunkMaleJan 20.2009 — Well thats not what you have in the code you posted.

What it looks like your doing is outputting a form and trying to process various elements at the same time.

You have to test if the submit button is present, it is present if the form is a form submission to the server which will then have data in the fields when the form is recieved.

You can not access data in fields when theirs no data to access because your outputing a form, not processing it.

Search this forum, you will find adequate examples of how a form is handles, processes, error checked and secured from hacks and form injection methods and then you can adapt them for what you need.
Copy linkTweet thisAlerts:
@MindzaiJan 20.2009 — ^^

That's incorrect. There is nothing wrong with outputting a form and inspecting data posted from it in the same script as the OP is doing. When the above script is run it will just show the form, and the results of var_dump($_POST) which should identify it as an empty array. When the form is submitted back to the same script it will then re-show the form and the contents of $_POST via var_dump.

I think the problem is a syntax error which you are not being notified of due to facebook having error_reporting off. It looks to me like you have an extra closing brace, but tbh the source code is so badly formatted it's hard to tell.

I'd suggest testing this code locally with error reporting turned right up and see if you get any errors.
Copy linkTweet thisAlerts:
@JunkMaleJan 21.2009 — @Mindzai

I am refering to the form itself.

You have to check to see if the submission is a form or not first in order to determin the best course of action to take in the script.

If the thread starte wants to look up other forms on this forum, they will soon see what the issue is.

I have tried pointing it out in easy terms but its just gone over peoples heads so thats me done with this.

Ciao.
Copy linkTweet thisAlerts:
@MindzaiJan 21.2009 — No, there is no need to check if a form is submitted before examining the contents of $_POST. The code above var_dumps $_POST regardless of whether the form is submitted or not. This means that when the page is originally loaded, var_dump will determine it is an empty array, and after the form is submitted it should determine that it is a populated array.
Copy linkTweet thisAlerts:
@JunkMaleJan 21.2009 — Not arguing, Said my bit and for good reason and now I am done with this thread...
×

Success!

Help @chifliiiii spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...