Jump to content

Want to automatically save the form data in txt format on to the server??


Recommended Posts

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.

 

 

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

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

 

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??

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

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.

 

 

 

 

 

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

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

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.