0

I am using EAN API for hotel Booking. Where i just want to use a form and button to post a url on form action.Here is the code what i am doing:

<form method="post" action="https://api.eancdn.com/ean-services/rs/hotel/v3/res?cid=50555&minorRev=99&apiKey=**XXXX**(YOUR API)&locale=en_US&currencyCode=INR&xml=%3CHotelRoomReservationRequest%3E%0A%20%20%20%20%3ChotelId%3E106347%3C%2FhotelId%3E%0A%20%20%20%20%3CarrivalDate%3E12%2F8%2F2013%3C%2FarrivalDate%3E%0A%20%20%20%20%3CdepartureDate%3E12%2F10%2F2013%3C%2FdepartureDate%3E%0A%20%20%20%20%3CsupplierType%3EE%3C%2FsupplierType%3E%0A%20%20%20%20%3CrateKey%3Eaf00b688-acf4-409e-8bdc-fcfc3d1cb80c%3C%2FrateKey%3E%0A%20%20%20%20%3CroomTypeCode%3E198058%3C%2FroomTypeCode%3E%20%0A%20%20%20%20%3CrateCode%3E484072%3C%2FrateCode%3E%0A%20%20%20%20%3CchargeableRate%3E24000%3C%2FchargeableRate%3E%0A%20%20%20%20%3CRoomGroup%3E%0A%20%20%20%20%20%20%20%20%3CRoom%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CnumberOfAdults%3E2%3C%2FnumberOfAdults%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CfirstName%3Etest%3C%2FfirstName%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3ClastName%3Etester%3C%2FlastName%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CbedTypeId%3E23%3C%2FbedTypeId%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3CsmokingPreference%3ENS%3C%2FsmokingPreference%3E%0A%20%20%20%20%20%20%20%20%3C%2FRoom%3E%0A%20%20%20%20%3C%2FRoomGroup%3E%0A%20%20%20%20%3CReservationInfo%3E%0A%20%20%20%20%20%20%20%20%3Cemail%3Etest%40travelnow.com%3C%2Femail%3E%0A%20%20%20%20%20%20%20%20%3CfirstName%3Etest%3C%2FfirstName%3E%0A%20%20%20%20%20%20%20%20%3ClastName%3Etester%3C%2FlastName%3E%0A%20%20%20%20%20%20%20%20%3ChomePhone%3E2145370159%3C%2FhomePhone%3E%0A%20%20%20%20%20%20%20%20%3CworkPhone%3E2145370159%3C%2FworkPhone%3E%0A%20%20%20%20%20%20%20%20%3CcreditCardType%3ECA%3C%2FcreditCardType%3E%0A%20%20%20%20%20%20%20%20%3CcreditCardNumber%3E5401999999999999%3C%2FcreditCardNumber%3E%0A%20%20%20%20%20%20%20%20%3CcreditCardIdentifier%3E123%3C%2FcreditCardIdentifier%3E%0A%20%20%20%20%20%20%20%20%3CcreditCardExpirationMonth%3E11%3C%2FcreditCardExpirationMonth%3E%0A%20%20%20%20%20%20%20%20%3CcreditCardExpirationYear%3E2015%3C%2FcreditCardExpirationYear%3E%0A%20%20%20%20%3C%2FReservationInfo%3E%0A%20%20%20%20%3CAddressInfo%3E%0A%20%20%20%20%20%20%20%20%3Caddress1%3Etravelnow%3C%2Faddress1%3E%0A%20%20%20%20%20%20%20%20%3Ccity%3ESeattle%3C%2Fcity%3E%0A%20%20%20%20%20%20%20%20%3CstateProvinceCode%3EWA%3C%2FstateProvinceCode%3E%0A%20%20%20%20%20%20%20%20%3CcountryCode%3EUS%3C%2FcountryCode%3E%0A%20%20%20%20%20%20%20%20%3CpostalCode%3E98004%3C%2FpostalCode%3E%0A%20%20%20%20%3C%2FAddressInfo%3E%0A%3C%2FHotelRoomReservationRequest%3E">
 <input name="submit" type="submit" />
 </form>

It is necessary to fetch data and also posting the URL(Post method for action). How can i get the value stored at the url and get back to my page.

Chirag Nagpal
  • 729
  • 10
  • 25
  • You mean after the users browser hits the "eancdn.com" site and the form is processed, they are redirected to "index.php". If that is the case, then after the form is processed, add a `header('Location: /index.php')` and `exit;` There is no need to make the user wait for no reason. – Tigger Nov 09 '13 at 05:01
  • 1
    Header is a option when i am going to a my own created page. I am Click on submit Button it go to the URL "eancdn.com". Now from that page how can i bring back to my php page because after clicking it is on a website i can not change code of a website managed by eancdn.com – Chirag Nagpal Nov 09 '13 at 05:04
  • You can't do this in the way you describe. The whole point is that you can't change the code of eancdn.com, so you can't force the user to come back, either. @DanCameron has a good suggestion, though; try that. – elixenide Nov 09 '13 at 05:34

1 Answers1

1

You could use jQuery to submit the form in the background than redirect the user.

Give your form an id of "eancdn-form"

$( "#eancdn-form" ).submit(function( event ) {
    // Stop form from submitting normally
    event.preventDefault();

    // Get some values from elements on the page:
    var $form = $( this ),
    url = $form.attr( "action" );

    // Send the data using post
    var submit_form = $.post( url );

    // Submit and when complete redirect
    submit_form.done(function( data ) {
       // Use .location.replace to prevent back button loop
       window.location.replace("http://stackoverflow.com");
    });
});
Dan Cameron
  • 756
  • 6
  • 8