Ok. Here is my description. I have three pages: createuser.php, updateprofile.php and deleteuser.php. They all share a common flat file database(not quite flat) which is database.php which looks like this:
PHP Code:
<?php exit(); ?>
#stores users in
#comma seperated
#values.
#format: username,password,email,zip,country
createuser.php looks something like this:
PHP Code:
<html>
<head>
</head>
<body>
<form name="testform" action="testcreate.php" method="POST">
UserName:<input type="text" name="name">
Email:<input type="text" name="email">
Password:<input type="text" name="password">
Zip:<input type="text" name="zip">
Country:<input type="text" name="country">
<input type="submit">
</form>
</body>
</html>
It gets to another file testcreate.php which stores the data using post to the file database.php. testcreate.php looks like this:
PHP Code:
<?php
$handle = fopen('database.php', 'a');
fwrite($handle, $_POST['name'].",".$_POST['password'].",".$_POST['email'].",".$_POST['zip'].",".$_POST['country']."\n");
fclose($handle);
echo "Please click <a href='login.php'>here</a> to go to the login page."
?>
This stores the data.
The deleteuser.php looks like this:
PHP Code:
#source php.net
<?
$key = $_POST["username"];
$fc=file("database.php");
$f=fopen("database.php","w");
foreach($fc as $line)
{
if (!strstr($line,$key))
fputs($f,$line);
}
fclose($f);
?>
The $_POST["username"] comes from a page deleteuser.html.
The problem I am having is I couldn't make a script to edit the profile of the user.
I need a script(descripted I am learning PHP not copying) which could let the users update their profile in the flat file database.
I hope I was able to clear my point.
Thanks.
Bookmarks