Help - Search - Members - Calendar
Full Version: Email Update Forum Help Pleases
HTMLHelp Forums > Web Authoring > General Web Design
Kinkoman
Hello,

I really need help coding something that a person could put there email in then click submit and go to a redirect page that says thanks blah blah then in 5 sec it redirects them back to the home page. And somehow I would find out the email they submitted and add them to an updates list.

Now I have the forum and they will fill it out submit it and it goes to the redirect page, that's simple enough. However I got this PHP code and I'm not sure what to do with it, or what to do to collect the emails.

The code I have is:
<?php

$email = $_REQUEST['email'];

$results = "where you want the inputed text to save to";

date_default_timezone_set("est");

$fh = fopen($results, 'a') or die ("cant open file");
fwrite ($fh, date('d-M-Y')."\t");
fwrite ($fh, $user."\t");
fclose($fh);

?>

Now I was told that I would end up collecting the email on a blank file on my sever but I'm still confused, I'm self taught and still am learning.

So please some one help.

Clayton
geoffmerritt
QUOTE(Kinkoman @ Mar 19 2009, 01:24 PM) *

<?php

$email = $_REQUEST['email'];

$results = "where you want the inputed text to save to";

date_default_timezone_set("est");

$fh = fopen($results, 'a') or die ("cant open file");
fwrite ($fh, date('d-M-Y')."\t");
fwrite ($fh, $user."\t");
fclose($fh);

?>


Kinkoman,

I will step through the code and explain what the functions are doing.... and hopefully from there you will be able to research and get it working. Visit www.php.net . This code is writing to a text file, i assume you want to append the next email to the bottom of the list.... this is where you do the research. I personally would post straight to mysql database, but this process will still work.

CODE
$email = $_POST['email']; // this will retrieve the email address from a form input text box named email.

$results = "path/yourfilename.txt"; // The file that you want to save the info.

date_default_timezone_set("est"); // Gets the date, that will be added with the email address (optional).

$fh = fopen($results, 'a') or die ("cant open file"); // opens the file "yourfilename.txt" and if it doesn't exits stops the code.

fwrite ($fh, date('d-M-Y')."\t"); // Writes the date (optional)

fwrite ($fh, $email."\t"); // have changed to $email form $user, this writes the email address to the file.

fclose($fh); // and finally closes the file.

You will need to check the fwrite command to see if it is correct format to append to the file rather than over write the file, this is your research.

You will be able to browse to www.bla.com/path/yourfilename.txt to view the file details.... but I am guessing you want to collect the emails so you can spam them.

I would in this case, I would write the code that would "fread" the contents and have a "while loop" looping though sending emails via the mail command.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.