PDA

View Full Version : 3 textboxes to a text file [was "Can someone help please"]


shrekpete
05-12-2007, 05:34 PM
Hi,
I am required to save entries from 3 text boxes into a text file on clicking a submit button.

Can anyone help please.

Regards

Shrekpete

johnz
05-12-2007, 10:04 PM
Try this out.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title></title>
</head>
<body>
<?php
if(isset($_POST['save'])){
$filen = "savedinfo" . time() . ".txt";
$fh = fopen($filen, "w");
for($i=1; $i<=3; $i++){
fwrite($fh, $_POST['text' . $i] . "\r\n");
}
fclose($fh);
}
?>
<form action="" method="post">
<p><input type="text" name="text1" />
<input type="text" name="text2" />
<input type="text" name="text3" />
<input type="submit" name="save" value="Save" /></p>
</form>
</body>
</html>

shrekpete
05-13-2007, 05:51 AM
thanks, but i need to be able to specify the location of the text file.
also to link to another webpage on clicking button.

any ideas?

Shrekpete