1

I have created two pages. One page is BookTicket which contains form. It has two buttons. one buttons submits form and stores value in database. other button will navigate to payment page. other page is payment. in BookTicket page the form values is submitted and stored in database. It is working correctly. I want to Display the currently entered data in form which is in Bookticket into Payment page so that user can see the details entered in bookticket page. How To achieve This? How to get Currently inserted record from database and display it in payment page?

What can I write in payment.html page and php page for payment to get presently entered record?

Bookticket.html

  
<div class="col-lg-12 well">

  <h2 style="text-align:center;">BOOK MOVIE TICKETS</h2>
     
	 <p style="text-align:center;">  NOTE : 1. FIRST FILL THE DETAILS AND REGISTER. <br> 2. AFTER FILLING FORM GO TO PAYMENT PAGE BY CLICKING ON PROCEED TO PAY  </p>

<div class="col-lg-6 well" style="margin-top:1em;" >

     <video width="430" height="340" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>
	  
</div>


  
           
<div class="col-lg-6 " style="margin-top:1em;">
<form  name="bookticket" ng-app="BookTicket" ng-controller="BookTicketCtrl" ng-submit="submitForm(bookticket.$valid)" novalidate>	      
				
		  <div class="form-group col-lg-6" ng-class="{ 'has-error' : BookTicket.city.$invalid && (BookTicket.city.$dirty || submitted)}">
                    <label>Select City</label>
                    <select name="city" class="form-control"
                            ng-model="city"
                            ng-options="city.Name as city.Name for city in cityList"
                            ng-required="true" >
							 
					  <option value="">Select </option> 
                   </select>
				   <span class="help-block" ng-show="BookTicket.city.$invalid && BookTicket.city.$error.required && (BookTicket.city.$dirty || submitted)" >City Name is required.</span> 
         </div>
		
		<div class="form-group col-lg-6" ng-class="{ 'has-error' : BookTicket.locations.$invalid && (BookTicket.locations.$dirty || submitted)}">
                    <label>Select Location</label>
                    <select name="location" class="form-control"
                            ng-model="locations"
                            ng-options="location.Name as location.Name for location in locationList"
                            ng-required="true">
						 <option value="">Select </option>  
                   </select>
				 <span ng-show="BookTicket.locations.$invalid && BookTicket.locations.$error.required && (BookTicket.locations.$dirty || submitted)" class="help-block">Location Name is required.</span>  
         </div>
		 
		 <div class="form-group col-lg-12" ng-class="{ 'has-error' : BookTicket.theater.$invalid && (BookTicket.theater.$dirty || submitted)}">
                    <label>Select Theater </label>
                    <select name="theater" class="form-control"
                            ng-model="theater"
                            ng-options="theater.Name as theater.Name for theater in theaterList"
                            ng-required="true">
						 <option value="">Select </option> 
                   </select>
				  <span ng-show="BookTicket.theater.$invalid && BookTicket.theater.$error.required && (BookTicket.theater.$dirty || submitted)" class="help-block">Theater Name is required.</span> 
         </div>
		
         <div class="form-group col-lg-6" ng-class="{ 'has-error' : BookTicket.showdate.$invalid && (BookTicket.showdate.$dirty || submitted)}">
                    <label>Select Show Date </label>
                    <select name="showdate" class="form-control"
                            ng-model="showdate"
                            ng-options="showdate.dates as showdate.dates for showdate in showdateList"
                            ng-required="true">
						 <option value="">Select </option> 	 
                   </select>
				   <span ng-show="BookTicket.showdate.$invalid && BookTicket.showdate.$error.required && (BookTicket.showdate.$dirty || submitted)" class="help-block">Show Date is required.</span>
         </div>
		
		 <div class="form-group col-lg-6" ng-class="{ 'has-error' : BookTicket.showtime.$invalid && (BookTicket.showtime.$dirty || submitted)}">
                    <label>Select Show Time </label>
                    <select name="showtime" class="form-control"
                            ng-model="showtime"
                            ng-options="showtime.times as showtime.times for showtime in showtimeList"
                           ng-required="true">
					   <option value="">Select </option> 		 
                   </select>
				<span ng-show="BookTicket.showtime.$invalid && BookTicket.showtime.$error.required && (BookTicket.showtime.$dirty || submitted)" class="help-block">Show Time is required.</span>
         </div>
		 
		  <div class="form-group col-lg-6" ng-class="{ 'has-error' : BookTicket.classes.$invalid && (BookTicket.classes.$dirty || submitted)}">
                    <label>Select Class </label>
                    <select name="classes" class="form-control"
                            ng-model="classes"
                            ng-options="class.Name as class.Name for class in classList"
                           ng-required="true">
						 <option value="">Select </option> 	 
                   </select>
				 <span ng-show=" BookTicket.classes.$invalid && BookTicket.classes.$error.required && (BookTicket.classes.$dirty || submitted)" class="help-block">Class is required.</span> 
         </div>
		
		<div class="form-group col-lg-6" ng-class="{ 'has-error' : BookTicket.seatno.$invalid && (BookTicket.seatno.$dirty || submitted)}">
                    <label>Select Seat Number </label>
                    <input class="form-control" type="number" name="seatno"  ng-model="seatno" min="1" max="500" ng-required="true">
					 <span ng-show="BookTicket.seatno.$invalid && BookTicket.seatno.$error.required && (BookTicket.seatno.$dirty || submitted)" class="help-block">Seat Number is required.</span> 

         </div>
			 
		
		 <div class="col-lg-12 well " ng-repeat="error in errors" style="background-color:red; margin-bottom:1.5em;"> {{ error}}  </div>
         <div class="col-lg-12 well" ng-repeat="msg in msgs" style="background-color:green; margin-bottom:1.5em;"> {{ msg}}     </div>	
                    
           <button type="submit" class="btn btn-success col-lg-8 col-lg-offset-2" >REGISTER DETAILS</button>
		   
		  <button type="submit" class="btn btn-success col-lg-8 col-lg-offset-2" style="margin-top:1.5em;" ui-sref="payment" >PROCEED TO PAY</button>

