<?php
session_start();
include_once 'dbconnect.php';

//if(isset($_SESSION['user'])!="")
//{
//	header("Location: index.php");
//}

if(isset($_POST['btn-login']))
{
	$friendname = mysqli_real_escape_string($con,$_POST['name']);
	$answer = mysqli_real_escape_string($con,$_POST['answer']);
	//$res=mysqli_query($con,"SELECT * FROM users WHERE username='$email'");
	//$row=mysqli_fetch_array($res);
	//$up = $row['user_pos'];
	
	if($friendname==''){
		echo '<script>alert("jangan lupa isi nama ya..." )</script>';  
	}else{
		if($answer=='YES'){
			//echo '<script>alert("ayo pilih makan dan minum ya" )</script>';  
		$dynamic_url = "food_menu.php?friendname=".$friendname."&answer=".$answer;
        echo "<script>window.location.href = '" . $dynamic_url . "';</script>";
        exit;
		}else{
			echo '<script>alert("thank you for your answer" )</script>';  
			//echo '<script type="text/javascript">','showCustomAlert();','</script>';
		}
	}
	//{
	
	//	if($up=='YES' )
	//	{
	//	$_SESSION['user'] = $row['user_id'];
	//	header("Location: mainmenu_pos.php");

		
	//	}
	//	else
	//	{
	//	$_SESSION['user'] = $row['user_id'];
	//	header("Location: mainmenu.php");
	//	}
	//}
	//else
	//{

	//}
	
}
?>

    <script>
        function showCustomAlert() {
            // Create a custom alert box with SweetAlert
            Swal.fire({
                title: 'Vettel 12th birthday',
                text: 'thank you for your answer',
                confirmButtonText: 'OK'
            });
        }


		function JSalert(){
swal("Congrats!", ", Your account is created!", "success");
}
    </script>
	

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content ="width=device-width,initial-scale=1,user-scalable=yes" />



<title>Login</title>
<link rel="icon" type="image/x-icon" href="/images/database.ico">
<link rel="stylesheet" href="style.css" type="text/css" />

<style>
.button {
  background-color: #f79503ff; /* Hijau */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
}

.button2 {background-color: #008CBA;} /* Biru */
.button3 {background-color: #f44336;} /* Merah */ 
.button4 {background-color: #e7e7e7; color: black;} /* Abu-abu */ 
.button5 {background-color: #555555;} /* Hitam */
</style>


</head>
<body>
<center>
<div id="login-form">
<form method="post">
 <p><img src="logo.png" width="336" height="336"></p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  
<table align="center" width="75%" border="0">
<tr>
 	
<td><label style='color:red;'><small>please input your name </small></label>  <input type="text" name="name" placeholder="Name" required /></td>
</tr>
<tr>
	
<td><label style='color:red;'><small>are u available for vettel's birthday? </small></label>   
        
                <div class="col-auto">
                    <select class="form-select" id="answer" name="answer" aria-label="" value="<?php echo $answer?>" style="color:blue">
                        
                       	<option value="-">-</option>
                        <option value="YES">YES</option>
                        <option value="NO">NO</option>

        
                    </select>
                       

                </div>




</tr>
<tr>
<td><button class="button" type="submit" name="btn-login">NEXT</button></td>
</tr>



</table>
</form>
</div>
</center>
</body>
</html>