<?php

include ("includes/database.php");
include ("includes/setting.php");




?>

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><?php echo $tajuk; ?></title>

    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="vendor/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="dist/css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
<body background="images/gamba4.gif"

<body>

    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <div class="login-panel panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Register here!</h3>
                        <h3 class="panel-title">&nbsp;</h3>
</div>
                    <div class="panel-body">
                       
                        <?php
						
						if (!isset($_POST ["username"]))
						{
							?>
                            
                        <form role="form" method="post">
                        
                            <fieldset>
                            
                            <div class="form-group">
                            <label>Username</label>
                                    <input class="form-control" placeholder="Username" name="username" type="text" required autocomplete"off">
                                </div>
                                
                            <div class="form-group">
                            <label>Password</label>
                                    <input class="form-control" placeholder="Password" name="password" type="password" required autocomplete"off">
                                </div>    
                                
                                <div class="form-group">
                            <label>Name</label>
                                    <input class="form-control" placeholder="Name" name="name" type="text" required autocomplete"off">
                                </div>
                                
                            <div class="form-group">
                            <label>IC</label>
                                    <input class="form-control" placeholder="Enter your IC number." name="ic" type="text" required autocomplete"off">
                                </div>    
                                
                            <div class="form-group">
                            <label>Address</label>
                                    <input class="form-control" placeholder="Line 1" name="add1" type="text" required autocomplete"off">
                                    <input class="form-control" placeholder="Line 2" name="add2" type="text" autocomplete"off">
                                </div>    
                                
                            <div class="form-group">
                            <label>Postcode</label>
                                    <input class="form-control" placeholder="Postcode" name="postcode" type="text" required autocomplete"off">
                                </div>    
                                
                                
                             <div class="form-group">
                            <label>City</label>
                                    <input class="form-control" placeholder="City" name="city" type="text" required autocomplete"off">
                                </div>       
                                
                                
                              <div class="form-group">
                            <label>State</label>
                                    <input class="form-control" placeholder="State" name="state" type="text" required autocomplete"off">
                                </div>      
                                
                             <div class="form-group">
                            <label>Phone</label>
                                    <input class="form-control" placeholder="Phone" name="phone" type="tel" required autocomplete"off">
                                </div>       
                                
                          <div class="form-group">
                            <label>Email</label>
                                    <input class="form-control" placeholder="Email" name="email" type="email" required autocomplete"off">
                                </div>             
                                
                            
                                
                                <!-- Change this to a button or input when using this as a form -->
                                
                                <input type="submit" class="btn btn-lg btn-success btn-block" value="Register">
                                <a href="index.html" class="btn btn-lg btn-danger btn-block">Cancel</a>
                                
                            </fieldset>
                        </form>
                        
                       <?php
						}
						else
						{
							
							//get data from input
							$username=$_POST["username"];
$pwd=md5($_POST["password"]);
							$name=$_POST["name"];
							$ic=$_POST["ic"];
							$add1=$_POST["add1"];
							$add2=$_POST["add2"];
							$postcode=$_POST["postcode"];
							$city=$_POST["city"];
							$state=$_POST["state"];
							$phone=$_POST["phone"];
							$email=$_POST["email"];
							
							//check duplicate
							
							$data=mysqli_query($newcon, "SELECT * FROM user where ic='$ic'");
							$bil_rekod=mysqli_num_rows($data);
							$show=mysqli_fetch_array($data);
							
							if ($bil_rekod!=0)
							{
							
							
							?>
                            
                            <div class="alert alert-success">
                               Account already existed in the system. <a href="register.php" class="alert-link">Click here to try again</a>.
                            </div>
                            
                         <?php
							}
							else
							{
$dateregister=date("Y-m-d");								
//insert data into database		
mysqli_query($newcon,"INSERT INTO user (username, pwd,name,ic,add1,add2,city,postcode,state,phone,email,status) values ('$username', '$pwd','$name','$ic','$add1','$add2','$city','$postcode','$state','$phone','$email','USER')")or die (mysqli_error($newcon));								
								
								
								
								?>
								
								<div class="alert alert-success">
                              New Account Successfully registered. <a href="index.php" class="alert-link">Click here to login</a>.
                            </div>
						<?php
							}}
							?>
						
                        
                        
                        
                        <p><br>
                        <br>
                        
             </p>
                        <p>
						
						 <span class="fa fa-user"></span> <?php echo $developer; ?><br>
                        <span class="fa fa-envelope-o "></span> <?php echo $edev; ?><br>
                        <span class="fa fa-phone"></span> <?php echo $pdev; ?><br>
                        <br>&copy; <?php echo date("Y"); ?>. <?php echo $cright; ?><br>
                        
                    </p></div>
                </div>
            </div>
        </div>
    </div>

    <!-- jQuery -->
    <script src="vendor/jquery/jquery.min.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="vendor/bootstrap/js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="vendor/metisMenu/metisMenu.min.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="dist/js/sb-admin-2.js"></script>

</body>

</html>
