The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> save form data locally, saving html form data into text file
kjpr
post Sep 3 2013, 12:35 PM
Post #1





Group: Members
Posts: 7
Joined: 27-August 13
Member No.: 19,628



Hello all,

I am trying to save the input form data locally in a text file. I dont have access to the webserver. so, i am planning to save the data locally at first and then change the path , once i get the access.
the issue i have here is that i am not able to open a text file and write the inputs into it..i am pasting my code.Please take a look at it and let me know where i am going wrong..
CODE

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script>

</style>
<script type="text/javascript">
  $(function(){
  
     $('form').submit(function(event){
   event.preventDefault();
   window.location = $('input[type=radio]:checked').val();
   });
   });
</script>
<script>
//  put the data into a file in the current directory called "data.txt"

if (isset($_POST['submit'])) {

// Put the contents of the forms into the file
   file_put_contents('./data.txt', $_POST['url'], FILE_APPEND);
   file_put_contents('./data.txt', $_POST['Dataset'], FILE_APPEND);
   file_put_contents('./data.txt', $_POST['checkbox1'], FILE_APPEND);
   file_put_contents('./data.txt', $_POST['checkbox2'], FILE_APPEND);
   file_put_contents('./data.txt', $_POST['checkbox3'], FILE_APPEND);
   file_put_contents('./data.txt', $_POST['checkbox4'], FILE_APPEND);
   file_put_contents('./data.txt', $_POST['checkbox5'], FILE_APPEND);
  

}
</script>


</head>


<body>
<div id="stylized" class="myform">
<form name="form" method="post" action="">

<label> New Data set: </label>

    <input type="radio" name="url" value="Inputs1.html"/> Yes
    <input type="radio" name="url" value="ResultsPage.html"/> No
    
<br><br>
<label>Dataset description:
</label>
<input type ="text" name= "Dataset" size="30"><br><br><br>
<table id="Previous Datasets">
  <tr>
    <th>Check</th>
    <th>Token Number</th>
    <th>Dataset description</th>
  </tr>
  <tr>
    <td><input type="checkbox" name="checkbox1"></td>
    <td>234567</td>
    <td>MHEX North America Dataset</td>
  </tr>
  <tr>
    <td><input type="checkbox" name="checkbox2"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="checkbox3"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="checkbox4"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td><input type="checkbox" name="checkbox5"></td>
    <td></td>
    <td></td>
</tr>
</table>
<div style="text-align: center"><br>
  <input type="Submit" name="submit" value="Submit" class="submit">
<div class="spacer"></div>
</form>
</div>
</body>


Thanks in advance
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th March 2019 - 05:43 AM