Anyone of you can help me: Form handling, write to File
Posted: Sat Dec 26, 2009 12:20 am
sorry im a total noob to php and i am running in circles trying to get this to work. i basically followed http://www.tizag.com/phpT/filewrite.php and put an "a" instead of "w" . but when the php is called after the form is submitted i get a "can't open file" on my browser and the file im trying to write to(registry.txt) is completely unedited... no clue what's wrong, can anyone tell me please? Many thanks
"form.processed.php":
The html form that forwards the info seems to work but here it is anyways("formCheck" is my validation Javascript):
"form.processed.php":
Code: Select all
<?php
$myFile="registry.txt";
$fh =fopen($myFile, 'a') or die("can't open file");
$stringData=$_GET['FirstName'];
fwrite($fh, $stringData);
$stringData=$_GET['LastName'];
fwrite($fh, $stringData);
$stringData=$_GET['Email'];
fwrite($fh, $stringData);
$stringData=$_GET['Company'];
fwrite($fh, $stringData);
$stringData=$_GET['Phone'];
fwrite($fh, $stringData);
$stringData=$_GET['City'];
fwrite($fh, $stringData);
$stringData=$_GET['State\n'];
fwrite($fh, $stringData);
fclose ($fh);
?>Code: Select all
<form action="form.processed.php" name="formcheck" onsubmit="return formCheck(this);">
<table border=0>
<tr>
<td>First Name*: </td><td><input type=text name="FirstName" size="30"></td>
</tr>
<tr>
<td>Last Name*: </td><td><input type=text name="LastName" size="30"></td>
</tr>
<tr>
<td>E-mail*:</td><td><input type=text name="Email" size="30"></td>
</tr>
<tr>
<td>Company:</td><td><input type=text name="Company" size="30"></td>
</tr>
<tr>
<td>Phone:</td><td><input type=text name="Phone" size="30"></td>
</tr>
<tr>
<td colspan=2>Address</td>
</tr>
<tr>
<td>City:</td><td><input type=text name="City" size="15">State:<input type=text name="State" size="2"></td>
</tr>
</table>
<input type=submit value="Submit and Download Trial">
</form>
*Required Fields<br><br><br>