Click to See Complete Forum and Search --> : has trouble in getting form data


milily
07-29-2003, 01:06 PM
I have a beginner in PHP. Now I have a very simple question. I have a form and have a submit button. After the user click the submit button, it will save the data in the text file. But now the data in the text area just doesn't go to the file. the file is empty with a size of 0. I check the code again and again. But I didn't find anything wrong with it. Could anyone tell me? The following are the html code and the php code.

HTML:

<html>
<head>
<title>question1</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" topMargin="0" leftmargin="0">
<table cellspacing="0" cellpadding="0" border="0" width="800" height="600" bgcolor="#99cc99">
<tr>
<td valign="top" height="566" align="center"> <br>
<form name="question1" method="post" action="saveFunction.php">
<input type="text" name="a1">
<input type="submit" name="Submit" value="Submit">
</form>
</td>
</tr>
</table>
</body>
</html>


PHP:

<?php
$fileName = "answerFile.txt";
if (submit){

// open the file in append mode, if the file doesn't exist, create one
$handle = fopen ($fileName,'a+');
chmod ($fileName,0777);
fwrite($handle,$a1);

//close the file
fclose($handle);
}

?>



Thank you very much in advance.

pyro
07-29-2003, 01:15 PM
The problem could be the global variables are off. Take a look at http://www.webdevfaqs.com/php.php#globalvariables

milily
07-29-2003, 01:55 PM
Pyro , thank you so much. It is working now.

pyro
07-29-2003, 02:01 PM
You're welcome... Glad to see the http://www.webdevfaqs.com is coming in handy... We just put it live today!