</form>
</div>


</div>

main.js

// create angular controller for BookTicket
app.controller('BookTicketCtrl', function ($scope,$location, $http) {
  
  
  
        
  
  
  
 
    $scope.cityList = [
                         { Name: 'BANGLORE' },
                         { Name: 'TUMKUR' },
	                     { Name: 'MYSORE' },
	                     { Name: 'MANGLORE' },
	                     { Name: 'HASAN' }
                      ];
 
    $scope.locationList = [
                         { Name: 'RAJAJINAGAR STREET' },
                         { Name: 'TUMKUR STRRET' },
	                     { Name: 'MYSORE STREET' },
	                     { Name: 'MANGLORE STREET' },
	                     { Name: 'HASAN STRRET' }
                      ];
					  
  $scope.theaterList = [
                         { Name: 'ABC THEATER (BANGLORE,RAJAJINAGAR)' },
                         { Name: 'HOME THEATER (TUMKUR,TUMKUR STREET)' },
	                     { Name: 'MYSORE THEATER (MYSORE ROAD, MYSORE)' },
	                     { Name: 'MANGLORE THEATER (MANGLORE ROAD, MANGLORE)' },
	                     { Name: 'HASAN THEATER (HASAN ROAD, HASAN)' }
                      ];
 

  $scope.showdateList = [
                         { dates: '1-MAR-2017' },
                         { dates: '10-MAR-2017' },
	                     { dates: '13-MAR-2017' },
	                     { dates: '15-MAR-2017' },
	                     { dates: '20-MAR-2017' }
                      ];
 $scope.showtimeList = [
                         { times: '10 AM' },
                         { times: '12 AM' },
	                     { times: '3 PM' },
	                     { times: '5 PM' }

                      ];
					  
 $scope.classList = [
                         { Name: 'A' },
                         { Name: 'B' },
	                     { Name: 'C' },
	                     { Name: 'D' },
	                     { Name: 'E' }
                      ];
					  
  /*$scope.seatList = [
                         { number: 'A' },
                         { number: 'B' },
	                     { number: 'C' },
	                     { number: 'D' },
	                     { number: 'E' }
                      ]; */
 
 
                $scope.errors = [];
                $scope.msgs = [];


    // function to submit the form after all validation has occurred			
    $scope.submitForm = function (isValid) {
		
		

		
		
		       // Set the 'submitted' flag to true
                  $scope.submitted = true;
		
                   $scope.errors.splice(0, $scope.errors.length); // remove all error messages
                    $scope.msgs.splice(0, $scope.msgs.length);

					
		 if (isValid) { 


              
                  
		 
					
                    $http.post('bookticket.php', 
					             {'city':        $scope.city, 
								  'locations':   $scope.locations, 
								  'theater':     $scope.theater,
								  'showdate' :   $scope.showdate ,
								  'showtime'  :  $scope.showtime   ,
								  'classes' :    $scope.classes  ,
								  'seatno'  :    $scope.seatno  
								  } 
							   )
					
					
					.success(function(data, status, headers, config) {
                            if (data.msg != '')
                        {
                            $scope.msgs.push(data.msg);
                        }
                        else
                        {
                            $scope.errors.push(data.error);
                        }
                      })
					
					.error(function(data, status) { // called asynchronously if an error occurs or server returns response with an error status.
                        $scope.errors.push(status);
                    });
					
					//$location.path('/payment');
	
			 } // closing bracket for isvalid 
					
					else{ alert ('All Fields Are Required... please fill all the feilds..')   }
	
	     };// closing bracket for $scope.submitForm = function 

	
});

