<?php
include "datacon.php";
if (isset($_POST['Submit'])){
	$fname = $_POST['fname'];
$lname = $_POST['lname'];
$sname = $_POST['sname'];
$idno= $_POST['idno'];
$town = $_POST['town'];
$pnumber = $_POST['pnumber'];
$email= $_POST['email'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$county= $_POST['county'];
$dh= $_POST['dh'];
$bn = $_POST['bn'];
$ban = $_POST['ban'];
$bb = $_POST['bb'];
$bano = $_POST['banu'];
$mpesa = $_POST['mpesa'];
$amount ='500';
$password=md5 ('0000');
$Pic_Path1="Chatpics/" . $gender . ".gif";
$query = @mysql_query("select * from operators where   username= '$pnumber' OR idno='$idno' OR email='$email'  ")or die(mysql_error());
$count = mysql_num_rows($query);

if ($count > 0){ ?>

<script>
alert('Acount with the detail given already exist please go to login');
</script>
<?php
 header('location:index.php');
}else{
$qry = @mysql_query("select * from operators where  Username='$dh'  ")or die(mysql_error());
$count2 = mysql_num_rows($qry);
if($count2>0){
mysql_query("insert into operators (Username,Password,Pic_Path,email,fname,sname,lname,idno,gender,utown,county,country,destinyh,bname,bbranch,baccountname,baccountnumber,timestam,mpesa,status,amount,premium,thumbnails) 
values('$pnumber','$password','$Pic_Path1','$email','$fname','$sname','$lname','$idno','$gender','$town','$county','$country','$dh','$bn','$bb','$ban','$bano',NOW(),'$mpesa','pending','$amount','gold','uploads/NO-IMAGE-AVAILABLE.jpg')")or die(mysql_error());
mysql_query("insert into dhpayment(dhmobile,regmobile,status,time,amount) values('$dh','$pnumber','Pending',NOW(),'$amount')")or die(mysql_error());

mysql_query("insert into mpesa (code,sentby,paymentfor,amount) values('$mpesa','$pnumber','Registration','$amount')")or die(mysql_error());

//mysql_query("insert into operators_reg (userreged,regby) values('$pnumber','$dh')")or die(mysql_error());

mysql_query("insert into activity_log (date,username,action) values(NOW(),'$pnumber','New Member')")or die(mysql_error());


	$phonen=$pnumber;		
$messag= "Congrats%20".$fname."%20You're%20Now%20registered%20with%20Wealth%20-%20Club%20Login%20Details%20Username:%20".$pnumber."%20and%20password:%20'0000'%20.%20";
$sendsms ='http://sms.clarity.co.ke/sendsms.jsp?user=wealthmark&password=w@mark&mobiles='. $phonen .'&sms=' . $messag . ' &unicode=1&clientsmsid=10002&senderid=Wealthmark&version=3';
@$homepage = file_get_contents($sendsms);


 header('location:premium.php');
}
else {?>

<script>
alert('The Denstiny Helper Number you entered doesnt exist');
window.location = "signup.php";
</script>
<?php

}
}
}

?>