Username:
Password:
Remember me:
Register

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)


Search forums via Google


0 Users appreciate this thread.

Help Needed
Started by ~Justin~
(2014-09-02 18:35:19)
~Justin~ (2014-09-02 18:35:19)
I will be releasing my site soon; I want a feature to shorten urls. I can't figure it out. If someone could explain, I thank you.
Also make an image like an ID that shows user info o3o

This post has been edited one or more times, the last time was:
2014-09-03 01:56:37

CoolApps (2014-09-02 21:14:53)
I have created my own URL shortening service, and seems pretty straight-forward.
You have to grab the generated string (look for the PHP code online) using PHP, insert it into the database where the shortened version, the full URL and such is.
You of course have to use $_GET for entering the shortened string which afterwards get's echoed into the header or meta to get you redirected. I would use exit() to make sure the rest of the script doesn't show. You can make the URL clean looking as well if you want (like other URL shorteners).

Tip: Make sure certain sections of the script has the title tags, you MUST NOT use it for the redirect part or the browser will not store the title from the page that it was redirected to previously.


You do need to check if certain things exist or not to avoid issues.



The logic?


You mainly need the PHP generated string to be inserted along with the original URL so putting that in the $_GET request will have to be escaped and places into the query like "SELECT * FROM urlbase WHERE srturl='$getty'" (note that $getty is $_GET and also escaped).
There, you can use the result count function to see if it exists or not (1 is the max and 0 is the min meaning 0 means none and 1 means it exists).
You have to grab a row from that query which contains the full version of the URL that you then echo out into a redirect code (header).

This post has been edited one or more times, the last time was:
2014-09-03 16:52:02

Newer account: NodePoint
 

Log in to submit a comment

This topic's ID: 76060

Back to forum: Web Programming (HTML, JS, CSS, PHP, MySQL)




Total registered users: 8321
New registered users today: 7
Newest registered user: ElegantVulpes

©  Copyright 2026 3DSPlaza. All Rights Reserved