BookTicket.php

<?php

$data = json_decode(file_get_contents("php://input"));

$city = mysql_real_escape_string($data->city);
$locations = mysql_real_escape_string($data->locations);
$theater = mysql_real_escape_string($data->theater);
$showdate = mysql_real_escape_string($data->showdate);
$showtime = mysql_real_escape_string($data->showtime);
$classes = mysql_real_escape_string($data->classes);
$seatno = mysql_real_escape_string($data->seatno);


$con = mysql_connect('localhost', 'root', '');
mysql_select_db('bookticket', $con);

$qry_em = 'select count(*) as cnt from users where seatno ="' . $seatno . '"';
$qry_res = mysql_query($qry_em);
$res = mysql_fetch_assoc($qry_res);

if($res['cnt']==0){
$qry = 'INSERT INTO users (city,locations,theater,showdate,showtime,classes,seatno) values 
("' . $city . '","' . $locations . '","' . $theater . '","' . $showdate . '","' . $showtime . '","' . $classes . '","' . $seatno . '")';
$qry_res = mysql_query($qry);
if ($qry_res) {
    $arr = array('msg' => "REGISTERED DETAILS SUCCESSFULLY!!!! NOW CLICK ON CONTINUE TO PAY TO COMPLETE PAYMENT", 'error' => '');
    $jsn = json_encode($arr);
    print_r($jsn);
} else {
    $arr = array('msg' => "", 'error' => 'ERROR OCCURED!!!! PLEASE TRY AGAIN...');
    $jsn = json_encode($arr);
    print_r($jsn);
}
}

else
{
     $arr = array('msg' => "", 'error' => 'Seat no is  Already Taken');
    $jsn = json_encode($arr);
    print_r($jsn);
}

?>

4
  • why u need that latest entered data from database. I think you could directly bind your payment page with form page. Commented Feb 18, 2017 at 17:47
  • Both Have Different controllers. How to bind it? Commented Feb 18, 2017 at 17:57
  • Latest entered data is needed because the user can see the summary of booking details before proceeding for payment Commented Feb 18, 2017 at 18:01
  • can you please tell how to do it? Commented Feb 18, 2017 at 19:30

1 Answer 1

0

you can get last inserted record id by using mysql_insert_id()

example:

    $last_insert = mysql_insert_id();

check http://php.net/manual/en/function.mysql-insert-id.php for more details

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.