Jump to content
aveeva

PHP Script - How to track courier service using tracking number from my website

Recommended Posts

I need like,

http://www.trackcourier.in/

The customer chooses selected courier service and enters tracking id then clicks its redirect to the appropriate courier service website.

eg: If tracking id 12345 the redirect link should be https://www.fedex.com/apps/fedextrack/index.html?tracknumbers=12345&cntry_code=in

How to do for India courier services?

Share this post


Link to post
Share on other sites

Note the tracking URL for the services you want to support. Most of them use GET, some use POST, some use POST but actually support GET too. Then insert the tracking code in the right spot.

Share this post


Link to post
Share on other sites

Think. This is not a difficult question. I know you can find the answer.

Share this post


Link to post
Share on other sites

@requinix   

Here is my code,

<!DOCTYPE HTML>
<html>  
<body>

<form action="#" method="post">
Select Courier :
<select name="courier">
  <option value="">--Please choose an option--</option>
  <option value="professional_courier">Professional Courier</option>
  <option value="india_post">India Post</option>
</select>

Trackingid: <input type="text" name="trackingid"><br>
<input type="submit">

</form>



<?php 
if (!empty($_POST)): header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=".$_POST["trackingid"]."&type=0&service=0");
endif;
?>

</body>
</html>

 

How to track more than one service, now my code track only one service, how can i add india post if customer choose india post courier service url: https://www.indiapost.gov.in/_layouts/15/dop.portal.tracking/trackconsignment.aspx

 

Share this post


Link to post
Share on other sites

Create a drop down list of the services.  When the user picks one from the list go back to the php script with that choice and the id number and build the url from an array of them keyed by the items in that dropdown list.  Then use a header() call to go to their website.

Share this post


Link to post
Share on other sites
On 11/29/2019 at 7:40 PM, ginerjm said:

Create a drop down list of the services.  When the user picks one from the list go back to the php script with that choice and the id number and build the url from an array of them keyed by the items in that dropdown list.  Then use a header() call to go to their website.

My final code :

 

<!DOCTYPE HTML>
<html>  
<body>

<form action="#" method="POST">
Select Courier :
<select name="courier">
  <option value="">--Please choose an option--</option>
  <option value="professional_courier">Professional Courier</option>
  <option value="india_post">India Post</option>
</select>

Trackingid: <input type="text" name="trackingid">
<input type="submit">

</form>

<?php
if(isset($_POST['courier']))
{
	if(isset($_POST['professional_courier']))
	{
		if (!empty($_POST)): header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=".$_POST["trackingid"]."&type=0&service=0");
	}

	else(isset($_POST['india_post']))
	{
		if (!empty($_POST)): header("Location: https://www.dhl.com/en/express/tracking.html?AWB=".$_POST["trackingid"]."&brand=DHL");
	}	
}
?>
</body>
</html>

 

Any help, thanks.

Share this post


Link to post
Share on other sites

 

Finally working, thanks to everyone.

<!DOCTYPE HTML>
<html>

<body>

	<form action="#" method="POST">
		Select Courier :
		<select name="courier">
			<option value="">--Please choose an option--</option>
			<option value="professional_courier">Professional Courier</option>
			<option value="india_post">India Post</option>
		</select>

		Trackingid: <input type="text" name="trackingid">
		<input type="submit">

	</form>

	<?php
	if (isset($_POST['courier'])) {
		if ('professional_courier' === $_POST['courier']) {
			header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0");
		} else if ('india_post' === $_POST['courier']) {
			header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL");
		}
	}
	?>
</body>

</html>

 

Share this post


Link to post
Share on other sites

You don't have anything in you input form with the name = "professional_courier" or name = "india_post", so $_POST['professional_courier'] and $_POST['india_post'] never exist.

You should, therefore, be seeing messages that those $_POST indexes do not exist. If not, turn on your error reporting so you are not continually stabbing in the dark.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.