<html>
<head>
<title>Subscribe</title>
</head>
<body>
<?php
if (is_readable('names.inc')){
$myFile = "names.inc";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
}else{
die("Could not read file. please <a href='mailto:[email protected]?subject=Subscribe to list: Can not read list'>contact support</a>");
}
if ( !$_POST['name'] ){
?>
<form target="_self" method="post">
Enter Your Name: <input type="textbox" name="name" /><input type="submit" value="Save" />
</form>
<?php
}else{
$name=$_POST['name'];
$values = "'$name',";
$exist = strpos($theData, $values);
if ( !$exist ){
$fp = fopen("names.inc", "a") or die("Could not save. please <a href='mailto:[email protected]?subject=Subscribe to list: Can not save list'>contact support</a>");
$numBytes = fwrite($fp, stripslashes($values)) or die("Couldn't write values to file!");
fclose($fp);
echo "You [$name] have been added to the list";
}else{
$fp = fopen("names.inc", "w") or die("Could not save. please <a href='mailto:[email protected]?subject=Subscribe to list: Can not save list'>contact support</a>");
$list = str_replace("$values", "", $theData);
$numBytes = fwrite($fp, stripslashes($list)) or die("Couldn't write values to file!");
fclose($fh);
echo "You [$name] were found on the list & have been removed";
}
}
?>