I need some serious help...

Uber_Tiny

New member
First of all yes, I know this should be in the programmers section, but it's dead and no one reads anything in there. Putting it in OT would get more bright minds to see it.

I am trying to create a form to submit data to a .txt or .csv file on a network without interrupting/deleting the data that's already written in the file. Now I understand I can do this by using an "fwrite" function in php for the submit button, but I haven't any clue how to do that. Plus the tricky part, we need to save the information in the forms to a certain .txt or .csv file as per what drop down field was selected.

Like this:
Drop down selected as "tool feedback" saves textarea+input to toolfeedback.txt or .csv
Drop down selected as "general feedback" saves textarea+input to genfeedback.txt or .csv

and so on...

If anyone here has any information on how to do this I really need your help please!<3
 
I guess you could open the file, go to the end of it, and then write into it and close it? By using this and fwrite?

As for the drop down menu, that component should obviously return a value of what file is selected, and then you can take that and create a file address string which you will use to open the needed file.

Ok, it should be something like this:

String selectedItem = dropDownMenu.getSelected();
String fileIWantToEdit = "address of the file withouth the filename" + "selectedItem";

fopen fileIWantToEdit with the a+ parameter;

String textIWantToPasteIntoTheFile = textBox.getText();

fwrite into fopen textIWantToPasteIntoTheFile

Or something along those lines... :)
 
Last edited:
I guess you could open the file, go to the end of it, and then write into it and close it? By using this and fwrite?

As for the drop down menu, that component should obviously return a value of what file is selected, and then you can take that and create a file address string which you will use to open the needed file.
I found that page, but I couldn't figure out how to get the form and the .php to work together. Maybe I'm just that tired, but I am at a loss. :embarrased:
 
Well, there's also this.
I think I just need to sit down and read over this more tonite. I was a bit tired and everything was getting mixed up in my head and not making any sense lastnight. After taking a few minutes between calls today to read through some of this I was able to recognize the functions and how it works and now it seems to make more sense to me. Hopefully I am not working on this all weekend though.
 
I think I just need to sit down and read over this more tonite. I was a bit tired and everything was getting mixed up in my head and not making any sense lastnight. After taking a few minutes between calls today to read through some of this I was able to recognize the functions and how it works and now it seems to make more sense to me. Hopefully I am not working on this all weekend though.

So the thing that I wrote above doesn't work? I haven't done PHP, truth be told (I do JSF).
 
I'm looking to do this without scripting if at all possible. The files is going to be an .hta program. Simple is better, but this is proving to be a little less than simple.

What I have so far:
contact form
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Feeback beta 0.01</title>

<HTA:APPLICATION 
        ID="oHTA"
        APPLICATIONNAME="Feeback ."
        BORDER="thin"
        BORDERSTYLE="normal"
        CAPTION="yes"
        ICON="http://www.hp.com/favicon.ico"
        MAXIMIZEBUTTON="no"
        MINIMIZEBUTTON="yes"
        SHOWINTASKBAR="yes"
        SELECTION="NO"
        SINGLEINSTANCE="yes"
        SYSMENU="yes"
        VERSION="1.0"
        WINDOWSTATE="normal"/>


<script LANGUAGE="VBScript">

'Change WindowSize
Self.ResizeTo 500, 500

</script>

</head>

<body>
<form name="input" action="D:\feedback\feedback.php" method="post">

Your name: <br>
<input type="text" name="Name: "><br>

Your Oracle: <br>
<input type="text" name="Oracle: "><br>

Your Feeback: <br>
<textarea name="Feeback" rows="15" cols="50"></textarea><br><br>

<input type="submit" value="Submit">
 
</form>
</body>
</html>
PHP write form
Code:
<?php

$writetocsv = $_POST['input'] . "," . $_POST['field2'] . "," . $_POST['field3'];

$fp = fopen [php.net]("D:\feedback\feedback.csv","a");

fwrite [php.net]($fp,$writetocsv);

fclose [php.net]($fp);

?>
Problem with this is that it is not writing to the .csv file.
 
Last edited:
Okay, so I figured out more about what it is that I need to do.

Layout;

Name: (input)
Oracle: (input)
List: (drop down selection)
Feedback: (text area)
[submit]

It looks like jquery is going to be what works best for this since it doesn't require DB access like .php does apparently. I also found out that it needs to have a date and time appended to each submission to which ever .csv file is associated to the drop down selected which may complicate things a bit more. This has now gone way beyond my ability's. If anyone here knows how to put this together I would be willing to pay you something through paypal for your work.

Anyone willing to help me out and teach me how to do this?
 
PHP doesn't need db access at all.
And you can't write to files with jQuery.


