php form - flat file help pls?

rskha

New member
I had posted a question earlier and received a very good answer on how to store an html form within a table. But it involved php which I never used. I understood the first part and i tried it and it worked. but when I click submit, a blank page comes up. That is because I am doing the last sytax part wrong. firstly, I do not know where to store the last part and how to save it. what will it be saved as?

//I did this and it worked:

ANSWER:
<form action="process.php" method="post">
<input type="text" name="custID" />
<input type="submit" value="Submit Me" />
</form>

In the action file (in this case process.php) you need to access these form values:
<?php
$customerID = $_POST['custID'];
?>


//This is the part which is probably giving me trouble, I don't know where to add this syntax.

Next you will need to store it somewhere. Databases are preferable, but you can also write it to text files and the like:

<?php

//file method
$myFile = "customerFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $customerID);
fclose($fh);
?>
 
Back
Top