Solved

PHP mailing list functionality

Posted on 2007-03-25
6
163 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

816 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now