I'm not entirely clear what tools you have to work with and what the ultimate outcome should be. Do you have a web server with PHP installed? Do the files have to be accessed by multiple people.
Could you clarify a bit what it is exactly that needs to be achieved.

If you do not have a web server with PHP installed your best bet is vbscript and you can write that in an .hta file. You can make a windows share that has the necessary permissions and contains the txt or csv files and you can make vbscript write to those files.
Maybe it was vbscript that I was thinking of. I've been looking at way to many different coding formats...

No I do not have access to a server for the php.

Ultimate outcome would be a form that writes to a .csv on the network with a date and time attached per entry. Not to create a new .csv file, but append to it.

Yes, multiple people need to access the feedback form at the same time which shouldn't be of any issue. When it comes to writing to the .csv file, yes that will need to be written to by multiple people at the same time. So there may need to be a check to make sure the form is ready to be written to.

As for the tools, notpad++, Dreamweaver whatever else is necessary.

Trying to achieve feedback information (.csv files) that are written to as per the drop down selected in the feedback form.
 
This is what I figured out now with the vbscript.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Feeback beta 0.01</title>

<HTA:APPLICATION 
        ID="oHTA"
        APPLICATIONNAME="Feeback ."
        BORDER="thin"
        BORDERSTYLE="normal"
        CAPTION="yes"
        ICON="http://****"
        MAXIMIZEBUTTON="no"
        MINIMIZEBUTTON="yes"
        SHOWINTASKBAR="yes"
        SELECTION="NO"
        SINGLEINSTANCE="yes"
        SYSMENU="yes"
        VERSION="1.0"
        WINDOWSTATE="normal"/>


<script LANGUAGE="VBScript">

'Change WindowSize
Self.ResizeTo 500, 500

</script>

</head>

<body>
    
    <script language="VBScript">

DateTime= Now      'GET CURRENT TIME

Sub APPEND_FILE

    Set objFSO = CreateObject("Scripting.FileSystemObject")  'CREATES FILE SYSTEM OBJECT

    Set contents = Document.getElementById("textbox")  'SETS CONTENTS TO POINT TO FORM DATA NAME=textbox

        WriteRow = DateTime & ","  'WRITE CURRENT TIME IN VARIABLE WRITEROW

        WriteRow = Writerow & replace(trim(contents.value),",",";") & ","     'ADD THE VALUE OF THE TEXT REMOVING LEADING/TRAILING SPACES

        WriteRow = replace(WriteRow,chr(13)," ")     'REMOVE CARRIAGE RETURN CHARACTERS

        WriteRow = replace(WriteRow,chr(10)," ")    'REMOVE LINE FEED CHARACTERS

        WriteRow = trim(WriteRow)     'REMOVE LEADING AND TRAILING SPACES

        'vFilename = "D:\feedback\FILE.csv"    SETS THE FILENAME AND PATH VARIABLE FOR NETWORK USE
        vFilename = "C:\FILE.csv"         'SETS THE FILENAME AND PATH VARIABLE FOR LOCAL USE

    Set objFile = objFSO.OpenTextFile(vFilename, 8,true,0)     'OPENS TEXT FILE FOR EDITING

        objFile.WriteLine WriteRow       'WRITES THE ENTIRE CONTENTS OF THE WRITEROW VARIABLE ON A NEW LINE

        objFile.Close    'SAVES AND CLOSES THE TEXT FILE

End Sub

</script>

<BODY> 

<div>

    <textarea rows="5" name="textbox"></textarea> 

        <input type="button" Value="Submit" onclick="APPEND_FILE()">

</div>

</body>
</html>
Getting an error when it tries to write though. Saying line 58 which is
Code:
Set objFile = objFSO.OpenTextFile(vFilename, 8,true,0)     'OPENS TEXT FILE FOR EDITING
I think I am getting a bit closer...maybe...hopefully.
 
Last edited:
Weird, when I tried it on my computer it created the file.csv on my c: drive and wrote the text in the textarea and the date into the csv.

Do you have the necessary rights to write to the C drive?
Made sure that C drive has the permissions. I changed the drive letter to another drive and it finally wrote to the file. So apparently I have to write permissions set for the C drive and I have no idea where to change that since it already has the permissions. grrr

