Location: PHPKode > projects > MyVPN OpenVPN Web Config > http_doc/add_member.php
<?php
include('login.php');
include('lib/conf.php');
include('lib/function.php');

$idcomm = $_GET["idcomm"];
$email = $_GET["email"];

$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);

$query = "SELECT * FROM COMM WHERE id = '$idcomm' AND uname_admin = '$user_name'";
$result = mysql_query($query)
or die("<br>Invalid query: $query\n<BR>\n" . mysql_error());
$fetch_em = mysql_fetch_array($result);
$numrows = mysql_num_rows($result);
if($numrows != "0") $admin=1;

$query = "SELECT * FROM COMM WHERE id = '$idcomm'";
$result = mysql_query($query)
or die("<br>Invalid query: $query\n<BR>\n" . mysql_error());
$row = mysql_fetch_array($result);

if ((($row['type_comm']==NOTPUB) && ($admin==1)) || ($row['type_comm']==PUB)) {
	
// validate email
	if(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'. '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email)) {
		echo "The email is not valid! Try again...<br>";
		echo "<a href=\"javascript:history.back();\">Go back</a>";
		exit();
	}
	
	$hash=md5($email.$hidden_hash_var);
	
// veryfy if that user havn't got invitation already
	$query = "SELECT * FROM `MEMB` where id1='$idcomm' AND hash='$hash'";
	$result = mysql_query($query)
	or die("<p align=\"left\">Invalid query: $query\n</p>\n" . mysql_error());
	$fetch_em = mysql_fetch_array($result);
	$numrows = mysql_num_rows($result);
	if($numrows != "0") {
		echo "This user has got invitation or subscribed already!<br>";
		echo "<a href=\"javascript:history.back();\">Go back</a>";
		exit();
	}

	
// verify if comunity have space	
	$query ="SELECT * FROM `COMM` WHERE id='$idcomm'";
	$result=mysql_query($query)
	or die("<br>Invalid query: $query\n<BR>\n" . mysql_error());
	$row = mysql_fetch_array ($result);
	if ($row["tot_usr"]==$row["max_usr"]) {
		echo "Unfortunately, the community is full!<br>";
		echo "<a href=\"javascript:history.back();\">Go back</a>";
		exit();
	}
	
	$query = "INSERT INTO `MEMB` (`id`, `id1`, `ip_num`, `confirmed`, `hash`) VALUES ('', '$idcomm', '', '0', '$hash');";
	mysql_query($query)
	or die("<br>Invalid query: $query\n<BR>\n" . mysql_error());
	//mysql_close($conn);
	
	$message = "You are invited to join to the VPN Community".
"\nSimply follow this link to confirm your membership: ".
"\n\nhttp://ovpnwc.sourceforge.net/memb_confirm.php?hash=$hash&idcomm=$idcomm&email=". urlencode($email).
"\n\nOnce you confirm, you can use the services on VPN COMMUNITY.";
	$query = "INSERT INTO email VALUES (null, '$email', 'Confirm your membership to VPN Community', '$message');";
	mysql_query($query)
	or die("<br>Invalid query: $query\n<BR>\n" . mysql_error());
	//mail ($email,'Confirm your registration to VPN Community',$message,'From: hide@address.com');
	echo "A Email will be sent to $email in a minute!";
	redirect("index.php?pag=myaccount", 5);
}
?>
Return current item: MyVPN OpenVPN Web Config