Location: PHPKode > projects > OpenNewsletter > OpenNewsletter-2.5.1/includethis.php
<?
	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. <a href='javascript:history.back(-1)'>please try again</a>";
		}
		else
		{
			$fp = fopen("$db_file", "a+");
			fwrite($fp, $_GET["email"] . ",");
			fclose($fp);
			print "<font face=arial size=2 color=blue>You have been subscribed successfully.</font>";
		}
	}
	print "
	<form action='includethis.php'>
	<input type='text' name='email' size='26' value='Enter your email' onfocus=\"this.value=''\">
	<br>
	<input type='submit' value='Subscribe'>
	<input type='hidden' name='action' value='subscribe'>
	</form>
	";
?>
Return current item: OpenNewsletter