Jump to content

Storing Variables In Txt File - Very Simple Question


chan95

Recommended Posts

Hi I'm trying to make a PHP file called store.php which stores the variables that are passed to it in a text file called data.txt. I want to make it so that if a user goes to http://www.mysite.com/store.php?myname=chan&myage=24, it will store myname and myage in that data.txt file. Could someone please help me do this?

Use a database instead.

 

Ken

 

Ok but I would rather just use a text file. Could you please tell me how to store the values in this text file? So far I have:

 

<html>
<head>
<title>My Variables PHP Script</title>
</head>
<body>
<p>The query string is: <?php echo $_SERVER['QUERY_STRING']; ?></p>
<p>Myname: <? echo $_REQUEST['myname'] ?></p>
<p>Myage: <? echo $_REQUEST['myage']; ?></p>
<?php
$handle = fopen("data.txt", "a");
fwrite($handle, "myname: $_REQUEST[1]");
fwrite($handle, "myage: $_REQUEST[2]");
fclose($handle);
?>
</body>
</html>

 

But this code does not work.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.