Solved

PHP mailing list functionality

Posted on 2007-03-25
6
166 Views
Last Modified: 2008-03-06
I am new to PHP and I am searching for code to embed into my webpage that will do several things:

1. Create a form that gets a visitor's name and email address (has a 'Submit' button).
2. Adds the name and email to a list (maybe just a txt document or a database). --> Note: I don't have a database set up, and I do not know how to code one (so I would need a lot of code for this option).
3. When the submit button is clicked, an email is sent to me (xxxxxx@yahoo.com) with the updated list of emails as the body of the email. The subject is : "New member has joined"

Can you please provide code. It will really help me. Thank you so much.
0
Comment
Question by:jrwalker2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 2

Expert Comment

by:bandolex2
ID: 18791151
Ask in PHP forum, this is ASP.
0
 
LVL 1

Author Comment

by:jrwalker2
ID: 18791217
I have asked in a PHP forum also. If you can answer my question with ASP, I welcome the solution. I am simply searching for people who are willing to help me with my problem. Thank you
0
 
LVL 2

Expert Comment

by:bandolex2
ID: 18791239
Is not really that simple, code in asp is totally different to php and what you need to do involves a lot of stuff ... if youre using a linux hosting you should stick to php forum, there's plenty of people that will gladly help you there.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Accepted Solution

by:
raja_ind82 earned 500 total points
ID: 18791613
<?php
if(isset($_POST['btnsubmit']))
{
      $fromAddress= "admin@yoursite.com";
      $toAddress= "youmail@yoursite.com";
                     $subject= "New member has joined";
      $firstName= $_POST['txtfirstname'];
      $lastName= $_POST['txtlastname'];
      $emailAddress= $_POST['txtemail'];
 
$content = <<<EOD
$content
<html>
<head>
      <title>New User register!!!</title>
</head>
<table>
      <tr>
            <td>FirstName:</td>
            <td><b>%FNAME%<b></td>
      </tr>
      <tr>
            <td>LastName:</td>
            <td><b>%LNAME%<b></td>
      </tr>
      <tr>
            <td>EMail:</td>
            <td><b>%MAILADDRESS%<b></td>
      </tr>
      <tr>
            <td colspan='2'>Regards,<br>Support Team</td>
      </tr>
</table>
</html>
EOD;

$bodytag = str_replace("%FNAME%",$firstName,$content);
$bodytag = str_replace("%LNAME%",$lastName,$bodytag);
$bodytag = str_replace("%MAILADDRESS%",$emailAddress,$bodytag);
 
send_mail($fromaddress,$toaddress,$subject,$bodytag);
}

/*****FUNCTION TO SEND EMAIL STARTS*****/
function send_mail($fromaddress,$toaddress,$subject,$bodymessage)
{
      $headers  = "MIME-Version: 1.0\r\n";
      $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
      $headers .= "Content-type: text/html;\r\n";
      $headers .= "From: ".$fromaddress."\r\n";
      @mail($toaddress,$subject,$bodymessage,$headers);
      return true;
}
/*****FUNCTION TO SEND EMAIL ENDS*****/
?>

<HTML>
<HEAD>
<TITLE>Raja's Example</TITLE>
</HEAD>
<BODY>
<form name="frmname" action="send_mail2.php" method="POST">
<TABLE>
<TR>
      <TD>First Name:</TD>
      <TD><input type="text" name="txtfirstname"></TD>
</TR>
<TR>
      <TD>Last Name:</TD>
      <TD><input type="text" name="txtlastname"></TD>
</TR>
<TR>
      <TD>Email Address:</TD>
      <TD><input type="text" name="txtemail"></TD>
</TR>

<TR>
      <TD><input type="submit" name="btnsubmit" value="submit"></TD>
      <TD></TD>
</TR>
</TABLE>
</form>
</BODY>
</HTML>

Regards,
M.Raja
0
 
LVL 1

Author Comment

by:jrwalker2
ID: 18793586
Thank you so much raja_ind82! I have a followup question...I have an exisiting page (page.html). Do I rename it to page.php? Is there something special that I need to do to get this working (I have tried both .php and .htm and neither work)? Also, if I want it sent straight to my gmail account, can the set the variables like this?:

 $fromAddress= "admin@gmail.com";
 $toAddress= "xxxxxxxx@gmail.com";

where xxxxxxxx is my user name.
0
 
LVL 14

Expert Comment

by:raja_ind82
ID: 18801696
if you want to any php scripting in that, then rename it to "page.php".
you can set any type value in the to address. do you want to change this in dynamically.
if you want get form the database, using any id and can get the details from the database. if you have any specific question feel free to ask me....

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question