<?php
ini_set('display_errors',1);
session_start();

include('script/condb.php');

/*session_start();
//include("script/condb.php");

// Change this to your connection info.
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'root';
$DATABASE_PASS = '';
$DATABASE_NAME = 'uplineappdb';
// Try and connect using the info above.
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
	// If there is an error with the connection, stop the script and display the error.
	exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}*/



//if($_SERVER["REQUEST_METHOD"] == "POST") {
if(isset($_POST['btnproj'])){
/*function generateRandomString($length = 10) {
   $randomString = sha1(uniqid(rand(), true));
   $randomString = substr($randomString, 0, $length);

   return $randomString;
}
$randomString = generateRandomString(5);*/
$id =rand(100, 1000);
$bui ="-build-";
$pro = "PROJECT".$id;

/*echo $dat ."<br/>";
echo $pro;*/

$project_type = $_POST['projecttype'];
$project_name = $_POST['projectname'];
$project_address =$_POST['projectaddress'];
$project_lga = $_POST['lga'];
$project_state =$_POST['state'];
$project_developer =$_POST['poweredby'];
$developer_website =$_POST['website'];
$developer_email = $_POST['email'];
$developer_phone = $_POST['telephone'];

$sql3 ="INSERT INTO upline_app_project_info(project_ref, project_type, project_name,project_address, project_location_lga,project_location_state,project_developer,project_developer_website,project_developer_email, project_developer_phone )VALUES('$pro', '$project_type', '$project_name','$project_address', '$project_lga', '$project_state', '$project_developer', '$developer_website', '$developer_email', '$developer_phone') ";

$checkmate=mysqli_query($con, $sql3);

if($checkmate){
	
	echo '<script language ="javascript" type= "text/javascript"> alert("Project number '.$pro.' has been created succesfull, proceed to Stage of project "); location.href="stagesofproject.php?id='.$pro.' ";</script>';
	
	}else{
	echo '<script language ="javascript" type= "text/javascript"> alert("project creation not succesful"); location.href="dashboard.php";</script>'; 
}


}





?>