You are invited to Log in or Register a free Frihost Account!

script for a newsletter

I am a beginner in php. I just want to create a newsletter on my web page. Can i have a script to make it? i am using easyphp to test my script.
What i need is to insert an adress mail into my database, and how to create that database. For a start i think it is the least i should be able to do. Laughing
All the info you need to do that is available on
But there are also many free programs that can do this, I think there is one in DA actually...
Manofgames wrote:
All the info you need to do that is available on
But there are also many free programs that can do this, I think there is one in DA actually...

What i am really looking for is the complete code for a newsletter. But there is not in that website you gave the link!
Ah, sorry.
I thought you wanted to try and make one Embarassed
The following site has a lot of newsletter scripts:

Also, a quick google:,GGLJ:2006-44,GGLJ:en&q=php+newsletter+script+free
you cant get better scripts but look for it in they have a huge database of codes or wanna create yourself, then google it. good luck.
Ok, thanks for the links.
The first step i've already done it. Create the HTML part, i wrote a a form so that anybody can enter his address, but now, my problem is to get the address entered in and send it to the database.

I need a code for this. So if there is somebody who has already done it, let me know.

Thans in advance.
Alright, I've litterally just thrown this together, so it may not be that brilliant, or secure(though I have put some protection in, it may go a bit crazy depending on how your web hosting is set up).

All the vars are created at the begining of the script, and I've included comments as well.


//Enter the general info here:
//Enter your MYSQL database info here
$dbhost = 'localhost'; //usually this is localhost, it is with frihost
$dbuser = 'root'; //This is usually in the format of 'yourhostingusername_databaseusername'
$dbpass = ''; //This is whatever you set it up to be
$dbdata = 'newsletters'; //This is the database to put the stuff in
$dbtabl = 'subscribers'; //This is the table in the database to put stuff in
$dbfiel = 'email'; //The table field

//Form settings
$ff_email = 'email';//This is the name of the field the user puts their address into

//Optional settings

$redaddrr = ''; //Redirect url

if($_POST[$ff_email] != null){

// Make a MySQL Connection
mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
mysql_select_db("$dbdata") or die(mysql_error());

// Insert a row of information into the table
$value = mysql_real_escape_string($_POST[$ff_email]);

$query = mysql_query("INSERT INTO $dbtabl ($dbfield) VALUES('$value') ")
or die(mysql_error()); 

header("Location: $redaddrr")


echo 'Please enter an email address';

In your html form, make sure where it says <form name="...." etc.
that you include the option action="post", otherwise this script will fail.

example form:

<form name="subscribe" action="post" method="dir/to/script.php">
Thanks for that code. I'ill try it but if anybody thinks he can give me another one, don't hesitate. I need, may be it could help me to understand once.

Thanks Manofgames!
firs you can make your form like this:

<!-- File: new_user.html -->
<!-- beginning of document -->
<form action="valid.php">
Name: <input type="text" name="name"/><br/>
Address: <input type="text" name="address"/><br/>
<input type="submit" value="Save" />
<!-- end of document -->

The file valid.php to send data to the database:

// Name of the file : valid.php
// sample:
//      valid.php?id=jdupond&name=Dupond&address=blabla


$name     = $_GET["name"];
$address = $_GET["address"];

   echo "Bonjour $name,<br>";
  $result=mysql_query("INSERT INTO table_utilisateurs (name,address)
              VALUES ('$name','$address')");
  if (!$result) {
     echo "L'enregistrement de vos données a échoué. Essayez plus tard<br>";
  } else {
     echo "Félicitations. Vous êtes desormais un nouveau membre de PHP Facile!<br>";

it should work
Fire Boar
Manofgames wrote:

<form name="subscribe" action="post" method="dir/to/script.php">



<form name="subscribe" method="post" action="dir/to/script.php">

Don't get methods and actions mixed up!
Ah, thanks Embarassed
Its absolutely ages since I've needed to create forms and stuff, I just forgot.
Thank you for the attention fire boar. I didn't noticed it.
Related topics
Which is your favourite weblog Script?
Chat script
Script Upload (obiefileman)
script backup database
Script run background
Can someone make me a php script?
target = _parent redirect script?
Bookmark Script:
Some Script Show
Image transparency script
A script for Loading
Need help with PHP script[RESOLVED]
Newsletter component for joomla
Looking for free Newsletter subscribe script or software
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.