Re: [PHP] Password Protection] -- My solution

2005-02-17 Thread Mailit, LLC

---BeginMessage---
Here is the setup that I have used.
Please, adapt to your needs.
Table 'theTable' is supposed to contain columns fname, mname, lname
and ePass (encrypted password). The crypt() function produces a password 
that
cannot be decrypted and really works well.
Of course, you need to use crypt() in the PHP script that creates a row in
'theTable'.

?php
#-- code starts here 
-#
$action = $_POST[action];
if( !empty( $action ) )
{
   $userName = $_POST[userName];
   $passw= $_POST[passw];

   # Bring the encrypted password and creation date from database:
   $cmd = SELECT * FROM theTable 
   .  WHERE userName='$userName' ;
   $res = mysql_query( $cmd ) or die( Password search failed. );
   $numRows = mysql_num_rows( $res );
   if( $numRows == 0 )
   {
   print( $userName not a valid user name.BR );
   exit;
   }
   $rec = mysql_fetch_array( $res );
   $privLevel = $rec[level];
   $nome = $rec[fname]. .$rec[mname]. .$rec[lname];
   # Encrypt the password:
   $passe = crypt( $passw, $rec[ePass] );
   if( $passe == $rec[ePass] )
   {
 /* Bring up the home page */
 print( h2WELCOME TO MY HOME PAGE/h2 );
   exit;
   }
   else
   {
   $retry = 1;
   }
}
   if( $retry )
   print(brh3Incorrect Login - Please, try again./h3br);
   ?
   FORM ACTION=? print( $_SERVER[PHP_SELF] ); ? METHOD=POST 
   INPUT TYPE=hidden NAME=action VALUE=login
   table align=center
   tr
   td
   BUser Name :/B
   /tdtd
   INPUT TYPE=text NAME=userName SIZE=20
   /td
   /trtr
   td
   BPassword :/B
   /tdtd
   INPUT TYPE=password NAME=passw SIZE=20
  /td
   /tr
   /table
   br
   P align=center
   INPUT TYPE=submit VALUE=Login STYLE=width:120;height:25
   /P
   /FORM
!-- - code ends here 
 --
Mario


Kevin Javia wrote:
I am experimenting on my site and I want to make it password protected like
www.realsolution.com.
If any one enters correct user name and password, only then they will be
able to enter into my site.
How can I do that in PHP?
Any ideas? Thanks a ton in advance.
 



---End Message---
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] getting a date 25 years back

2004-12-14 Thread Mailit, LLC
You should do date arithmetic using the Unix date format (number of 
seconds since 1970).
I think these string format dates are not appropriate.
Mario

Merlin wrote:
Hi there,
I am trying to create a date which is 25 years back from today. The 
purpose of this is to be able to query a mysql database date field 
for columns smaller than this date.

I tried this:
$years = 25;
$start_from = date(Y-m-d,strtotime(- .$years. year));
Somehow it always ads the years instead of subtracting.
Has anybody an idea on how to do that?
Thank you in advance for any help,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Why $a +1 is not 02 ??

2004-11-23 Thread Mailit, LLC
use printf( %02d, $a + 1 )
or something like that. Should work.
Mario
p
Labunski wrote:
Hello,
I have small problem..
$a = 01;
echo $a+1;
//this will display 2, instead of 02.
How to get 02?
thanks.
Lab.
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] How to change mail defaults?

2004-11-21 Thread Mailit, LLC
In php.ini we have the ability to set sendmail_from only for Windows. It 
is unfair, because it does not work
for Linux. When I broadcast, the From defaults to 'Apache' and people 
have complained about that.
Another thing that is causing trouble is that uploaded file ownership 
defaults to apache.apache, and I could not
find a way to change ownership and permissions for uploaded files.
Did anybody in this list solve these problems? Thank you
Mario Miyojim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to assure that php.ini is being obeyed?

2004-11-18 Thread Mailit, LLC
Sebastian Mendel,
I am using simple scripts to verify this file size issue:
The Html file that accepts the job is as follows:
form enctype=multipart/form-data action=uploading.php method=POST
   input type=hidden name=MAX_FILE_SIZE value=800 /
   pSend this file: input name=userfile type=file /
   pinput type=submit value=Send File /
