Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-06-2009, 07:45 AM
jaison jaison is offline
Registered User
 
Join Date: Mar 2008
Posts: 5
News letter with php

How can i add a news letter option in my site using php. First i want to add the the name and email add to the database and thn later send news letters. pls help me or refer me to the proper place

jaison
Reply With Quote
  #2 (permalink)  
Old 01-06-2009, 11:43 AM
Chip Chip is offline
Registered User
 
Join Date: Jan 2009
Location: Cardiff
Posts: 6
well unless i've misunderstood what it is you want, this should be pretty simple:
You just need to have a simple form to ask the user for their details ie email address etc (remember to confirm email address) then add the details to the database:
mysql_query("INSERT INTO table VALUES value1, value2");
then when you want to send the news letter out to people you want an area to type your newsletter with a submit button, and have some code similar to this:
if(isset($_POST['submit'])
{
$query = mysql_query("SELECT emailaddress FROM table1");
while($row = mysql_fetch_array($query))
{
mail($row['email'], $subject, $newsletter);
// free the entry to save memory, can't rmember the command though...
}
}

hope thats at all useful?
Reply With Quote
  #3 (permalink)  
Old 01-06-2009, 08:35 PM
jaison jaison is offline
Registered User
 
Join Date: Mar 2008
Posts: 5
can u make it little more clear

can u make it little more clear, i want the same, but i can able to put the details in database, but i am not getting how to call the submitted email ids. If possible pls make different file with details

tks
Reply With Quote
  #4 (permalink)  
Old 01-07-2009, 06:45 AM
Chip Chip is offline
Registered User
 
Join Date: Jan 2009
Location: Cardiff
Posts: 6
First of all, make sure that you're familiar with the php/MySQL design http://www.w3schools.com/php/php_mysql_intro.asp

This process should be simple: take one form:
<form method='post' action='pagename.php'>
Email Address <input type='text' name='email' />
Confirm Email <input type='text' name='confirmemail' />
<input type='submit' value='Sign up!' />
</form>

Once this form is submitted, the code to handle it will be
if(isset($_POST['submit']) && $_POST['email']==$_POST['confirmemail'])
{
mysql_query("INSERT INTO table VALUES value1, value2");
}
which will add the email address' into the database after checking that the 2 emails address' match (you may also need to put in some of your own validation ie checking that the email address is valid. stripslashes() etc.

Then on your page where you have a form to make your news letter?

<form method='post' action='page2.php'>
<textarea cols='50' rows='25'></textarea>
<input type='submit' value='Send Letter' />
</form>

This form allows you to write your letter and send it.

The page it directs to should then have the appropriate code to retrieve email address' from the database and send the letter.

if(isset($_POST['submit'])
{
$query = mysql_query("SELECT emailaddress FROM table"); <--- the table you saved the email address' to

while($row = mysql_fetch_array($query)) <--- while there are email address' to be sent to
{
mail($row['email'], $subject, $newsletter); <--- send the email.
}
}

If you're unsure about the email function then check here
http://www.w3schools.com/php/php_mail.asp
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 08:34 PM.





Acceptable Use Policy

WebMediaBrands

internet.comMediabistrojusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Shopping | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0