Jump to content

sending text from form to a file...


vipes

Recommended Posts

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.
Link to comment
Share on other sites

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");




goodluck

ps that doesnt iclude any validation
Link to comment
Share on other sites

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.php
if(fwrite($handle, "<>".$username)){
echo "Wrote content.";
}else{
echo "Failed writing content.";
}
[/code]

hope that helps.
Link to comment
Share on other sites

[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.php
if(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?
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

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
Link to comment
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.