vipes Posted January 30, 2007 Share Posted January 30, 2007 Hi, I don't know anything about php...but basically i have a form I want to send the info thats put into the form sent to a text file.Like Login: Password: i want those 2 variables sent to a text file. how would I do that exactly?Can anyone show me a script or something of how its done and what to edit?Thanks. Quote Link to comment Share on other sites More sharing options...
vipes Posted January 30, 2007 Author Share Posted January 30, 2007 bumpanyone? Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted January 30, 2007 Share Posted January 30, 2007 i would suggest searching google for a simple text file based member system. it isnt hard, you just need to no about fopen() fwrite() etc etc. arrays can help to. some basic stuff. start reading up is my suggestion to you. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted January 30, 2007 Share Posted January 30, 2007 if you send your form stuff to the php via post... than it would be something like this. ( i dont know anything much abobut file writing only databases)fwrite($_POST['field1']);fwrite($_POST['field2']);f_write("/n/n");goodluckps that doesnt iclude any validation Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted January 30, 2007 Share Posted January 30, 2007 your missing a parameter. here. this is how its done. you get your post data, then open the file, write it, then close it.like this:[code=php:0]$username = $_POST['username'];$handle = fopen('data.txt', 'a'); //the 'a' is the mode. for more modes visit http://au2.php.net/manual/en/function.fopen.phpif(fwrite($handle, "<>".$username)){echo "Wrote content.";}else{echo "Failed writing content.";}[/code]hope that helps. Quote Link to comment Share on other sites More sharing options...
vipes Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=ProjectFear link=topic=124633.msg516852#msg516852 date=1170136710]your missing a parameter. here. this is how its done. you get your post data, then open the file, write it, then close it.like this:[code=php:0]$username = $_POST['username'];$handle = fopen('data.txt', 'a'); //the 'a' is the mode. for more modes visit http://au2.php.net/manual/en/function.fopen.phpif(fwrite($handle, "<>".$username)){echo "Wrote content.";}else{echo "Failed writing content.";}[/code]hope that helps.[/quote]I tried that but for some reason when I click login it just posts everything in the address bar and shows opens the php file and shows the code....this is basically what ive got<h5 class="heading">Member Login</h5> <form action="myphp.php"> <div class="row"> <label for="email">E-Mail:</label> <input type="text" name="email" id="email" value="crashnburn500@yahoo.com" /> </div> <div class="row"> <label for="password">Password:</label> <input name="password" type="password" id="password" /><br /> </div> <div class="clear" style="margin-left:-8px; margin-bottom:3px;"> <input type="checkbox" name="Remember" value="Remember" id="checkbox" checked /> <label for="checkbox">Remember Me</label><br /> </div> <div style="margin-left:21%">When someone clicks Login, i want the username and password to be logged to a file....i've been looking up stuff but i cant figure it all out? if someone can tell me what I should put after <form action= and what should the php file say? Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 31, 2007 Share Posted January 31, 2007 [code]<form action="myphp.php">[/code] the default form method is GET not POST... try changing the above for [code]<form action="myphp.php" method="post">[/code] Quote Link to comment Share on other sites More sharing options...
corbin Posted January 31, 2007 Share Posted January 31, 2007 You're just seeing the PHP source? Is it named .php? Does your webserver support PHP?To make it sent through post instead of get (the address bar) put method="POST" in the form fthing...Once you have all that figured out, I, or someone else can help you with the file writing.Someone else posted while I was typing... But oh well :p Quote Link to comment Share on other sites More sharing options...
vipes Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=corbin link=topic=124633.msg517634#msg517634 date=1170209227]You're just seeing the PHP source? Is it named .php? Does your webserver support PHP?To make it sent through post instead of get (the address bar) put method="POST" in the form fthing...Once you have all that figured out, I, or someone else can help you with the file writing.Someone else posted while I was typing... But oh well :p[/quote]i did that, and its still showing the php and yes its named .php and yes it supports php...the box that its ran on is actually owned by dho if anyone knows who that is....anyways, idk why it isnt working...its really getting annoying. Quote Link to comment Share on other sites More sharing options...
vipes Posted January 31, 2007 Author Share Posted January 31, 2007 btw this is the php im using$username = $_POST['username'];$handle = fopen('data.txt', 'w+');if(fwrite($handle, "<>".$username)){echo "Wrote content.";}else{echo "Failed writing content.";}is there anything in that that should be changed to log the username and password? Quote Link to comment Share on other sites More sharing options...
corbin Posted January 31, 2007 Share Posted January 31, 2007 w+ empties the files everytime it opens it... And you aren't logging a password obviously, but in theory that code should work. Quote Link to comment Share on other sites More sharing options...
vipes Posted January 31, 2007 Author Share Posted January 31, 2007 should it be a? i was just fooling around with the fopen commands [IMG]http://img.photobucket.com/albums/v198/THEUSEDLOVER/everytime.jpg[/img]it does this whenever i click login Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 31, 2007 Share Posted January 31, 2007 Have you checked that you have writing permissions on the folder you're writing to? Quote Link to comment Share on other sites More sharing options...
vipes Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=rantsh link=topic=124633.msg517654#msg517654 date=1170210486]Have you checked that you have writing permissions on the folder you're writing to?[/quote]yup, checked, i do =/ Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 31, 2007 Share Posted January 31, 2007 can you post the complete code? Quote Link to comment Share on other sites More sharing options...
Hypnos Posted January 31, 2007 Share Posted January 31, 2007 [quote]but basically i have a form I want to send the info thats put into the form sent to a text file.Like Login: Password: i want those 2 variables sent to a text file.[/quote]Am I the only one that thinks this is most likely for phishing? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 I concur. Quote Link to comment Share on other sites More sharing options...
rantsh Posted January 31, 2007 Share Posted January 31, 2007 In any case he could still use a DB... Even if it is, none of us know what the others do with the knowledge we acquire at this forum... I personally think that anyone here could potentially be trying to learn so he/she can screw others...Either way, I don't think a kid that doesn't know how to build and handle a form and store the provided info can be a threat to anyone... at least not right now.Either way, I might be wrong... Or right... all I know is I've had enough of this thread, see you guys around Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.