/form
The action php script is as follows:
?php
  # uploading.php - Process the saving of an uploaded file
  $name = $_FILES[userfile][name];
  $type = $_FILES[userfile][type];
  $size = $_FILES[userfile][size];
  print( The file is called $name, type $type, size $sizebr );
  print( Error message: $php_errormsgbr );
?
I don't know how to see the error message, because when I submit a large 
file for uploading,  it does not even
execute the php script; the message This document contains no data 
pops up; if I click on OK, the php script
is not executed. I think I need a function that will catch the error 
before the system message pops up, but I don't
know how to code it.
So, that is why I am baffled. The error message that I see is not 
explanatory of the real situation.
Mario Miyojim

Sebastian Mendel wrote:
Llc Mailit wrote:
My problem: To upload large files.
Although /etc/php.ini on my Linux server specifies
upload_max_filesize = 8M
post_max_size = 8M
only files smaller than 512 kB are uploaded, while larger files 
fail with message
This document contains no data

quota?
free space?
try setting display_errors and startup_errors on
try track_errors with on

also, when using apache 1.3.2 or later, see the LimitRequestBody 
directive.

I set display_errors, startup_errors, track_errors On in php.ini, 
restarted Apache and reran an upload session.
The only error message displayed upon attempt to upload a large file 
is This document contains no data
The specified log file is empty.

did you check $php_errormsg ?
track_errors  boolean
If enabled, the last error message will always be present in the 
variable $php_errormsg.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] How to assure that php.ini is being obeyed?

2004-11-17 Thread Mailit, LLC
My problem: To upload large files.
Although /etc/php.ini on my Linux server specifies
upload_max_filesize = 8M
post_max_size = 8M
only files smaller than 512 kB are uploaded, while larger files fail 
with message
File contains no data
Everything happens as if php.ini were being ignored, although the 
parameters in question appear
with correct values on the table generated by phpinfo()
It is failing on my server, but on another server upload works as 
defined by /etc/php.ini
It must be something in the initialization of the server, or apache, but 
I don't know where to look.
Did anybody have this experience before?
Thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to assure that php.ini is being obeyed?

2004-11-17 Thread Mailit, LLC
I set display_errors, startup_errors, track_errors On in php.ini, 
restarted Apache and reran an upload session.
The only error message displayed upon attempt to upload a large file is 
This document contains no data
The specified log file is empty.
I am using Apache 2.0, but could not find LimitRequestBody in httpd.conf
I am not desperate, because the other server is working with large 
files. But I am really curious on why this
server has this limitation.
M. Sokolewicz wrote:

Sebastian Mendel wrote:
Llc Mailit wrote:
My problem: To upload large files.
Although /etc/php.ini on my Linux server specifies
upload_max_filesize = 8M
post_max_size = 8M
only files smaller than 512 kB are uploaded, while larger files fail 
with message
This document contains no data

quota?
free space?
try setting display_errors and startup_errors on
try track_errors with on
also, when using apache 1.3.2 or later, see the LimitRequestBody 
directive.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to assure that php.ini is being obeyed?

2004-11-17 Thread Mailit, LLC
Yes, I restarted httpd and ran phpinfo() to check if the parameter 
values were being recognized by php.
Two different Linux servers respond differently to the same change in 
php.ini.
That is why I suspect that my server has some basic setting that 
overrides everything that I do for php.
I am asking this question because my situation looks unique and the 
answer might be ridiculous.
Challenging, huh?

Jay Blanchard wrote:
[snip]
Did anybody have this experience before?
[/snip]
Just out of curiosity, did you restart Apache after you made the changes
to the php.ini?
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: php.ini

2004-11-16 Thread Mailit, LLC
This is a similar question, but under Linux.
No matter how I change the upload_max_filesize in /etc/php.ini, the file 
uploading script refuses to accept files larger than 512 kB.
If I run the phpinfo() function, the new value for upload_max_size (20M) 
appears there, but I get the message  File contains no data.
I repeated the test on another server running Linux, and I succeded in 
uploading a 6 MB file, by changing the value of upload_max_filesize.
My server must have some fundamental setting that overrides the php.ini 
settings. Can anyone clarify the matter?
Thanks. Mario.

Lester Caine wrote:
[EMAIL PROTECTED] wrote:
(on windows) can someone tell me where to define which php.ini gets 
used?

The default is a copy in the windows directory. (C:\WINDOWS or c:\WINNT)
While details of what goes IN php.ini are nice in the manual - where 
it goes is a bit more vague. Someone add some fine detail into 
relocating it?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php