session_start(); require_once("config.php"); if($_GET["action"] == "subscribe") { $fp = fopen("$db_file", "r"); $file_text = fread($fp, 999999); fclose($fp); $subscribers = explode(",",$file_text); foreach($subscribers as $subscriber) { if($subscriber == $_GET["email"]) { $result = 1; break; } else { $result = 0; } } if($result == 1) { print "The email you provided alreay exists. please try again"; } else { $fp = fopen("$db_file", "a+"); fwrite($fp, $_GET["email"] . ","); fclose($fp); print "You have been subscribed successfully."; } } print "
"; ?>