naveenbj Posted January 8, 2008 Share Posted January 8, 2008 Hello Friends, Im a student and new to php .Here is my question. Is it possible for me to automatically save the form data in a txt. file on server.and get the link on the next page. Please reply me with ur comments Regards , Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/ Share on other sites More sharing options...
priti Posted January 8, 2008 Share Posted January 8, 2008 Yes you can do that but you should have write access to the server you are trying to sacve you form elements. when you will post your form you will receive all info in $_POST .so you can open a file handle and write all data needed in the file. Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433370 Share on other sites More sharing options...
naveenbj Posted January 8, 2008 Author Share Posted January 8, 2008 Hello, But i dont hav any idea about the file handling So if you can help me that will be helpfull and appriciated:) Regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433372 Share on other sites More sharing options...
priti Posted January 8, 2008 Share Posted January 8, 2008 If you want me to code it for you then how you will learn let me give you some idea so you can explore more and if you find error which u cann't understand will definately help you to understand it. 1.create HTML oafe for your form there will be <form> tag something like <form name='frmname' action='action.php' method='post'> 2.create file action.php there foreach($_POST as $k=> $v) { echo $k .' value '.$v.'<br>'; } it will print all from fileds. 3. when you are clear all about this then inaction.php open file handle $f=fopen('filename','mode'); mode=r,w,a any which you want use fwrite to write data in file. instead of echoing it you have to write the chunk of data in file.how you will do spend sometime with it.i will post your a simple tutorials link to follow till then explore as above Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433378 Share on other sites More sharing options...
priti Posted January 8, 2008 Share Posted January 8, 2008 for file handling function reference use php.net below is direct link to fwrite and you will find related around it. http://in.php.net/manual/en/function.fwrite.php Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433380 Share on other sites More sharing options...
naveenbj Posted January 8, 2008 Author Share Posted January 8, 2008 Hello thanks for ur reply!! As you said i did that. I already created a form but in file handling ,im not as good. And one more thing ,in your 3rd point u wrote that "inaction.php open file handle" wht it means exactly?? i mean to say tht where i hav to place the file handling codes?? ---------- Did you get what i mean:) And even i have knolez about the file codes but how to handle thm is problem for you ,i mean where to put the code. Reagrds, Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433400 Share on other sites More sharing options...
priti Posted January 8, 2008 Share Posted January 8, 2008 hi, it has to be in your action.php file. referring your point in your 3rd point u wrote that "inaction.php its typo err its "in action.php" (refer form tag action="action.php") in action .php you have to open file handle. I didn't understand this "And even i have knolez about the file codes but how to handle thm is problem for you ,i mean where to put the code." -------if i ignore your typo errors even then why file handling is going to be a problem for me???????????????????????? your task is very small for me not even 10 min job for me.But because you have to learn then its your problem not mine. :-) R u expecting someone to give you a ready made code which you can try on your local?? Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433481 Share on other sites More sharing options...
naveenbj Posted January 8, 2008 Author Share Posted January 8, 2008 Hello thanks for reply!! I really agree with you but i jst need bit help on file handling bcoz this part is quite hard for me. And i dont want you or smone to do the complete code work for me .I just want bit help thaat i can use in my form.and only the file handle part except part of form is done. And you can only guide me on this no need to code for me. ---------------- Hope you get what i mean:) Best Reagrds Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433504 Share on other sites More sharing options...
trq Posted January 8, 2008 Share Posted January 8, 2008 So, take a look at the examples in the manual for fopen and fwrite. Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433515 Share on other sites More sharing options...
priti Posted January 8, 2008 Share Posted January 8, 2008 hmmm........ what you need is something like 1. $fp=fopen('file.txt','w'); 2. run the foreach loop create a single string $content='name=priti#language=php'; //any delimiter 3.fwrite($fp,$content,strlen($content); 4.fclose($fp); it sud solve your problem. Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433519 Share on other sites More sharing options...
naveenbj Posted January 8, 2008 Author Share Posted January 8, 2008 hello Thanks For Reply!! Sry but i still not able to find out wht to do Here is the form code for ur consideration <html> <head> <title>Form</title> </head> <body> <p><FONT FACE="Verdana, Arial, Helvetica, sans-serif, Trebuchet MS" SIZE="5" COLOR="#FF9999"> <B>This is a simple example of Data Displaying from a form </B> </FONT></p><form method="post" action="welcome.php"> <P><br> <BR></P><TABLE WIDTH="40%" BORDER="0" CELLSPACING="2" CELLPADDING="1" ALIGN="CENTER" BGCOLOR="#99CCCC"><TR> <TD WIDTH="121"> <P ALIGN="LEFT"><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000">First Name :-</FONT></I></B></P></TD> <TD WIDTH="487"> <P><B><I> <INPUT NAME ="name" TYPE="text" ><br /> </I></B></P></TD></TR><TR> <TD WIDTH="121"> <P><B><I> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> Last Name :-</FONT></I></B></P></TD> <TD WIDTH="487"> <P><B><I> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"><INPUT NAME ="lastname" TYPE="text" onkeypress="return handleEnter(this, event)"></FONT></I></B></P></TD></TR><TR> <TD WIDTH="121" HEIGHT="27"> <P><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000">Email : -</FONT></I></B></P></TD> <TD WIDTH="487" HEIGHT="27"> <P><B><I> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT NAME ="email" TYPE="text"></FONT></I></B></P></TD> </TR><TR> <TD WIDTH="121" HEIGHT="2"> <P><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000">Age:-</FONT></I></B></P></TD> <TD WIDTH="487" HEIGHT="2"> <P><B><I> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT NAME ="age" TYPE="text"> </FONT></I></B></P></TD></TR> <TR> <TD WIDTH="121"> <P><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> Gender:-</FONT></I></B></P></TD> <TD WIDTH="487"> <P><B><I> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT TYPE="radio" NAME="radiobutton" VALUE="male" onkeypress="return handleEnter(this, event)"> Male <INPUT TYPE="radio" NAME="radiobutton" VALUE="female" onkeypress="return handleEnter(this, event)">Female</FONT></I></B></P></TD></TR> <TR> <TD WIDTH="121"> <P><B><I><FONT COLOR="#FF0000">Address:-</FONT></I></B></P></TD> <TD WIDTH="487"> <P><B><TEXTAREA NAME="address"></TEXTAREA></B></P></TD> </TR><TR> <TD WIDTH="121"><B><I><FONT COLOR="#FF0000">Phone:-</FONT></I></B></TD> <TD WIDTH="487"><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT NAME ="phone" TYPE="text"></FONT></I></B></TD></TR> <TR> <TD WIDTH="121"><B><I><FONT COLOR="#FF0000">Mobile:-</FONT></I></B></TD> <TD WIDTH="487"><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT NAME ="mobile" TYPE="text"></FONT></I></B></TD></TR> <TR> <TD WIDTH="121"><B><I><FONT COLOR="#FF0000">Fax:-</FONT></I></B></TD> <TD WIDTH="487"><B><I><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT NAME ="fax" TYPE="text" onkeypress="return handleEnter(this, event)"></FONT></I></B></TD></TR> <TR> <TD WIDTH="121"> </TD> <TD WIDTH="487"><B><I> <FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#FF0000"> <INPUT NAME="submit" TYPE="submit"> <INPUT TYPE="reset" NAME="Submit" VALUE="reset"> </FONT></I></B></TD></TR></TABLE> <P> </P> <P> </P> </form> </body> </html> ----------------- Regards Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433535 Share on other sites More sharing options...
trq Posted January 8, 2008 Share Posted January 8, 2008 Look at the manual pages I posted and please DO NOT Multipost! You said you don't want people coding it for you, so start reading. Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433536 Share on other sites More sharing options...
naveenbj Posted January 8, 2008 Author Share Posted January 8, 2008 Regards Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-433615 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 Hello, Im still not able to find out the problem so any one can help me?? Regards, Nj Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-434360 Share on other sites More sharing options...
naveenbj Posted January 9, 2008 Author Share Posted January 9, 2008 can you help me to get output Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-434374 Share on other sites More sharing options...
priti Posted January 10, 2008 Share Posted January 10, 2008 Hmm According to you form you have welcome.php .write your logic to handle file here in welcome.php. i have almost given yout he code what you have to do it is read the whole post create an steps and put them in this file. and please read basic chapters for php handling.I think you need to understand how client-server carry on their session. regards Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-435276 Share on other sites More sharing options...
naveenbj Posted January 10, 2008 Author Share Posted January 10, 2008 Thanks for reply!! Quote Link to comment https://forums.phpfreaks.com/topic/84980-want-to-automatically-save-the-form-data-in-txt-format-on-to-the-server/#findComment-435382 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.