Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-13-2008, 03:50 AM   PM User | #1
van21691
New Coder

 
Join Date: Oct 2006
Posts: 68
Thanks: 3
Thanked 0 Times in 0 Posts
van21691 is an unknown quantity at this point
PHP Submit

I do not know what its called but basically it is a form. It is more than a form.
It's hard to explain.
Let's say that I have two files: info.txt/info.dat and form.php.
In form.php, I have the form code, then when you view it and test it and make something up. I want all the data that was submit to go inside the info.txt file.

If i am not clear, please reply. Thank you

BTW: this is not to phish someone, but this is for my school club website that I am doing.

Last edited by van21691; 04-13-2008 at 03:59 AM..
van21691 is offline   Reply With Quote
Old 04-13-2008, 03:54 AM   PM User | #2
Iszak
Regular Coder

 
Iszak's Avatar
 
Join Date: Jun 2007
Location: Perth, Western Australia
Posts: 332
Thanks: 2
Thanked 58 Times in 57 Posts
Iszak is an unknown quantity at this point
You'll want to the fread, fwrite commands, this way you can save data into the file, but I'll have a character that seperates each submit like a linebreak or something so when you're parsing it you can seperate it.
Iszak is offline   Reply With Quote
Old 04-13-2008, 03:55 AM   PM User | #3
van21691
New Coder

 
Join Date: Oct 2006
Posts: 68
Thanks: 3
Thanked 0 Times in 0 Posts
van21691 is an unknown quantity at this point
could you post on how would I do that.
Thank you
van21691 is offline   Reply With Quote
Old 04-13-2008, 05:15 AM   PM User | #4
van21691
New Coder

 
Join Date: Oct 2006
Posts: 68
Thanks: 3
Thanked 0 Times in 0 Posts
van21691 is an unknown quantity at this point
This is what I got from the net. Basically, what this do is after you hit submit, it will replace whatever is in the info.dat. What I want is instead of replacing what is in the info.dat, I want to put more
PHP Code:
<?
$newcontents
="This
is my content"
//
$filename="info.dat";

$fp fopen ($file_name"w");


fclose ($fp);

chmod($file_name,0777);

?>
<html>
<head>
<title>File Editor Test</title>
</head>
<body>
<h1>File Editor Test</h1>

<?php
$newcontents 
$contents;
if(isset(
$_POST['submit'])) { //if submit was pressed
$writefh fopen($filename"w"); //File handle for $filename

if(get_magic_quotes_gpc()){
$newcontents=stripslashes($_POST['editcontents']);
//strips unneeded backspaces by magicquotes
else{
$newcontents $_POST['editcontents'];
}

//NEXT 3 LINES ARE THE PROBLEM SPOT:
fwrite($writefh$newcontentsstrlen($newcontents)); //Saves changes
rewind($readfh); //resets cursor in file

echo("The changes were saved.<br/>\n");
fclose($writefh);
}
?>
Edit the file here:
<form method="post" action="<? echo($PHP_SELF); ?>">
<textarea name="editcontents" style="width:400px; height:150px;"><? echo($newcontents); ?></textarea>
<br />
<input type="submit" name="submit" value="Save Changes" />


</form>
</body>
</html>
van21691 is offline   Reply With Quote
Old 04-13-2008, 05:32 PM   PM User | #5
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Change this
PHP Code:
$fp fopen ($file_name"w"); 
to this
PHP Code:
$fp fopen ($file_name"a+"); 
There are other things you could use. I suggest you read the manual on whats available.
http://us.php.net/manual/en/function.fopen.php
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 04-14-2008, 12:16 AM   PM User | #6
van21691
New Coder

 
Join Date: Oct 2006
Posts: 68
Thanks: 3
Thanked 0 Times in 0 Posts
van21691 is an unknown quantity at this point
thanks for the help. i got it now
Thank you
van21691 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:56 AM.


Advertisement
Log in to turn off these ads.