homepage Welcome to WebmasterWorld Guest from 174.129.103.100
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Confirmation email link without a database
Email stored in temp file, then saved to new on confirmation
fredfletcher




msg:4462778
 3:11 am on Jun 8, 2012 (gmt 0)

I realize that this question has been asked many times, but I've yet to find a flatfile version.

I'm looking for a way to achieve this:

Scenario:

A person submits their email address via a form.

The email is then stored in flatfile database (.txt)

The person then gets an auto-reply email with a link to confirm their email address.

Upon confirming after clicking the link, their email address is saved to a new file (confirmed_emails.txt for example).

Is this possible without the use of a SQL/similar datase, and how can I achieve this?

Note: SQL or other database option, is not an option unfortunately.

 

incrediBILL




msg:4462854
 9:36 am on Jun 8, 2012 (gmt 0)

It's quite trivial really.

Write the original contents in a file named email_address.txt and when they confirm it rename it to confirmed_email_address.

I'd probably use an MD5 version of the email address to avoid the special characters that can be in email addresses that can cause trouble.

rocknbil




msg:4462988
 3:52 pm on Jun 8, 2012 (gmt 0)

The tools you will use are PHP mail() [php.net] and file_get_contents() [us2.php.net] or if you're on an old version of PHP, fopen() [us2.php.net] and related functions described in See Also section.

You'd likely have two scripts, one to initiate the mail and store the email in the first file, one to receive the input from the email link.

I would also suggest storing this file in a location inaccessible from the web and only from your script to avoid someone stumbling on it and mining your email addresses.

fredfletcher




msg:4463734
 1:10 am on Jun 11, 2012 (gmt 0)

What would an inaccessible folder be, one such as cgi-bin maybe?

rocknbil




msg:4463984
 4:11 pm on Jun 11, 2012 (gmt 0)

Generally no. cgi-bin is usually for CGI executables or scripts. For example, on some systems perl scripts will only execute if they reside in the cgi-bin directory, but it's still accessible via the web.

It depends on the setup. Your "visible" (from the web) might reside in public_html, so you possibly have

_private
_vti_bin
_vti_cnf
_vti_pvt
_vti_log
_vti_txt
cgi-bin
images
includes
somescript.php
index.php

Of those, only "_private" is a viable location within the "public_html" directory to store such files. It's not browsable, that's why it's "private."

Even that may have issues, another approach might be to store the file somewhere **outside** public_html, if you can and are allowed.

This is just one setup, like I said it depends on the system.

fredfletcher




msg:4464004
 4:37 pm on Jun 11, 2012 (gmt 0)

Unfortunately I don't. Is there a way to do it with .htaccess?

coopster




msg:4464393
 2:31 pm on Jun 12, 2012 (gmt 0)

You can restrict access to a directory or even a file using Apache configuration directives. See the following resources for more information:

Apache 2.2
[httpd.apache.org...]

Apache 2.4
[httpd.apache.org...]

rlange




msg:4464404
 2:42 pm on Jun 12, 2012 (gmt 0)

fredfletcher wrote:
Note: SQL or other database option, is not an option unfortunately.

Not even SQLite?

--
Ryan

fredfletcher




msg:4464651
 2:01 am on Jun 13, 2012 (gmt 0)

@Ryan - SQLite might be an option. Am looking into it, thanks.

fredfletcher




msg:4464652
 2:02 am on Jun 13, 2012 (gmt 0)

Thanks for the info Coopster

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved