Solved

PHP mailing list functionality

Posted on 2007-03-25
6
161 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

896 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

13 Experts available now in Live!

Get 1:1 Help Now