<?php 
include ('database.php');
session_start();

if(isset($_POST['submit']));
{
    $code = mysqli_real_escape_string($connection, $_POST['code']);
	$id = mysqli_real_escape_string($connection, $_POST['id']);
    

  
  $query = "UPDATE users SET code='$code' WHERE id='$id' LIMIT 1";
  $query_run = mysqli_query($connection, $query);
 
 if($query_run)
  {
 	 

	 $_SESSION['id'] = $id;
	 header("location:../index.php"); 
 }
 else
 {
	  $_SESSION['status'] = "<h5 style='padding:8px; background: #fe8b8e; border-radius: 10px; color: #fff; text-align: center;'>Failed to complete</h5>";
       
	header("location: ../passcode.php");  
 }
}
 
?>