0
php form passing??????? Please someone that knows how to do it????
here is my html form code <form action="contacts.php" method="post"> E-mail: <input type="text" name="email" placeholder="Subscribe to our page for the latest News & Updates"> <input type="submit" value="Subscribe" > </form> alls i neeedddd.......is the user to input their email address......and have it save to the "contacts.php" txt file i have saved to my desktop!!! I have been at this for two days and really need it!!! Can someone just tell me what code i have to put in the contacts.php txt file on my desktop in order to save users emails???????? Thats all i need please
3 Respostas
+ 5
What you want to do is very easy.
Basically this code receives what you send through your form and stores it in the $ email variable. Then try to access the file, if it does not exist then create a new one, and in case of not being able to print an error and finish the execution. Then he writes the content, closes the file and notifies that everything went well.
In this example you have to change the route by the corresponding on your computer.
Use the 'a +' mode to open the file only because it places the pointer at the end of the file. That way you do not rewrite the contents of the file in each execution.
You still have to fix some details like the format in which the emails will be written inside the file, but I leave that to you.
<?php
$email = $_POST['email'];
$file = fopen('C:\Users\Mickel\Desktop\email.txt', 'a+') or die('Error opening the file.');
fwrite($file, $email);
fclose($file);
echo 'Done!';
?>
+ 5
Btw, I'm sure I've seen a thread similar to this early. I remember it because I was going to comment and I didn't it because someone was already helping.
+ 1
ill try this thanks