www.webdeveloper.com
Results 1 to 7 of 7

Thread: I need help with POST inside php

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    4

    Question I need help with POST inside php

    Hello evryone, i am new to the web development, and i have some isues with POST.
    I have to send some values to an external server (to hostelworld.com) for the booking of some hostel using POST. The values are e-mail, first name, credit card number ecc..

    I have created a form with textaras, check box, etc... with all the variables requiered. This is the form:

    <form id="booking" method="post" action="https://secure.hostelworld.com/bookhostels/xmlapi/SubmitCustomerDetails.php">



    This is the part of the API that explains how to make the post request:
    Sample Submission of Customer Details

    POST /bookhostels/xmlapi/SubmitCustomerDetails.php HTTPS/1.0
    Host: secure.hostelworld.com
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 265

    FirstName=test&LastName=test&Nationality=Ireland&Gender=Male&EmailAddress=test@hostelw
    orld.com&PhoneNumber=none&ArrivalTime=11&CCName=test+test&CCNumber=xxxxxxxxxxxxxxxx&CC
    Expiry=04/04&CCType=mastercard&BSID=e06cc5f441805f43371c189f93734fef&UserID=testaffili
    ate.com&SettleCurrency=GBP

    \NOTE: The information for this section must be posted over a secure connection.
    The address to post to is:
    https://secure.hostelworld.com/bookh...merDetails.php


    Now when i made the request, i got an errore, becose the sever of hostelworld talkes the ip of the client, and not the ip of the server, and dosen't allowed the connection.
    I think this is an errore becouse there is something wrong withg the post request. I have not inserted in the request this part:
    POST .........HTTPS/1.0
    Host:.......
    Content-Type: .....
    Content-Length: .......

    I don't now how to insert this in the form, or if i have to insert this in some other way.
    Any help is very appreciated.

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    becose the sever of hostelworld talkes the ip of the client, and not the ip of the server, and dosen't allowed the connection.
    Is this a guess or a fact? Does the API documentation say something about an IP?

    More information that is needed/would be really helpful is:

    1) More details about the API, if you have them
    2) Your attempted POST request (you've omitted it above, we need to see it, you can replace sensitive parts with X's, if need be).
    3) The response (i.e. error) received from the server

    If you've got a link to the "live" test form, that might help as well. When in doubt, post everything you've got for us to see!
    Last edited by aj_nsc; 05-25-2010 at 12:47 PM.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  3. #3
    Join Date
    May 2010
    Posts
    4
    Thank you for your interes

    becose the sever of hostelworld talkes the ip of the client, and not the ip of the server, and dosen't allowed the connection.
    Is this a guess or a fact? Does the API documentation say something about an IP?
    This is a fact. This is writen in the API:
    To be set-up to use the XML API, you will need to contact Hostelworld.com
    (affiliates@hostelworld.com) with the IP address (or range of IP addresses) that you will be connecting to the service from. This is so we can authenticate each affiliate as they connect to make sure each request is legitimate. Once this has been done, you’re ready to start development.



    1)In this link you can find all the API info that i have
    https://docs.google.com/viewer?url=h..._%2520v1.1.pdf
    2)
    HTML Code:
    	<form id="booking" method="post" action="https://secure.hostelworld.com/bookhostels/xmlapi/SubmitCustomerDetails.php?">
    
    		<table   bgcolor="#669ccc">
    <input type='hidden' name='UserID' value="xxxxxxx.com">
    <input type='hidden' name='BSID' value="<?echo $bsid;?>">
    
    <tr >	
    
    	<td>First Name: <input type="text"  name="FirstName" value="FirstName"></td>
    	<td>Last Name: <input type="text" name="LastName" value="LastName"></td>
    
    
    
    
    <td>Nationality<select id="Nationality" name="Nationality" >
    <option>Afghanistan</option>
    <option>Albania</option>
    ... etc
    	 </select></td>	
    </tr>
    <tr>
    	<td>Email adress: <input type="text" name="EmailAddress"></td>
    	<td>Phone number: <input type="text" name="PhoneNumber"></td>
    
    	<td align="left">
    
    	Gender	
    	<select id="Gender" name="Gender" >
    		<option>Male</option>
    		<option>Female</option>
    	 </select>	
    	</td>	
    
    </tr>
    
    <tr >
    
    	
    
    <td>Card Holder's Name: <input type="text" name="CCName"></td>
    <td>Card Number: <input type="text" name="CCNumber"></td>
    <td>ArrivalTime <select id="ArrivalTime" name="ArrivalTime" >
    		<option>select</option>
    	
    		<?for ($i=0;$i<24;$i++)
    		{
    			echo '<option>'.$i.'</option>';
    
    		}?>
    	 </select>
    </td>
    
    
    </tr>
    <td>Security Code: <input type="text" name="CVV" maxlength="4" size="4"></td>
    
    <td>
    
    <select id="year" name="CCType" > <!--TODO: Get card by XML API -->
    			<option>Visa</option>
    			<option>Mastercard</option>
    
    	 </select>	
    
    </td>
    <td>Expiry date
    
    <select id="CCExpiry" name="CCExpiry" >
    		<option>05/10</option>
    		<option>06/10</option>
    		<option>07/10</option>
    etc...
    	 </select>	
    </td>
    </td>
    </tr>
    <tr ><td>
    <input type="submit" align="left" value="Submit">
    </td></tr>
    			</table>
    </form>
    3)Authentication Failed Your 'UserID' could not be authenticated with your connection details. Please check your 'UserID' or contact Web Reservations to have your account activated. xxxxx.com xxx.xxx.xxx.xxx
    wheere xxxx.com is the username i use to conect to the api and xxx.xxx.xxx.xxx is my ip adress


    Thank you again for your Help, i really appreciate it.
    Nigel

  4. #4
    Join Date
    Jan 2009
    Posts
    3,346
    You will need to process the API on the server-side. You will not be able to post an HTML directly to the API based on their documentation.

  5. #5
    Join Date
    May 2010
    Posts
    4
    Quote Originally Posted by criterion9 View Post
    You will need to process the API on the server-side. You will not be able to post an HTML directly to the API based on their documentation.
    How can i do that?

  6. #6
    Join Date
    Dec 2005
    Posts
    2,984
    Submit the form to a script that you write on your server and then send a POST request to the hostel world server.

    The following will help you do it in PHP:
    http://www.jonasjohn.de/snippets/php/post-request.htm
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  7. #7
    Join Date
    May 2010
    Posts
    4

    Thumbs up

    Quote Originally Posted by aj_nsc View Post
    Submit the form to a script that you write on your server and then send a POST request to the hostel world server.

    The following will help you do it in PHP:
    http://www.jonasjohn.de/snippets/php/post-request.htm
    Thank you, this really help me. When i was googeling for my problem i found the site you sugest me a lot of time, but when i was trying i must have done something wrong. Now i think i resolved my problem. Really thank you to all for helping me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles