|
Posted by Hilarion on 09/13/05 18:09
> I'm trying to create a script to verify an email address after a user
> signs up for an account. I would like the user to get an email with a
> link that they click on (something like
> www.webaddress.com/12453523/7573434) and that funnels through and marks
> their email address as verified in the mysql database.
>
> The thing I'm having trouble with is the /12453523/7573434 part. How
> do those arguments get grabbed by the script? Does the verify script
> actually create those directories on the web server, and then copy an
> index file at the bottommost directory which verifies the email? It's
> fairly straightforward to create one that uses something like
> www.webaddress.com/?u=12453523&p=7573434, but I'd really like it the
> other way.
>
> Can anyone point me to an example script which might help me?
You can do it at least two ways.
One is to use rewrite rules of the webserver, which change the URL from
http://www.webaddress.com/12453523/7573434 to
http://www.webaddress.com/?u=12453523&p=7573434 on the fly, which allows
you to treat the URL parts as parameters. You should look at your
webserver documentation to check this possibility.
Other one is in pure (almost) PHP. If you have "verify.php" script
on website root folder, then it's also executed if you treat it
as folder in URL: http://www.webaddress.com/verify.php/12453523/7573434
In the script you can parse the URL to get the values passed in it.
In both solutions you'll have to remember that when user enters
such URL in his browser (by clicking on a link in the e-mail or
any other way), then the browser treats your parameters (/12453523/7573434)
as a path and all relative paths given in the HTML document available
under this web address are calculated basing on those folders.
So if you use <img src="imgs/some_image.jpeg" /> in this script,
then the browser will try to get it from:
http://www.webaddress.com/12453523/imgs/some_image.jpeg
or http://www.webaddress.com/verify.php/12453523/imgs/some_image.jpeg
(the last part "7573434" is considered to be a file, not a folder,
so it's stripped from the path) which is probably not something
you would like. In this case you'll have to use absolute URLs
(like "/imgs/some_image.jpeg" or http://www.webaddress.com/imgs/some_image.jpeg)
in the script or use relative paths regarding the situation
(like "../imgs/some_image.jpeg") or use rewrite rules to strip the
"12453523/" part from the URL (but remember not to do it if the
request is to the oryginal script), or write "verify.php" script
to also pass the image contents to the browser when it's called this
way, not only to deal with the oryginal request.
I prefer the PHP way (not the rewrite rules) with absolute paths
or relative paths adjusted to the situation.
Hilarion
Navigation:
[Reply to this message]
|