Email submission php to the max

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
StupidIdiot
Forum Newbie
Posts: 2
Joined: Wed Jun 18, 2008 5:56 am

Email submission php to the max

Post by StupidIdiot »

I know almost nothing about php (and only a small amount of html), but I'm making a website for my band (not that we'll be taking over the world any time soon), and need to use php for some things.

While the site is "under construction", I want to have a page up that allows visitors to input their email address so that I can email them when it is done, and also when we upload a new song etc etc.

I've called the page "index.htm" (because it'll be the main page up until the rest is done). In index.htm I have this:

Code: Select all

<form action="email.php" method="post"></form>
at the start of the input box. I don't know if this is right...

Then for "email.php" I have:

Code: Select all

<?php
$email_list = ("email.txt");
$emails = file($email_list);
$fp = fopen($email_list , "a");
fputs($fp , "$new_email");
fclose($fp);
?>
I don't know what's going on really, just robbed it from various tutorials.

How do I assign the variable "$new_email" to the email address that has just been entered? So when someone enters their email I want it to equal $new_email.
Also are email.php and index.htm even right?

Any help is very much appreciated
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: Email submission php to the max

Post by WebbieDave »

Change index.html to:

Code: Select all

<form action="email.php" method="post">
    <input type="text" name="new_email">
    <input type="submit" value="Join Mailing List">
</form>
On email.php, replace line 3 (you don't need to use the file() function in this script) with:

Code: Select all

$new_email = $_REQUEST['new_email'];
Change line 5 to:

Code: Select all

fputs($fp , "$new_email\n");
Keep rockin...
StupidIdiot
Forum Newbie
Posts: 2
Joined: Wed Jun 18, 2008 5:56 am

Re: Email submission php to the max

Post by StupidIdiot »

Thanks hugely Dave, I was like this :? right, then eventually I was giving it :banghead:, but now thanks to you I'm :drunk: (with happiness).

Made good use of smilies there
Post Reply