<?php
include ("includes/database.php");
?>

<!doctype html>
<html>
<head>
              <a class="nav-link js-scroll-trigger" href="main.php">BACK TO HOMEPAGE</a><br>
              <a class="nav-link js-scroll-trigger" href="shoplogin.php">Already a member? LOG IN here</a>
              
              
<title>SERVICE REGISTRATION</title>
<center>
<font size="6" color="blue" face=soap>REGISTER YOUR SERVICE HERE!</font size></strong><br><br>
</center>
<center>
<p><img src="images/shopregister.png" width="325" height="325"></p>
</center>

</head>

<body>

<center>

<br>
<center><strong><font size="5" face=verdana color=black>FILL THE FORM BELOW</font size></strong><br><br></center>
<br/>
<?php
if (!(isset($_POST["name"])))
{
?>

<form method="post" enctype="multipart/form-data">

<center>

<label>Business Name</label>
<input class="form-control" placeholder="Name" name="name" type="text" required autocomplete"on"><br>
<br>

<label>Type of Service</label>

<form action="services.php" method="post">
<select name="Services">
<option value="Mechanic">Mechanic</option>
<option value="Plumber">Plumber</option>
<option value="Carpenter">Carpenter</option>
<option value="Technician">Technician</option>
<option value="Other">Other</option>
</select>


<input type="submit" name="submit" value="Get Selected Values" />
</form>
<?php
if(isset($_POST['submit'])){
$selected_val = $_POST['Color'];  // Storing Selected Value In Variable
echo "You have selected :" .$selected_val;  // Displaying Selected Value
}
?>
  <!-- Page Content -->
    <div class="container">
  <link rel="stylesheet" type="text/css" href="styleall.css">


<br>

<label>Username</label>
<input class="form-control" placeholder="Username" name="username" type="text" required autocomplete"on"><br>
<br>
<label>Password</label>
<input class="form-control" placeholder="eg:1234" name="password" type="password" required autocomplete"on"><br>
<br>
<label>Address</label>
<input class="form-control" placeholder="eg:Machang, Kelantan" name="address" type="text" required autocomplete"on"><br>
<br>
<label>Phone Number</label>
<input class="form-control" placeholder="eg:01********" name="phone" type="tel" required autocomplete"on"><br>
<br>
<label>Operation Hour</label>
<input class="form-control" placeholder="eg:7am-5pm" name="operation" type="text" required autocomplete"on"><br>
<br>
<label>Email</label>
<input class="form-control" placeholder="eg:123@gmail.com" name="email" type="email" required autocomplete"on"><br>
<br>
<input class="form-control" name="photo" type="file"><br>


<a href="main.php" class="btn btn2" type="submit" value="register">HOME</a>
	
</div>
<input class="btnsubmit" type="submit" name="submit" value="Register"><br>
</form>


<br><br>




<?php
}
else
{

//get data
$susername=$_POST["username"];
$sname=$_POST["name"];
$sadd2=$_POST["address"];
$sphone=$_POST["phone"];
$semail=$_POST["email"];
$spwd=$_POST["password"];
$soperation=$_POST["operation"];



//check duplicate
$data=mysqli_query($con, "SELECT * from tbl_shop where shop_username ='$susername'");
$wujud=mysqli_num_rows($data);

if ($wujud>0)
{echo "Username already taken. <a href='shopregister.php'>Try again</a>.";}
else
{
//php.net (The original name of the file on the client machine)
$namaFile=$username.$_FILES["photo"]["name"];

//upload picture
move_uploaded_file($_FILES["photo"]["tmp_name"],"shop/".$namaFile);




mysqli_query($con,"insert into tbl_shop(shop_name,shop_password,shop_username,shop_address,shop_phone, shop_email,shop_photo,shop_operationhour) values ('$sname','$spwd','$susername','$sadd2','$sphone','$semail','$namaFile','$soperation')") or die (mysqli_error($con));
echo "New record inserted. Click <a href='shoplogin.php'>here</a> to login";



}
}

?>
</center>

</body>
</html>