Re: [PHP] another easy cookie question

2001-09-14 Thread Kelly Barrett

Hi George,
You must output all headers (including cookies) before you output any
content.

So, you just need to move your header and setcookie calls so they are above
the html and head tags.

e.g.
 ?php
 header(Location:index.php);
 setcookie(Cookievalue, abcdefghijklmnopqrstuvwxyz0123456789)
 time()+3600);
 ?
 html
 head


Cheers,
Kelly.

 Hi all,

 This is what I have at the top of my php page (php-4.0.6-winNT).

 html
 head
 ?php
 header(Location:index.php);
 setcookie(Cookievalue, abcdefghijklmnopqrstuvwxyz0123456789)
 time()+3600);
 ?
 titleUntitled Document/title
 meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
 /head

 I get the following error.

 CGI Error
 The specified CGI application misbehaved by not returning a complete set
of
 HTTP headers.  The headers it did return are:

 ... and nothing else!

 Where am I going wrong? I bet it's a simple answer.

 George P in Edinburgh





 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php4 and apache on SuSE Linux

2001-09-13 Thread Kelly Barrett

Hi Sean,
What webserver are you using?  Is it using the Apache module of PHP or the
CGI version?

Perhaps the extension of your file doesn't have the PHP processor associated
with it (if it is installed as an Apache process)?

Maybe you are using the CGI version incorrectly?

With the command line version, you still need the ?php ? tags before it
will process the PHP code.

e.g.
#!/usr/bin/php

?php
echo Hey, I am working fine.;
?

That should work as you expect.

Cheers,
Kelly.

 I am trying to run a simple php4 script on my SuSE Linux 7.2 (Update)
 system, but I am not getting the correct output.  Instead of the browser
 (Netscape or Konqueror) showing a normal web page, it shows the raw
 commands from the php script portion of the html file.

 Here is the script I am using:

 html
 head
 titlePHP Test Example/title
 /head
 body
 ?php

 echo hr;
 echo date(H:i, jS F);
 echo p;
 echo Hi, I am a PHP script!p;
 echo hr;

 ?
 /body
 /html

 When I open this file with konqueror or Netscape, the browser window
 carries the title PHP Test Example, but the output within the browser
 window looks like this:

 ; echo date(H:i, jS F); echo

 ; echo Hi, I am a PHP script!

 ; echo
 -a horizontal rule___
 ; ?

 Furthermore, if I run a simple script from the command line, something
