Forums

PHP

This topic is locked

PHP + mySQL + auto-increment + email

Posted 21 May 2008 03:40:04
1
has voted
21 May 2008 03:40:04 Peter Pan posted:
Hi,

Background: Dreamweaver, a PHP page, and a mySQL database.

When submitting a form, I shoot off an e-mail to the e-mail address entered in the form. The form's content is also written to a table in a database (mySQL), where the key in the table is created by auto-increment. So far so good.
Now, the e-mail that was sent upon submit - I want to put the key from record just created in the subject of this e-mail. Any good ideas how to do this? I guess the record key is only created in split seconds after I post, so I'll have to 'wait' to send the email - but I'll need to know which key was just created... - hmm...

Any ideas?

Thanks,
Anders

Replies

Replied 21 May 2008 10:06:30
21 May 2008 10:06:30 Alan C replied:
HI
sounds like something to do with user registration, and maybe getting the user to verify their email address by clicking a link

I've got something similar on one of my sites, I generate a random number, take the md5 digest of it and stick that into a field in the record along with the username and md5 of the password, then assemble a link to my user verification script, the link contains the md5 of the random number and gets sent in an email.

When the new user gets the email they click the link, are taken to the verify script which accesses the database looking for the record that contains the appropriate username, email and random number md5. Once that's verified the random number gets cleared from the field and replaced by some other details.

This was based on a tutorial I found at evolt.org with huge modification.

Replied 22 May 2008 16:26:16
22 May 2008 16:26:16 Peter Pan replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
HI
sounds like something to do with user registration, and maybe getting the user to verify their email address by clicking a link

I've got something similar on one of my sites, I generate a random number, take the md5 digest of it and stick that into a field in the record along with the username and md5 of the password, then assemble a link to my user verification script, the link contains the md5 of the random number and gets sent in an email.

When the new user gets the email they click the link, are taken to the verify script which accesses the database looking for the record that contains the appropriate username, email and random number md5. Once that's verified the random number gets cleared from the field and replaced by some other details.

This was based on a tutorial I found at evolt.org with huge modification.


<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

It's not user registration/verification, but your suggestion solves my problem! A any unique random number is fine, because it makes me able to identify that specific submission. I can take the md5 of the current time + the email address, and that will be unique.

Thanks a lot!

Reply to this topic