<?php

session_start();

error_reporting(0);

include('includes/dbconnection3.php');

if (strlen($_SESSION['clientmsaid']==0)) {

  header('location:logout.php');

  } else{

    if(isset($_POST['submit']))

  {



$clientmsaid=$_SESSION['clientmsaid'];

 $id=$_POST['id'];

 $username=md5($_POST['username']);

 $password=$_POST['password'];

 $created_at=$_POST['created_at'];

 $phonenumber=$_POST['phonenumber'];

 $uid=$_POST['uid'];

 $name=$_POST['name'];

 $age=$_POST['age'];

 $vehicletype=$_POST['vehichletype'];

 $model=$_POST['model'];

 $batterytype=$_POST['batterytype'];

 $details=$_POST['details'];

 $jpg=$_POST['jpg'];

 $number=$_POST['number'];
 $min_vol=$_POST['min_vol'];
 $max_vol=$_POST['max_vol'];
 $type=$_POST['type'];




 

$sql="insert into usersbike(id,username,password,created_at,phonenumber,uid,name,age,vehicletype,model,batterytype,details,jpg,number,min_vol,max_vol,type)values(:id,: username,: password,: created_at,: phonenumber,: uid,: name,: age,: vehicletype,: model,: batterytype,: details,: jpg,: number,: min_vol,: max_vol,: type)";

$query=$dbh->prepare($sql);

$query->bindParam(':id',$id,PDO::PARAM_STR);

$query->bindParam(':username',$username,PDO::PARAM_STR);

$query->bindParam(':password',$password,PDO::PARAM_STR);

$query->bindParam(':created_at',$created_at,PDO::PARAM_STR);

$query->bindParam(':phonenumber',$phonenumber,PDO::PARAM_STR);

$query->bindParam(':uid',$uid,PDO::PARAM_STR);

$query->bindParam(':name',$name,PDO::PARAM_STR);

$query->bindParam(':age',$age,PDO::PARAM_STR);

$query->bindParam(':vehicletype',$vehicletype,PDO::PARAM_STR);

$query->bindParam(':model',$model,PDO::PARAM_STR);

$query->bindParam(':batterytype',$batterytype,PDO::PARAM_STR);

$query->bindParam(':details',$details,PDO::PARAM_STR);

$query->bindParam(':jpg',$jpg,PDO::PARAM_STR);

$query->bindParam(':number',$number,PDO::PARAM_STR);

$query->bindParam(':min_vol',$min_vol,PDO::PARAM_STR);
$query->bindParam(':max_vol',$max_vol,PDO::PARAM_STR);
$query->bindParam(':type',$type,PDO::PARAM_STR);


 $query->execute();



   $LastInsertId=$dbh->lastInsertId();

   if ($LastInsertId>0) {

    echo '<script>alert("Client has been added.")</script>';

echo "<script>window.location.href ='add-client.php'</script>";

  }

  else

    {

         echo '<script>alert("Something Went Wrong. Please try again")</script>';

    }



  

}



?>

<!DOCTYPE HTML>

<html>

<head>

	<title>Add Clients</title>



	<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>

	<!-- Bootstrap Core CSS -->

	<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />

	<!-- Custom CSS -->

	<link href="css/style.css" rel='stylesheet' type='text/css' />

	<!-- Graph CSS -->

	<link href="css/font-awesome.css" rel="stylesheet"> 

	<!-- jQuery -->

	<link href='//fonts.googleapis.com/css?family=Roboto:700,500,300,100italic,100,400' rel='stylesheet' type='text/css'>

	<!-- lined-icons -->

	<link rel="stylesheet" href="css/icon-font.min.css" type='text/css' />

	<!-- //lined-icons -->

	<script src="js/jquery-1.10.2.min.js"></script>

	<!--clock init-->

	<script src="js/css3clock.js"></script>

	<!--Easy Pie Chart-->

	<!--skycons-icons-->

	<script src="js/skycons.js"></script>

	<!--//skycons-icons-->

</head> 

<body>

<div class="page-container">

<!--/content-inner-->

<div class="left-content">

<div class="inner-content">

	

<?php include_once('includes/header.php');?>

				<!--//outer-wp-->

<div class="outter-wp">

					<!--/sub-heard-part-->

<div class="sub-heard-part">

<ol class="breadcrumb m-b-0">

<li><a href="dashboard.php">Home</a></li>

<li class="active">Add Clients</li>

</ol>

</div>	

					<!--/sub-heard-part-->	

					<!--/forms-->

<div class="forms-main">

<h2 class="inner-tittle">Add Clients </h2>

<div class="graph-form">

<div class="form-body">

<form method="post"> 

									

	

	<div class="form-group"> <label for="exampleInputEmail1">id</label> <input type="text" name="id" placeholder="id" value="" class="form-control" required='true'> </div>

	<div class="form-group"> <label for="exampleInputEmail1">username</label> <input type="text" name="username" placeholder="username" value="" class="form-control" required='true'> </div>

	<div class="form-group"> <label for="exampleInputEmail1">password</label> <input type="text" name="password" placeholder="password" value="" class="form-control" required='true'> </div>

	<div class="form-group"> <label for="exampleInputEmail1">created_at</label> <input type="text" name="created_at" placeholder="created_at" value="" class="form-control" required='true'> </div>

	<div class="form-group"> <label for="exampleInputEmail1">phonenumber</label> <input type="text" name="phonenumber" placeholder="phonenumber" value="" class="form-control" required='true'> </div>

	<div class="form-group"> <label for="exampleInputEmail1">uid</label> <input type="text" name="uid" placeholder="uid" value="" class="form-control" required='true'> </div>

	<div class="form-group"> <label for="exampleInputEmail1">name</label><input type="text" name="name" value="" placeholder="name"  class="form-control" maxlength='10' required='true' pattern="[0-9]+"> </div>

	<div class="form-group"> <label for="exampleInputEmail1">age</label><input type="text" name="age" value="" placeholder="age"  class="form-control" maxlength='10' pattern="[0-9]+"> </div>

	<div class="form-group"> <label for="exampleInputEmail1">vehicletype</label><input type="text" name="vehicletype" value="" placeholder="vehicletype"  class="form-control" maxlength='10' pattern="[0-9]+"> </div>

	<div class="form-group"> <label for="exampleInputEmail1">model</label> <input type="text" name="model" value="" placeholder="model" class="form-control" required='true'> </div> 

<div class="form-group"> <label for="exampleInputEmail1">batterytype</label>

	<input placeholder="batterytype" type="text" name="batterytype" class="form-control">

</div>

	<div class="form-group"> <label for="exampleInputPassword1">details</label> <input type="text" name="details" value="" placeholder="details" required='true' class="form-control"> </div>
			<div class="form-group"> <label for="exampleInputEmail1">number</label> <input type="text" name="number" placeholder="number" value="" class="form-control" required='true'> </div>
	<div class="form-group"> <label for="exampleInputEmail1">min_vol</label> <input type="text" name="min_vol" placeholder="min_vol" value="" class="form-control" required='true'> </div>
	<div class="form-group"> <label for="exampleInputEmail1">max_vol</label> <input type="text" name="max_vol" placeholder="max_vol" value="" class="form-control" required='true'> </div>
		<div class="form-group"> <label for="exampleInputEmail1">type</label> <input type="text" name="type" placeholder="type" value="" class="form-control" required='true'> </div>



	


	

	 <button type="submit" class="btn btn-default" name="submit" id="submit">Save</button> </form> 

</div>

</div>

</div> 

</div>

<?php include_once('includes/footer.php');?>

</div>

</div>		

<?php include_once('includes/sidebar.php');?>

<div class="clearfix"></div>		

</div>

<script>

		var toggle = true;



		$(".sidebar-icon").click(function() {                

			if (toggle)

			{

				$(".page-container").addClass("sidebar-collapsed").removeClass("sidebar-collapsed-back");

				$("#menu span").css({"position":"absolute"});

			}

			else

			{

				$(".page-container").removeClass("sidebar-collapsed").addClass("sidebar-collapsed-back");

				setTimeout(function() {

					$("#menu span").css({"position":"relative"});

				}, 400);

			}



			toggle = !toggle;

		});

	</script>

	<!--js -->

	<script src="js/jquery.nicescroll.js"></script>

	<script src="js/scripts.js"></script>



	<!-- Bootstrap Core JavaScript -->

	<script src="js/bootstrap.min.js"></script>

</body>

</html>

<?php }  ?>