By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

Getting the content length of posted values

100+
P: 107
hi,

i am currently creating one page processing the username and password , and prints the value given in that textboxes.

it is a single php script contains both the design and server script.

That is form action and actual page is same..

for example the below script is saved as login.php
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <form method="post" action="login.php">
  4. : :
  5. : :
  6. </form>
  7. <?php
  8. $s=$_POST['user'];
  9. $p=$_POST['pass'];
  10.  
in Asp i use to get the content length is request.TotalBytes
in JSP i use to get the content length is request.getContentLength
How do we get it in PHP?

Thanks in Advance..
Sep 30 '08 #1
Share this Question
Share on Google+
4 Replies


Dormilich
Expert Mod 5K+
P: 8,639
do you mean strlen($_POST['user']);?
Sep 30 '08 #2

pbmods
Expert 5K+
P: 5,821
Heya, rajujrk.

If you want to see if the User submitted anything, do this:
Expand|Select|Wrap|Line Numbers
  1. if( ! empty($_POST) )
  2.  
http://php.net/empty

If you need the actual length of the POST data, your best bet would be to do something like this:

Expand|Select|Wrap|Line Numbers
  1. strlen(http_build_query($_POST))
  2.  
http://php.net/strlen
http://php.net/http_build_query
Sep 30 '08 #3

100+
P: 107
do you mean strlen($_POST['user']);?
content length not only for a single field

i want check all the fields values
Oct 1 '08 #4

100+
P: 107
Heya, rajujrk.

If you want to see if the User submitted anything, do this:
Expand|Select|Wrap|Line Numbers
  1. if( ! empty($_POST) )
  2.  
http://php.net/empty

If you need the actual length of the POST data, your best bet would be to do something like this:

Expand|Select|Wrap|Line Numbers
  1. strlen(http_build_query($_POST))
  2.  
http://php.net/strlen
http://php.net/http_build_query
Ya fine..

Its working well

Thank you
Oct 1 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.