Jump to content
xisto Community
gotcha41

How To Store The Text Typed In A Form? sort of newsletter subsciption form

Recommended Posts

i would like to add a form on my site, that let's you fill in your e-mail address in order to subscribe to a newsletter. Actually, i just need to see their addresses somewhere (in a textfile, database, forward to my e-mailaddress,..). How can this be done? I mean, which script do i have to use?There is a database available.Php is enabled.I have no acces to cgi-bin, if that's needed.I hope someone can help me with this.The alternative would be that there is a link on my site so that they can mail it to me, but prefer a script :P Any ideas? thanks in advance! :D

Share this post


Link to post
Share on other sites

Try this:

FORM

<form name="newsletter" method="post" action="newsletter.php">  <p>    <input type="text" name="nl_email"></p>  <p>    <input type="submit" name="Submit" value="Submit"></p></form>

TABLE in sql
ID: int autoincrasing indexNL_EMAIL: string

newsletter.php file

<?phpif ( isset($HTTP_POST_VARS['nl_email'])) {   $nl_email = $HTTP_POST_VARS['nl_email'];  $dbh=mysql_connect (HOST, USER, PASSWORD) or die ('DB is OFF');  mysql_select_db (TABLE NAME);  $query = "INSERT INTO TABLE NAME (`NL_EMAIL`) VALUES ('".$nl_email."')";  $result = mysql_query($query);  print "Your email is add. Nice day";}else{  print "Don't see email adress.";}?>

Dont forget to change HOST, USER, PASSWORD, TABLE NAME to right values.

With this you get a list of emails putting by users on in form, if you need a script for sending this news letter just ask :]

Share this post


Link to post
Share on other sites

ok, thanks a lot, this is what i was looking for, but one question:

can you be more specific on what to do with the database? (in phpmyadmin) i'm not that familiar with mysql. But i do can run a query on my database.

can you give me something like:

CREATE TABLE cpg_online (  user_id int(11) NOT NULL default '0',  user_ip tinytext NOT NULL,  last_action datetime default NULL,  PRIMARY KEY  (user_id,user_ip(15))) TYPE=MyISAM;

thanks a lot :P

Share this post


Link to post
Share on other sites

sql

SQL-query: CREATE TABLE `nl_table` (`ID` INT NOT NULL AUTO_INCREMENT ,`NL_EMAIL` TEXT NOT NULL ,INDEX ( `ID` ) );

php
$sql = 'CREATE TABLE `nl_table` ('        . ' `ID` INT NOT NULL AUTO_INCREMENT, '        . ' `NL_EMAIL` TEXT NOT NULL,'        . ' INDEX (`ID`)'        . ' )'; 

But first you need create database in CPANEL, next create user to this database add to this user full acces, then you can create tables in this new database.

MySQL Database button in CPANEL.

--------------------

Practice is when evrything is work but no one know why.
Theory is when work nothing but evry one know why.
Programmers join Practice with Theory - nothing work and no one know why :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.