Here are a few steps to try:
Go to your favourite text editor and open the file, what do you see?
If the contents are there then go back to your script and read the file using *file_get_contents(filename)*
graeme
Patrick Roane wrote:
I created a form that asks for the users 1st and last name. I than try and attempt to save this data to a file. Next, I'd like to read the data from this file and write its contents to the browser.
I only get so far before I get a wierd response after
hitting the submit button:
Resource id #3
See code below:
<?php $firstnm = $_POST['firstnm']; //creates 1st var $lastnm = $_POST['lastnm']; //create 2nd var
$filename = "names.txt"; //creates file to write the
//above variable values to
print "writing to $names.txt";
$fp = fopen( "names.txt", "w" ) or die("couldn't open $names"); //opens the file I created fwrite( $fp, "$firstnm\n" , "$lastnm"); //I don't know //if this is right, but I attempt to write the //variables to the file //here. fclose( $fp ); //close the file print "$fp_names"; //attempt to print the files //contents to the browser here- but it does not work $contents = file_get_contents( "names.txt" ); //attempts to read from file print "$contents"; //attempts to display contents to //browser
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict/EN" "http://www/w3/org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>form</title>
</head> <body> <h1> <?php print "$fp" ?> </h1> <form method="post" action="<?php print $_SERVER['PHP_SELF']?>"> <p> Type your 1st name here: <input type="text" name="firstnm" /><br /> Type your last name here: <input type="text" name="lastnm" /><br /> <p><input type="submit" value="submit" /></p>
</p> </form> </body> </html>
=====
---------------- "forget your lust for the rich man's gold. All that you need, is in your soul. You can do this if you try. All that I want for you my son, is to be satisfied"
~ Lynard Skynard
-- Experience is a good teacher, but she sends in terrific bills.
Minna Antrim