Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

basic url call script

Featured Replies

Hi im in the process of creating a site and was woundering if thier are any basic mysql/php free scripts out thier that allow me to add urls to a database with a brief description and picture, i want this to be a ery basic structure so that i can learn from it to go onto more complex solutions.

Don't forget that when inserting certain characters into mysql they need to be escaped,you will find examples here

 

Particularly important when dealing with urls as they often contain characters that need to escaped.

Hi im in the process of creating a site and was woundering if thier are any basic mysql/php free scripts out thier that allow me to add urls to a database with a brief description and picture, i want this to be a ery basic structure so that i can learn from it to go onto more complex solutions.

 

Here are few tutorials, you can have a look at these links too..

http://www.php-mysql-tutorial.com/mysql-insert-php.php

http://teamtutorials.com/web-development-t...abase-using-php

 

Few links where you can get your required scripts..

http://www.scriptsbank.com/PHP_Scripts/Ima...ries/more3.html

http://www.yourfreescripts.com/detail/3416...-and-mysql.html

http://www.hotscripts.com/PHP/Scripts_and_...ries/index.html

  • Author

Thanks guys for your help i have managed to set up almost what i want.

 

Now i would like advise on a simalar subject, as part of the mysql script i would like to hide the actual link as alot of them will be affiliate links, would it be best to just link this to my .htaccess or is thier away round it i havnt thought of?

proberbly the easiest way is to use md5()

 

you would then display your links somthing like so:

 

$rs = mysql_query("SELECT url, title FROM links");
while ($row = mysql_fetch_array($rs)) {
echo '<a href="link.php?goto='.md5($row['url']).'">'.$row['title'].'</a><br />';
}

Basically just show an md5 checksum of the url rather than the url itself.

 

The code for link.php would be somthing like this:

$rs = mysql_query("SELECT url FROM links WHERE MD5(url) = '".$_GET['goto']."'");
$url = mysql_result($rs, 0);
header("Location: $url");
exit();

This would take the $_GET['goto'] checksum and search for it in the database, returning the url and sending the browers to it.

I think you can use the mysql MD5() function like ive shown, else you would have to loop through the results and compare them instead.

 

Ofcourse you should add some validation in there as anything passed in $_GET['goto'] that does exist would cause and error on this script. But im just showing the basic principle.

 

I hope ive understood you correctly and this helps you achieve what you need.

  • Author
proberbly the easiest way is to use md5()

 

you would then display your links somthing like so:

 

$rs = mysql_query("SELECT url, title FROM links");
while ($row = mysql_fetch_array($rs)) {
echo '<a href="link.php?goto='.md5($row['url']).'">'.$row['title'].'</a><br />';
}

Basically just show an md5 checksum of the url rather than the url itself.

 

The code for link.php would be somthing like this:

$rs = mysql_query("SELECT url FROM links WHERE MD5(url) = '".$_GET['goto']."'");
$url = mysql_result($rs, 0);
header("Location: $url");
exit();

This would take the $_GET['goto'] checksum and search for it in the database, returning the url and sending the browers to it.

I think you can use the mysql MD5() function like ive shown, else you would have to loop through the results and compare them instead.

 

Ofcourse you should add some validation in there as anything passed in $_GET['goto'] that does exist would cause and error on this script. But im just showing the basic principle.

 

I hope ive understood you correctly and this helps you achieve what you need.

 

Hi thanks for this but if i just use the "$_GET" straight to mysql wouldnt that leave me open to hackers and security flaws?

Yes it would leave you open to mysql injections but i provided it as a quick example to show you and i wrote it really quickly.

You should definatly improve on the code by adding mysql_escape_string() or your own choice of function.

I tried to keep it very basic to make it easy to understand, i was unaware of your PHP knowledge. There are validation issues you should cover too. For example you should cover for URL's that dont exist in the database, the easiest way is to use mysql_num_rows

 

$rs = mysql_query("SELECT url FROM links WHERE MD5(url) = '".$_GET['goto']."'");
if(mysql_num_rows($rs) < 1) {
 // The requested link is not in the database
 // Do some error or whatever
}
else {
 $url = mysql_result($rs, 0);
 header("Location: $url");
 exit();
}

  • Author

Thanks,i do only have a basicknowlege of this but im a quick learner and appreciate the help. That is agreat help as i would not have thought about that one, so many pit holes!!!

:o

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.