Well on my site (In my sig) I have a page where the user submits their email.
Is there a way I can save the submitted emails to a file, so if that email has already been sent, it cant be submitted again?
Hopefully that makes sense.
Thank you, that worked!
I just have one other question.
I am using that to save the sent emails to a file, but its running them all together (
[email protected]@
[email protected] etc.)
How can I make it put them on separate lines?
Nevermind, I got it
(2010-02-01, 06:09 PM)Joshee Wrote: [ -> ]Thank you, that worked!
I just have one other question.
I am using that to save the sent emails to a file, but its running them all together ([email protected]@[email protected] etc.)
How can I make it put them on separate lines?
Nevermind, I got it
file_put_contents("file", "email\n", FILE_APPEND);
Just out of curiosity, wouldn't a MySQL database be more suitable for this?
That would probably help me with what I am trying to do.
I am trying to save the emails to a file, and then have the form check that file to see if the email has already been submitted. If it has, it displays an error message saying so.
I would make sure that you use .htaccess so that the file can't be accessed directly (or move it above public_html) - I don't think users would be happy if their emails were stored in an accessible plaintext file.
If it's a form that stores only emails, you should not make it a file else spiders might harvest the mails (which you don't want).
.htaccess protection over the file or directory or placing it outside of public_html is certainly a workaround, but using a database backend would be much easier to handle (generally).
Set up a default HTML form, grab all the content using $_POST (or $_REQUEST, refer to php.net), I personally like using a ;save extension through $_GET to check if $_POST is sent, but you could always just check if the array is empty or not, so it doesn't matter...
At that point you'd just connect to the db, run a query, close the query, and exit. There are a lot of tutorials that explain the process of making an SQL connection.
You could then run a num_row or fetch_row or run an fetch_assoc and store all the content into an array map, and then check based on the key existance through a pattern (though personally I like the idea of using num_row to see if the mail exists (this is not having the id as the key)).
-Ygg
(2010-02-03, 03:14 AM)Yggdrasil Wrote: [ -> ]If it's a form that stores only emails, you should not make it a file else spiders might harvest the mails (which you don't want).
.htaccess protection over the file or directory or placing it outside of public_html is certainly a workaround, but using a database backend would be much easier to handle (generally).
Set up a default HTML form, grab all the content using $_POST (or $_REQUEST, refer to php.net), I personally like using a ;save extension through $_GET to check if $_POST is sent, but you could always just check if the array is empty or not, so it doesn't matter...
At that point you'd just connect to the db, run a query, close the query, and exit. There are a lot of tutorials that explain the process of making an SQL connection.
You could then run a num_row or fetch_row or run an fetch_assoc and store all the content into an array map, and then check based on the key existance through a pattern (though personally I like the idea of using num_row to see if the mail exists (this is not having the id as the key)).
-Ygg
Okay, I'm sorry, but that made absolutely no sense to me. I dont know any PHP or anything like that.
If you want an example (unsanitized, beware) of a simple MySQL connection & query, check out my name logger code:
http://community.mybboard.net/thread-64268.html
Not perfect by any means but if I can understand some of this stuff in 2 nights I'm sure you can in a few too