I have an article directory, but on the page where an author submits an article I would also like the contents of the form to be sent to an email address. Is this possible, and would it be relatively esay to configure? Thanks for any help.
Thanks for the reply rehash. What I forgot to mention was that I would like the article to still be sent to the database. So on submission, the article would be sent to the database as it is at the moment, and also a copy would be sent to my email address. At the minute, the form action is as follows: <form name=submitarticle action=submitarticles.php method=post> I guess there's a lot to it, but I hope I'll be able to configure this to work.
I think that should work, I'm very new to php and don't know if there is a better way to do it. Maybe you need to some stringreplace or n12br or something like that since I don't know how mysql handles line breaks. Daniel
To give a clue what the code looks like at the moment i've attached it below. This is probably more difficult but can a checkbox option be added so if it is checked then the article is also sent to my email, but if it is left unchecked then it will just be sent to the database as it is currently? Thanks for helping, i really appreciate it. Code:
Daniel's script should work, but there's one other thing to consider when adding it to a DB. Look here: $result = MYSQL_QUERY("INSERT INTO tablenamehere (id, author, title, article) VALUE ('NULL', '$author', '$title', '$article')"); Yes, this will add in the values, but what if the title or article uses PHP reserved characters? Apostrophes, etc. get jacked up if you try to do a straight insert. I had this problem with one of the names of tile that my company produces...it's called Perle D'Alpi (don't ask...it's some Italian name that Marketing dreamed up). Anyway, the apostrophe threw everything for a loop. So, I added in PHP's built-in functions of AddSlashes() and StripSlashes(). These scripts look for, and escape with a "\" character, any problematic characters in a string. Here's how to use it... $auth = StripSlashes($author); Then replace $author with $auth in your query value. I tried assigning something like $author = StripSlashes($author) in my own experience, but it didn't like it, so a new variable seems to be a better option for some odd reason. To get it back from the DB, just use the same procedure, but before echoing the variable to the screen, perform the AddSlashes($author); function to strip out those escape characters that were squirted in the string before storing it in the DB. Hope this helps. Full documentation can be found in php.net's online manual.