How can I show a page for a number of times?

Hello! I'm trying to make my first web application of a hotel(this is an education project not a payed one) and I have a lot of issues...The most important one is that if a user at the registration process selects that he wants to reserve 4 rooms he needs to make the checkin process 4 times, once for each room. I have succesfully managed to register the user and login, but the problem is with showing the check-in form for a number of times... I managed to show it once, but the second time it doesn't work, it shows me the details for the same room, not for a different one, or it makes an infinite loop...what can I do? Here it's the PHP code:
<?php
	ob_start();
	 $success = false;
	// Errors reporting, used if needed
	error_reporting(E_ALL);
	ini_set('display_errors', 'on');

	// General configuration like base, used if needed
	include_once ('include/config.inc.php');

	// Mail functions
	include_once ('include/mail.functions.php');



	// DBConn
	include_once ('class/DB/DBConn.includeall.php');
	$db = new DBConn(NULL);

	// Includere clasa login
	require_once ('class/class_login.php');

	// Set up current language
	$lang = "ro";
	$_SESSION[PRE.'lang'] = $lang;
	$row='';
	$access = 0;
	$user = (isset($_POST['nume']) && !empty($_POST['nume'])) ? $_POST['nume'] : "" ;
	$email = (isset($_POST['email']) && !empty($_POST['email'])) ? $_POST['email'] : "" ;
	$telefon = (isset($_POST['telefon']) && !empty($_POST['telefon'])) ? $_POST['telefon'] : "" ;
	$cnp = (isset($_POST['cnp']) && !empty($_POST['cnp'])) ? $_POST['cnp'] : "" ;
	$serieci = (isset($_POST['serieci']) && !empty($_POST['serieci'])) ? $_POST['serieci'] : "" ;
	$mesaj = (isset($_POST['mesaj']) && !empty($_POST['mesaj'])) ? $_POST['mesaj'] : "" ;
	$email_status=1;

	$db = pg_connect("host=dev.incorom.local port=5432 dbname=login_robinson user=robinson password=123");
	$query = "INSERT INTO tcheckin(nume,email,telefon,cnp,serieci,mesaj) VALUES ('$user','$email','$telefon','$cnp','$serieci','$mesaj')";
	$result = pg_query($query);
	$test=$_SESSION[PRE.'nume'];
	$test1=$_SESSION[PRE.'uid'];

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

			echo "<script>
	 alert('Check-in efectuat cu success! Daca ai rezervat mai multe camere te rog sa completezi si check-in-ul pentru celelalte camere.');
	 window.location.href='acasa';
	 </script>";
			echo "<script>
	 alert('S-a produs o eroare! Te rog mai verifica odata formularul!');
	 </script>";

		if($user !=''&& $email !='')
		{
			$success=true;
		}

	}
?>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

	<head>
		<link href="https://fonts.googleapis.com/css?family=Playfair+Display:400,700,900|Rubik:300,400,700" rel="stylesheet">

		<!-- <base href="http://dev.incorom.local/ticketing/www/login.php" /> -->
		<title>Efectueaza check-in</title>
		<?php
			include('include/links.php');
			include('include/scripts.php');
		?>

	</head>
	<?php
	$i=1;
	$conn = pg_connect("host=local port=5432 dbname=login_robinson user=robinson password=123");
	$test1=$_SESSION[PRE.'uid'];
	$result = pg_query($conn, "SELECT nume FROM tregister WHERE id = '$test1'");
	if (!$result) {
		echo "An error occurred.\n";
		exit;
	}
	$row = pg_fetch_row($result);

	$result1 = pg_query($conn, "SELECT nr_camere FROM tregister WHERE id = '$test1'");
	if (!$result1) {
		echo "An error occurred.\n";
		exit;
	}

	$camere = pg_fetch_row($result1);
	while($camere[0] < $i){
		if(isset($_POST['submit'])){

				echo "<script>
		 alert('Check-in efectuat cu success! Daca ai rezervat mai multe camere te rog sa completezi si check-in-ul pentru celelalte camere.');
		 window.location.href='acasa';
		 </script>";
				echo "<script>
		 alert('S-a produs o eroare! Te rog mai verifica odata formularul!');
		 </script>";
		$i++;
	}
}
	?>
	<body style="display: block !important;" ng-cloak="" ng-class="{ 'layout-fixed' : app.layout.isFixed, 'layout-boxed' : app.layout.isBoxed, 'layout-dock' : app.layout.isDocked, 'layout-material': app.layout.isMaterial, 'aside-offscreen' : app.sidebar.isOffscreen, 'aside-mini' : app.sidebar.isMini, 'aside-right' : app.sidebar.isRight, 'footer-hidden': app.footer.hidden, 'in-app': !$state.includes('page')}">

		<div class="animated fadeOutZoom">
			<div class="container container-sm animated fadeInDown">
				<div class="app-view-header">Bine ai venit, <?php echo $row[0]; ?>!</div>
				<div class="center-block mt-xl">

					<div class="panel">
						<div class="panel-body">
							<p class="pv text-bold">Check-in pentru camera cu numarul <?php echo $i; ?></p>
							<form action="#" method="post">
								<div class="row">
									<div class="col-md-12 form-group">
										<label for="nume">Nume</label>
										<input type="text" id="text	" value=" <?php echo $row[0]; ?>" class="form-control " name="nume" disabled="disabled">
									</div>
								</div>
								<div class="row">
									<div class="col-md-12 form-group">
										<label for="telefon">Telefon</label>
										<input type="phone" id="telefon	" class="form-control " name="telefon" required>
									</div>
								</div>
								<div class="row">
									<div class="col-md-12 form-group">
										<label for="email">Email</label>
										<input type="email" id="email" class="form-control " name="email" required>
									</div>
								</div>
								<div class="row">
									<div class="col-md-12 form-group">
										<label for="cnp">CNP</label>
										<input type="text" id="text	" class="form-control "name="cnp" required>
									</div>
								</div>
								<div class="row">
									<div class="col-md-12 form-group">
										<label for="serie">Serie de buletin</label>
										<input type="text" id="text	" class="form-control " name="serieci" required>
									</div>
								</div>
								<div class="row">
									<div class="col-md-12 form-group">
										<label for="message">Scrie un mesaj *Optional</label>
										<textarea name="mesaj" id="message" class="form-control " cols="5" rows="4"></textarea>
									</div>
								</div>
								<div class="row">
									<div class="col-md-6 form-group">
										<input type="submit" value="Rezerva acum" class="btn btn-primary" name="submit">
									</div>
								</div>
							</form>
						</div>

					</div>
				</div>
			</div>
		</div>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.min.js"></script>

		<script>

		$('#arrival_date, #departure_date').datepicker({format: 'dd/mm/yyyy'});


		</script>


	</body>

	</html>
<?php
ob_end_flush();
?>

Open in new window

Chera RobinsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
First of all: embed your code into the post using the CODE button (please edit your post).

Then:
The most important one is that if a user at the registration process selects that he wants to reserve 4 rooms he needs to make the checkin process 4 times, once for each room.
I would expect the following flow:

1) Login to the site.
2) Go to room reservations.
3) Enter the date range and the number of rooms.
4) Provide information for further room filtering (number of persons, preferences, pricing etc.).
5) Select the rooms from the list of available rooms.

Where 3 - 5 are performed on the same page in the sense of a SPA. And 4 is optional.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PostgreSQL

From novice to tech pro — start learning today.