Location: PHPKode > projects > Top site PHP script > topsite/accept_reject.php
<?php
include('config.php');
//We check if its an admin and if the id is defined
if(isset($_SESSION['logged']) and isset($_GET['id']))
{
	$id = intval($_GET['id']);
	$req1 = mysql_query('select email,url from topsite where id="'.$id.'"');
	//We check if the website exists
	if(mysql_num_rows($req1)>0)
	{
		$req1 = mysql_fetch_array($req1);
		//If the admin accept the site
		if($_GET['ch']=='a')
		{
			//We change the status of the website in the DB
			if(mysql_query('update topsite set status="ok" where id="'.$id.'"'))
			{
				//We send an email
				if($mail)
				{
					$subject = 'Your website has been aproved in our Top site';
					$message = "Hy,
You receive this message to inform you that your website(".$req1['url'].") has been aproved in our Top site.
Yoi can start earning points by sharing the following link in your website:

<a href=\"".$url_root."vote.php?id=".$id."\">Vote for this Website</a>

Thank you";
					$to = $req1['email'];
					$headers = "From: \"Top site\"<".$mail_webmaster.">\n";
					$headers .= "Reply-To: ".$mail_webmaster."\n";
					$headers .= "Content-Type: text/plain; charset=\"utf-8\"";
					mail($to,$subject,$message,$headers);
				}
				//We redirect to the top site
				header('Location: '.$url_topsite);
			}
		}//If the admin reject the website
		elseif($_GET['ch']=='r')
		{
			//We delete the website from the DB
			if(mysql_query('delete from topsite where id="'.$id.'"'))
			{
				//We send an email
				if($mail)
				{
					$subject = 'Your website has been rejected from our Top site';
					$message = "Hy,
You receive this message to inform you that your website(".$req1['url'].") has been rejected from our Top site. For more details, contact us at ".$mail_webmaster.".
Thank you";
					$to = $req1['email'];
					$headers = "From: \"Top site\"<".$mail_webmaster.">\n";
					$headers .= "Reply-To: ".$mail_webmaster."\n";
					$headers .= "Content-Type: text/plain; charset=\"utf-8\"";
					mail($to,$subject,$message,$headers);
				}
				//We redirect to the top site
				header('Location: '.$url_topsite);
			}
		}//Otherwise, we delete the website from the DB
		else
		{
			//We delete the website from the DB
			if(mysql_query('delete from topsite where id="'.$id.'"'))
			{
				//We redirect to the top site
				header('Location: '.$url_topsite);
			}
		}
	}
}
?>
Return current item: Top site PHP script