<?php

	$id=$_GET['guestid'];

	$result=mysqli_query($conn, "SELECT * FROM guest WHERE g_id=$id") or die (mysql_error());

	$row=mysqli_fetch_array($result);

?>



<div class="right_col" role="main">

    <div class="">

        <div class="row">

            <div class="col-md-12 col-sm-12 col-xs-12">

                <div class="x_panel">

					<div class="x_title">

						<h2>Update guest</h2>

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

					</div>

					<div class="x_content">



						<form class="form-horizontal form-label-left" method="post">



							<div class="item form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="name">Full Name <span class="required">*</span>

								</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<input id="name" class="form-control col-md-7 col-xs-12" name="name" type="text" value="<?php echo $row['g_full_name'];?>" disabled>

								</div>

							</div>

							<div class="item form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="ic">IC or Passport <span class="required">*</span>

								</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<input type="text" id="ic" name="ic" class="form-control col-md-7 col-xs-12" placeholder="123456-08-3455 or A123456789" 

									value="<?php echo $row['g_id_no'];?>" required>

								</div>

							</div>

							<div class="form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12">Gender</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<div id="gender" class="btn-group" data-toggle="buttons">

										<label class="btn btn-default" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default">

											<input type="radio" name="gendar" value="Male"> &nbsp; Male &nbsp;

										</label>

										<label class="btn btn-primary" data-toggle-class="btn-primary" data-toggle-passive-class="btn-default">

											<input type="radio" name="gendar" value="Female"> Female

										</label>

									</div>

								</div>

							</div>

							<div class="item form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="contact">Contact <span class="required">*</span>

								</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<input type="text" id="contact" name="contact" data-validate-length-range="8,20" class="form-control col-md-7 col-xs-12"

									value="<?php echo $row['g_contact'];?>" disabled>

								</div>

							</div>

							<div class="item form-group">

								<label class="control-label col-md-3 col-sm-3 col-xs-12" for="email">Email

								</label>

								<div class="col-md-6 col-sm-6 col-xs-12">

									<input type="email" id="email" name="email" data-validate-linked="email" class="form-control col-md-7 col-xs-12" value="<?php echo $row['g_email'];?>">

								</div>

							</div>

							<div class="ln_solid"></div>

							<div class="form-group">

								<div class="col-md-6 col-md-offset-3">

									<button id="send" type="submit" class="btn btn-success" name="submit">Submit</button>

									<button type="submit" class="btn btn-primary" onclick="javascript:window.location='index.php?pagecontent=guestlist'">Cancel</button>

								</div>

							</div>

						</form>

					</div>

                </div>

            </div>

        </div>

    </div>

</div>



<?php 

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

	{

		$ic=$_POST['ic'];

		$gendar=$_POST['gendar'];

		$email = $_POST['email'];

		

		mysqli_query($conn, "UPDATE guest set g_id_no='$ic', g_gendar ='$gendar', g_email='$email' WHERE g_id=$id") or die (mysql_error());

		

		header('Location: index.php?pagecontent=guestlist');

	}

?>