like
 this (trythis.php):

 #!/usr/bin/php

 echo Hey, I am working fine.;

 this is the output I get:

 tschulze:~/web_dev/schulze ./trythis.php
 X-Powered-By: PHP/4.0.4pl1
 Content-type: text/html


 echo Hey, I am working fine.;

 tschulze:~/web_dev/schulze

 Any idea what I need to do to get this working right?

 TIA,
 Sean

 [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php4 and apache on SuSE Linux

2001-09-13 Thread Kelly Barrett

It sounds like the PHP isn't getting parsed.  Check the webserver is
configured correctly for the extension of your file, or that your system
requires you to use the CGI version of the PHP interpreter.

 Rudolf,

 I have tried adding the double quotes, and when I do, nothing at all is
 displayed.  Adding single quotes to the script, just adds single quotes to
 the output.

 Sean

 Rudolf Visagie wrote:

  Try:
 
  html
  head
  titlePHP Test Example/title
  /head
  body
  ?php
 
  echo hr;
  echo date(H:i, jS F);
  echo p;
  echo Hi, I am a PHP script!p;
  echo hr;
 
  ?
  /body
  /html
 
  Rudolf Visagie
  [EMAIL PROTECTED]
 
  -Original Message-
  From: T.Sean Schulze [mailto:[EMAIL PROTECTED]]
  Sent: 13 September 2001 11:47
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: [PHP] php4 and apache on SuSE Linux
 
 
  I am trying to run a simple php4 script on my SuSE Linux 7.2 (Update)
  system, but I am not getting the correct output.  Instead of the browser
  (Netscape or Konqueror) showing a normal web page, it shows the raw
  commands from the php script portion of the html file.
 
  Here is the script I am using:
 
  html
  head
  titlePHP Test Example/title
  /head
  body
  ?php
 
  echo hr;
  echo date(H:i, jS F);
  echo p;
  echo Hi, I am a PHP script!p;
  echo hr;
 
  ?
  /body
  /html
 
  When I open this file with konqueror or Netscape, the browser window
  carries the title PHP Test Example, but the output within the browser
  window looks like this:
 
  ; echo date(H:i, jS F); echo
 
  ; echo Hi, I am a PHP script!
 
  ; echo
  -a horizontal rule___
  ; ?
 
  Furthermore, if I run a simple script from the command line, something
  like this (trythis.php):
 
  #!/usr/bin/php
 
  echo Hey, I am working fine.;
 
  this is the output I get:
 
  tschulze:~/web_dev/schulze ./trythis.php
  X-Powered-By: PHP/4.0.4pl1
  Content-type: text/html
 
 
  echo Hey, I am working fine.;
 
  tschulze:~/web_dev/schulze
 
  Any idea what I need to do to get this working right?
 
  TIA,
  Sean
 
  [EMAIL PROTECTED]
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP Security

2001-09-13 Thread Kelly Barrett

Hi Allen,
What you should do is check the session variable from within PHP.  If it
doesn't exist, you redirect to a PHP authentication form.

So at the head of each page you need something like:
?php
session_start();
if(session_is_registered(logged_in) == false)
{
header(location: login.php); // redirect to login page
exit();
}

// continue on here
?
And in your PHP authentication form, you register the logged_in variable
after the user details have been authenticated:
?php
// user details have been authenticated at this stage

session_start();
session_register(logged_in);
$logged_in = true;
header(location: somepage.php); // redirect to the page they were
originally going to
exit();
?

Cheers,
Kelly.

 I have been using the .htpasswd/.htaccess convention to authenticate our
 3000 employees.
 I want to move away from the .htpasswd/.htaccess convention and use a PHP
 form to authenticate against the database.

 I can create the PHP authentication page, no problem, but how do I check
 authentication on the thousands of HTML pages I already have on the site?
 For several reasons I don't want to do cookies. Can I set a session
variable
 in the PHP and conditionally check it with Javascript, if fail go to PHP
 authentication form?

 What is the javascript session variable function?

 Thanks

 -Allen


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Getting ip address of client and displaying a number in decimal format.

2001-09-13 Thread Kelly Barrett

Troy,
$REMOTE_ADDR gives you the client IP.

To convert a number to show 2 decimals use sprintf:

$money = 5;

$money_string = sprintf(%.2f, $money); // $money_string will be 5.00

Cheers,
Kelly.

 -Original Message-
 From: Troy Lynch [mailto:[EMAIL PROTECTED]]
 Sent: Friday, 14 September 2001 8:49 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Getting ip address of client and displaying a number in
 decimal format.
 
 
 I'm trying to find out how to do 2 things one. I'd like to get the ip
 address of the client machine so I can write it to a database. 
 And then I'd
 like to convert a number to show 2 decmials to the right like for money
 etc
 
 
 Thanks
 
 Troy
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] easy cookie question

2001-09-13 Thread Kelly Barrett

You need to set the expire time.  Set it to 10 years in the future or
something.

$expire_time = time() + (86400 * 365 * 10);
setcookie(cookie, value, $expire_time);

Cheers,
Kelly.

 -Original Message-
 From: Jay Paulson [mailto:[EMAIL PROTECTED]]
 Sent: Friday, 14 September 2001 6:13 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] easy cookie question


 How do you set a cookie not to ever expire even after the browser
 is closed?

 I've tried the following:

 setcookie(cookie,value);

 and when you close the browser it has to set the cookie again,
 which i don't
 want it to do.

 Thanks,
 jay


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Searching for text in a file

2001-09-10 Thread Kelly Barrett

Hi Richard,
First, I think it should be:
$variable = [EMAIL PROTECTED];
instead of:
 $line_text= [EMAIL PROTECTED];

as you overwrite $line_text with your fgets.

