Ryan,

As usual, telling us more about the project will help. I'm a little confused about the key -- is it just a unique key, or is it some form of password, or somewhere in between?

Let's look at the flow...

1.      You send your pal a key in an email or whatever like so:
        http://www.site.com/view.php?key=123457890

2. they go to that URL, and view the message


What I don't understand is why the key needs to be so complicated. Surely starting at 1 and incrementing is enough? MySQL's in-built auto-increment makes life very easy to have a numbered unique key :)


Or perhaps you want something less predictable... like PHP's unique key function:
http://www.php.net/manual/en/function.uniqid.php



Before you even bother figuring out the queries, take a step back, and think long and hard about what you're trying to achieve. You sound like you're trying to invent something secure, but in reality, it's a mess, with predictable, plain-text keys.



If I wanted to publish a list of secret messages on a website, each message would have a unique ID (starting at one, and incrementing), a password (*at least* stored as an md5(), and not transmitted with the id), and finally the message field.


Even then, I still don't get it, so perhaps you need to tell us more.


Justin French



On Tuesday, December 16, 2003, at 05:43 AM, Ryan A wrote:


Hi,
I am making a personal project like so:

I enter something in the text box (eg. "PHP REALLLLLLY ROCKS!!!")
then the program checks if that string already exists in the database, if
no, then it should enter it into the database and also generate a "key"
This key can be given to pals and they can read the "secret message"


Key:
Key should first be 1-1000 then a-z then A-Z then axxx (eg: a001, the xxx
will always be numbers) once it reaches 999 it should become Axxx then b
then B etc after a,A,b,B are done it should go for aaxx,AAxx etc always 4
characters


A few questions:
1.Looking at the above (database part) I figured that doing this via a mysql
database would be better rather than a text database...do you agree?


2.I was thinking of making the "key" field a primary key and unique and
indexed....right?

3.The way I see it theres 3 sql statements that need to be run, a) connect
and see if string exists b)read the last key c)write to the
database...anyway to break the above to 2 statements or am I following this
wrong?


4. Logic for the key, I am coming up with crummy logic to make the "key",
basically a block of code for 1-1000,another block for a-z another block for
A-Z etc...... any ideas,links,URLs or code snippets off the top of your head
would be greatly appreciated.



Thanks in advance.


Cheers,
-Ryan

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to