Jump to content

Recommended Posts

Hi every body, in this code i am trying to write to file on linux server :

 

<code>

$c=$_SERVER['HTTP_HOST'];

echo $_SERVER['REMOTE_PORT'];

 

$ip_add=$c;

 

$today=date("d-M-y");

$date = date("Y-M-d H:i:s");

 

$logfile = $today."_log.txt";

$dir = 'log';

$saveLocation=$dir . '/' . $logfile;

$logMessage=$ip_add;

if(!is_dir($dir))

{

  mkdir($dir,"0755");

}

 

if (!$handle = fopen($saveLocation, "a"))

{

    //ERROR, DO SOMETHING

    #echo "can't create the file";

    exit;

}

else

{

    if(fwrite($handle,'Date: '.$date. ' IP: '. $logMessage.'  '.'/r/n')===FALSE)

    {

          //ERROR, DO SOMETHING

        # echo " can't write to the file ";

          exit;

    }

 

    fclose($handle);

}

</code>

1. how to go to new line each time we are writting in the file (/r/n it is not working, it is writing it in the file as /r/n) like this:

Date: 2007-Aug-09 09:12:36 IP: 10.6.0.15 /r/n

2. can i write the user computer name in the file and its port.

coz i want to create a log file for each user loggin into the system

 

Link to comment
https://forums.phpfreaks.com/topic/64041-new-line-character/
Share on other sites

i am sure of what i am seeing , look what is writting into the file when i am trying both : \r\n and /r/n:

Date: 2007-Aug-09 09:51:52 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 09:55:17 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 09:57:04 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 09:57:51 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 10:00:54 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 10:01:12 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 10:03:25 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 10:04:22 IP: 10.6.0.15  /r/nDate: 2007-Aug-09 10:07:11 IP: 10.6.0.15  \r\n

Link to comment
https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319218
Share on other sites

you are right "\r\n" but i want to know the answer of second question:

1.how to get the user computer name , and i have another question also :

 

2. after submitting a forum , is there a way that i will refresh another frame not the frame mentioned in the action attribute in the form tag.

i meant suppose i have 3 frames :

first frame :top.php which contatins the form

second frame: body.php which recieve the form contents

third frame : left.php contains some links in the body.php

 

so how can i , after submitting the form refresh both body.php and left.php

Link to comment
https://forums.phpfreaks.com/topic/64041-new-line-character/#findComment-319230
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.