Thanks, but recipient address every time is different. I have about 100 pages with different email addresses, that send to mail.php
PHP form - how to hide recipient address
start a session:
<?php
session_start();
// save the address in a session variable.
$_SESSION["recipient"]= "an email address";
?>
and in mail.php
<?php
session_start();
if(empty($_SESSION["recipient"]))
die("recipient is empty");
$emailadd = $_SESSION["recipient"];
// ...
?>
And use the real php bb tags around your php scripts, please. Its the first icon from the right side.
Thanks for the help
Really appreciate it.
Another question - is it possible to save into a file (csv, excel or txt format) users email addresses from contact form?
Thanks
Tali
Its a better choice if you save them into a database.
However you need simple store, save the file outer from your public folder.
if(isset($_POST["email"]))
file_put_contents("../emails.txt" , htmlspecialchars($_POST["email"]) . "\n\r" , FILE_APPEND );
Yes, to save it into database could be even better.
This line will create a file and save form to the file?
Thanks
Yes it can make it, but only the $_POST["email"] only.
I tried it - it doesn't save any data. The file is empty
Thanks
in the example, you filnd: "../emails.txt"
Lets correct this file to a real folder, and be sure its safe from the internet.
Yes, i changed the path - it's in the same folder, so i put just "emails.txt"
But nothing in there
then you don't have permission to write.
yes, changed permissions to "write" in all the groups, it saves now.
Will it add a new email address every time and save the file?
Thanks
yes, i see it add and saves
Thanks for the help
but notice that if i quess file names from your server and matched , i get all your email addresses. Lets add a "safe from web" folder, ask a new thread how to make one.
inserting into an email table (database ) makes this project a bit safer, with lots of advantages. And collecting email addresses without a warn in our contry is a crime. You should forewarn the visitor that his personal information will be logged.