Now that I have that part working...finally...I get to ad some more text fields and a drop down and then code it to save to a .csv file as per drop down selection. I can see that being another irritating task. :(
 
WOOHOO!!1!

I have done it. :yahoo:

Code:
<HTML>

<HEAD>

<script language="VBScript">

DateTime= Now

Sub APPEND_FILE

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set csvfilename = Document.getElementById("filename")

Set vName = Document.getElementById("name")

Set vNumber = Document.getElementById("number")

Set contents = Document.getElementById("textbox")

WriteRow = DateTime & ","

WriteRow = Writerow & replace(trim(vName.value),",",";") & ","

WriteRow = Writerow & replace(trim(vNumber.value),",",";") & ","

WriteRow = Writerow & replace(trim(contents.value),",",";") & ","

WriteRow = replace(WriteRow,chr(13)," ")

WriteRow = replace(WriteRow,chr(10)," ")

WriteRow = trim(WriteRow)

vFilename = "D:\feedback\" & csvfilename.value

Set objFile = objFSO.OpenTextFile(vFilename, 8,true,0)

objFile.WriteLine WriteRow

objFile.Close

End Sub

</script>

</HEAD>

<BODY>

<div>

<strong>Choose File:</strong>

<select id="filename" TABINDEX=1>

<option value="" selected>Select a File</option>

<option value="Feedback.CSV">Feedback</option>

<option value="Tools.CSV">Tools</option>

<option value="Other.CSV">Other</option>




</select>

<br>
<strong>Name:</strong>

<input type="text" id="name" TABINDEX=2>

</input>

<br>

<strong>Number:</strong>

<input type="text" id="number" TABINDEX=3>

</input>

<br>

<strong>Textarea:</strong>

<textarea rows="5" name="textbox"></textarea>

<input type="button" Value="Submit" onclick="APPEND_FILE()">

</input>

</div>

</BODY>

</HTML>
 
Great job :up:

Note that you can use UNC paths in vbscript. So the csv files can reside on some windows share that you have the necessary rights to e.g. \\share\file.csv

Nice work :)
Thank you!

The finalized code if anyone else wants to use it:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<HTML>

<HEAD>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Feeback Beta 0.5</title>

<HTA:APPLICATION 
        ID="oHTA"
        APPLICATIONNAME="Feeback ."
        BORDER="thin"
        BORDERSTYLE="normal"
        CAPTION="yes"
        ICON="http://www.*your address goes here*/favicon.ico"
        MAXIMIZEBUTTON="no"
        MINIMIZEBUTTON="yes"
        SHOWINTASKBAR="yes"
        SELECTION="NO"
        SINGLEINSTANCE="no"
        SYSMENU="yes"
        VERSION="1.0"
        scroll="no"
        WINDOWSTATE="normal"/>

<script language="VBScript">

'Change WindowSize
Self.ResizeTo 440, 510

DateTime= Now

Sub APPEND_FILE

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set csvfilename = Document.getElementById("filename")

Set vName = Document.getElementById("name")

Set vNumber = Document.getElementById("number")

Set contents = Document.getElementById("textbox")

WriteRow = DateTime & ","

WriteRow = Writerow & replace(trim(vName.value),",",";") & ","

WriteRow = Writerow & replace(trim(vNumber.value),",",";") & ","

WriteRow = Writerow & replace(trim(contents.value),",",";") & ","

WriteRow = replace(WriteRow,chr(13)," ")

WriteRow = replace(WriteRow,chr(10)," ")

WriteRow = trim(WriteRow)

vFilename = " *YOUR NETWORK DRIVE GOES HERE* " & csvfilename.value

Set objFile = objFSO.OpenTextFile(vFilename, 8,true,0)

objFile.WriteLine WriteRow

objFile.Close

End Sub

</script>

</HEAD>

<BODY background="bg.jpg">
<FONT SIZE="4" FACE="courier" COLOR=Yellow><MARQUEE WIDTH=100% BEHAVIOR=ALTERNATE BGColor=>Your feedback is important to us!</MARQUEE></FONT>
<div>

<strong>Choose Reason:</strong>
<br />

<select id="filename" STYLE="background-color: #CEDDE8" TABINDEX=1>

<option value="notselected.CSV" selected>Select Reason</option>

<option value="Feedback.CSV">Feedback</option>

<option value="Tools.CSV">Tools</option>

<option value="Other.CSV">Other</option>

</select>

<br />
<strong>Name:</strong><br />

<input type="text" STYLE="background-color: #CEDDE8" id="name" TABINDEX=2>

</input>

<br />

<strong>Oracle Number:</strong><br />

<input type="text" STYLE="background-color: #CEDDE8" id="number" TABINDEX=3>

</input>

<br />

<strong>Textarea:</strong><br />

<textarea rows="15" cols="50" name="textbox" style="overflow:hidden; background-color: #CEDDE8"></textarea>
<br />
<br />

<input type="button" Value="Submit" onclick="APPEND_FILE()">

</input>

</div>

</BODY>

</HTML>
 
Back
Top