Jump to content

[SOLVED] Using md5(or md4?) to create a unique hash, help please


Recommended Posts

Hey guys, I want to create new pages on my site. However, I want the pages to be like so:

 

www.mysite.com/.../989said9asdua9s-the-title-of-my-page.html

 

So I am trying to create a url with the title words in it.

But I want to take precautions incase I end up making 2 pages with the same name.

So i want the random number part (989said9asdua9s) to be unique for every title string.

 

Would this work:

check if the title is unique, if it is then the url is just:

md4/5(title).urlencode(title).".html";

If the title is not unique, I add some random string/numbers to the title inside of the md4/5, and the url is:

md4/5(title.randomString()).urlencode(title).".html";

//I would make randomstring as a function.

So I would loop this until the url is unique. Does that sound like a good plan? or could something go horribly wrong that I do not see.

 

I don't want the random string to be too long, and so is md4 or md5 right for this?

 

or does anyone have any other suggestions? thanks!!

 

EDIT: incase of appending random strings, I could just append something unique to the page, such as it's ID or whatever... So the question becomes, is md5/4 good for this? Is this a good idea? Is there a better way?

Why are you creating static pages? Is the content not stored in a database?

If so you only require 1 file. A mod-rewrite, can include the page name in the url. Use the primary key as the page identifier i.e

 

/page-title/23.html

/another-page-title/24.html

 

Both pages are index.php?id=

Can you explain what you mean exactly when you say I only need one file?

 

Say each of my files can be generated from a "pageid" from a database, I thought I had to create many different pages like this:

 

<?php
$pageid = 8;
include("genericpage");
?>

 

How do I do it like you are saying?

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.