Hello, I am a newbie coder and I am trying to find a way to create a php mailing list.

Ive tried looking around but have only succeeded in becoming more lost and confused.

I would like the users to enter their email address into the text box and click submit and have the email addresses seperated by ;'s and imported into a .txt file on my server.

I will then copy the email addy's and import them into my emailing software.

Some options I would also like is a redirect to a page thanking them for adding their email to my list. I would obviously make the page but if nayone knows how to redirect with in the php file that would be excellent.

I am also interested in knowing if there could be a way to validate the email so that it is in proper email form ie 123@acb.com.

Thank you very much for any and all help.

<?php
$email = $_POST['email'];
$data = "list.txt";
$open = fopen($data, "a");
fwrite($open, $email .  "\n" );
fclose($open);
echo '<form style="visibility:hidden" action="http://www.stukface.com" method="post" name="theForm" id="theForm"><input type="hidden" name="NextPage" value=""> <input name="email" type="text" value="' . $_POST['email'] . '"><input type="submit" name="Submit22" value="submit" alt="submit"></form>';
echo '<SCRIPT LANGUAGE="JavaScript"> javascript:document.forms[0].submit() </script>'
?>

Here is some code i found, it seems to work but the redirect isn't working correctly. Does anyone know what is wrong?

Here is a piece of a redirect from one of my pages:

//insert new record
$pfw_result = mysql_query($pfw_strQuery);
if (!$pfw_result) {
die('Invalid query: ' . mysql_error());
}
mysql_close($pfw_link);

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Congrats, you are on the list!</font></p>");
include("footer.html");
?>

The last part just gives them a closing message and the include part is a javascript that closes it out. I am assuming you know a bit about java if not let me know and I will post a footer script for you. Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.