file handling functions
Posted: Tue Aug 18, 2009 3:54 am
how am i going to save and view records from a textbox to text file (notepad)?
here's my code for saving record but it only creates text file but it doesn't save the record.
in this code im only testing the name record
<html>
<body>
<form>
<form method = "POST" action = "mp05.php" action2 = "mp05.php">
Name
<input type = "text" name = "name"><br><br>
Address
<input type = "text" name = "address"><br><br>
Course
<input type = "text" name = "course"><br><br>
Contact
<input type = "text" name = "contact"><br><br>
Email
<input type = "text" name = "email"><br><br>
<input type = "submit" value = "View" name = "action">
<input type = "submit" value = "Save" name = "action2">
<?PHP
if(isset($_POST['action2']));
$name = $_POST['name'];
$address = $_POST['address'];
$course = $_POST['course'];
$contact = $_POST['contact'];
$email = $_POST['email'];
$file = fopen ("studinfo.txt","a");
fwrite($file,$name);
fclose($file);
?>
</form>
</body>
</hmtl>
here's my code for saving record but it only creates text file but it doesn't save the record.
in this code im only testing the name record
<html>
<body>
<form>
<form method = "POST" action = "mp05.php" action2 = "mp05.php">
Name
<input type = "text" name = "name"><br><br>
Address
<input type = "text" name = "address"><br><br>
Course
<input type = "text" name = "course"><br><br>
Contact
<input type = "text" name = "contact"><br><br>
Email
<input type = "text" name = "email"><br><br>
<input type = "submit" value = "View" name = "action">
<input type = "submit" value = "Save" name = "action2">
<?PHP
if(isset($_POST['action2']));
$name = $_POST['name'];
$address = $_POST['address'];
$course = $_POST['course'];
$contact = $_POST['contact'];
$email = $_POST['email'];
$file = fopen ("studinfo.txt","a");
fwrite($file,$name);
fclose($file);
?>
</form>
</body>
</hmtl>