Also:
 if ($variable = trim($line_text)) {
Should be:
 if ($variable == trim($line_text)) {

Otherwise you are doing an assignment, which will always be true.

Finally, your while loop should probably be:
while(feof($fd) == false) {
$line_text = fgets($fd, 2048);

Because fgets returns EOF at the end of a file, not necessarily false (I
THINK EOF currently is false, though theoretically EOF could change to any
value).

Cheers,
Kelly.

 -Original Message-
 From: Richard Kurth [mailto:[EMAIL PROTECTED]]
 Sent: Monday, 10 September 2001 5:12 PM
 To: php
 Subject: [PHP] Searching for text in a file


 I am having a problem with searching through a file for a curtain
   text. Like the text below [EMAIL PROTECTED] does not exists in the file
   but when I run this it gives me a Match at line number.
   I need to run three or four names at a time through this script
   to see if they are already there. But it does not seam to work.
   And I can not figure out way. A small sample of the file is below.

 $fd = fopen (virtusertable, r);
 $line_text= [EMAIL PROTECTED];
$count = 1;
 while ($line_text = fgets($fd, 2048)) {
 if ($variable = trim($line_text)) {
echo Match at line number $count;
 break;
 }
 ++$count;
 }


 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]











 Best regards,
  Richard
 mailto:[EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: Re[2]: [PHP] Searching for text in a file

2001-09-10 Thread Kelly Barrett

Richard,
I just put together a script using that code exactly, and it worked.

All I can say is make sure that what you are searching for is actually in
the file you are searching.

Remember that the string you are searching for needs to match the entire
contents of the line, not just a substring of the line.

Try some simple tests that you know are sure to work. i.e. Make a
virtusertable file that is just a couple of lines.

 Hello Kelly,
 Yes I noticed the variable after I sent the message
 Now I have it like this.  But If I add something that is in the file it
 does not find it.

 $fd = fopen (virtusertable, r);
 $variable= [EMAIL PROTECTED];
$count = 1;
 while(feof($fd) == false) {
 $line_text = fgets($fd, 2048);
 if ($variable == trim($line_text)) {
echo Match at line number $count;
 break;
 }
 ++$count;
 }


 Monday, September 10, 2001, 12:39:15 AM, you wrote:

 Kelly Barrett Hi Richard,
 Kelly Barrett First, I think it should be:
 Kelly Barrett $variable = [EMAIL PROTECTED];
 Kelly Barrett instead of:
  $line_text= [EMAIL PROTECTED];

 Kelly Barrett as you overwrite $line_text with your fgets.

 Kelly Barrett Also:
  if ($variable = trim($line_text)) {
 Kelly Barrett Should be:
 Kelly Barrett  if ($variable == trim($line_text)) {

 Kelly Barrett Otherwise you are doing an assignment, which will
 always be true.

 Kelly Barrett Finally, your while loop should probably be:
 Kelly Barrett while(feof($fd) == false) {
 Kelly Barrett $line_text = fgets($fd, 2048);

 Kelly Barrett Because fgets returns EOF at the end of a file,
 not necessarily false (I
 Kelly Barrett THINK EOF currently is false, though theoretically
 EOF could change to any
 Kelly Barrett value).

 Kelly Barrett Cheers,
 Kelly Barrett Kelly.

  -Original Message-
  From: Richard Kurth [mailto:[EMAIL PROTECTED]]
  Sent: Monday, 10 September 2001 5:12 PM
  To: php
  Subject: [PHP] Searching for text in a file
 
 
  I am having a problem with searching through a file for a curtain
text. Like the text below [EMAIL PROTECTED] does not exists in the file
but when I run this it gives me a Match at line number.
I need to run three or four names at a time through this script
to see if they are already there. But it does not seam to work.
And I can not figure out way. A small sample of the file is below.
 
  $fd = fopen (virtusertable, r);
  $line_text= [EMAIL PROTECTED];
 $count = 1;
  while ($line_text = fgets($fd, 2048)) {
  if ($variable = trim($line_text)) {
 echo Match at line number $count;
  break;
  }
  ++$count;
  }
 
 
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
 
 
 
 
 
 
 
 
 
 
 
  Best regards,
   Richard
  mailto:[EMAIL PROTECTED]
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail:
 [EMAIL PROTECTED]
 
 





 --
 Best regards,
  Richard
 mailto:[EMAIL PROTECTED]


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re[4]: [PHP] Searching for text in a file

2001-09-10 Thread Kelly Barrett

Richard,
Then you need to use something like explode() to get only the part you
want.

e.g.  If the file is delimited by spaces, then have something like this:

$fd = fopen (virtusertable, r);
$variable= [EMAIL PROTECTED];
$count = 1;
while(feof($fd) == false) {
$line_text = fgets($fd, 2048);
$strings = explode( , $line_text);--- Splits the line at
every space into an array of string
 if ($variable == trim($strings[0])) {
echo Match at line number $count;
 break;
 }
 ++$count;
 }

If the file is tab delimited, you will need:
$strings = explode(\t, $line_text);

 Hello Kelly,
 Your right the script does work but my problem is this
 the file I am searching looks like this below.
 And if I search on [EMAIL PROTECTED] alone it does not find it but
 if I search on [EMAIL PROTECTED]   yourns it finds it. I need it
 to find just the email address not the stuff after it.


 [EMAIL PROTECTED]   yourns
 [EMAIL PROTECTED]  root
 [EMAIL PROTECTED]   majordomo_site1
 [EMAIL PROTECTED] owner-majordomo_site15
 [EMAIL PROTECTED] sys


 Monday, September 10, 2001, 1:26:44 AM, you wrote:

 Kelly Barrett Richard,
 Kelly Barrett I just put together a script using that code exactly, and
it worked.

 Kelly Barrett All I can say is make sure that what you are searching for
is actually in
 Kelly Barrett the file you are searching.

 Kelly Barrett Remember that the string you are searching for needs to
match the entire
 Kelly Barrett contents of the line, not just a substring of the line.

 Kelly Barrett Try some simple tests that you know are sure to work. i.e.
Make a
 Kelly Barrett virtusertable file that is just a couple of lines.

  Hello Kelly,
  Yes I noticed the variable after I sent the message
  Now I have it like this.  But If I add something that is in the file it
  does not find it.
 
  $fd = fopen (virtusertable, r);
  $variable= [EMAIL PROTECTED];
 $count = 1;
  while(feof($fd) == false) {
  $line_text = fgets($fd, 2048);
  if ($variable == trim($line_text)) {
 echo Match at line number $count;
  break;
  }
  ++$count;
  }
 
 
  Monday, September 10, 2001, 12:39:15 AM, you wrote:
 
  Kelly Barrett Hi Richard,
  Kelly Barrett First, I think it should be:
  Kelly Barrett $variable = [EMAIL PROTECTED];
  Kelly Barrett instead of:
   $line_text= [EMAIL PROTECTED];
 
  Kelly Barrett as you overwrite $line_text with your fgets.
 
  Kelly Barrett Also:
   if ($variable = trim($line_text)) {
  Kelly Barrett Should be:
  Kelly Barrett  if ($variable == trim($line_text)) {
 
  Kelly Barrett Otherwise you are doing an assignment, which will
  always be true.
 
  Kelly Barrett Finally, your while loop should probably be:
  Kelly Barrett while(feof($fd) == false) {
  Kelly Barrett $line_text = fgets($fd, 2048);
 
  Kelly Barrett Because fgets returns EOF at the end of a file,
  not necessarily false (I
  Kelly Barrett THINK EOF currently is false, though theoretically
  EOF could change to any
  Kelly Barrett value).
 
  Kelly Barrett Cheers,
  Kelly Barrett Kelly.
 
   -Original Message-
   From: Richard Kurth [mailto:[EMAIL PROTECTED]]
   Sent: Monday, 10 September 2001 5:12 PM
   To: php
   Subject: [PHP] Searching for text in a file
  
  
   I am having a problem with searching through a file for a
curtain
 text. Like the text below [EMAIL PROTECTED] does not exists in the
file
 but when I run this it gives me a Match at line number.
 I need to run three or four names at a time through this script
 to see if they are already there. But it does not seam to work.
 And I can not figure out way. A small sample of the file is below.
  
   $fd = fopen (virtusertable, r);
   $line_text= [EMAIL PROTECTED];
  $count = 1;
   while ($line_text = fgets($fd, 2048)) {
   if ($variable = trim($line_text)) {
  echo Match at line number $count;
   break;
   }
   ++$count;
   }
  
  
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
   [EMAIL PROTECTED]
  
  
  
  
  
  
  
  
  
  
  
   Best regards,
Richard
   mailto:[EMAIL PROTECTED]
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   To contact the list administrators, e-mail:
  [EMAIL PROTECTED]
  
  
 
 
 
 
 
  --
  Best regards,
   Richard
  mailto:[EMAIL PROTECTED]
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail:
[EMAIL PROTECTED]
 
 





 --
 Best regards