Click to See Complete Forum and Search --> : Help! Form content into MySQL database?


flatlander
11-04-2005, 11:55 AM
Hi,
I need to create a basic html form for my newsletter sign-ups and send the form info to a simple MqSQL database, then be able to retrieve the email address's when I need them.

Does anyone know of an easy to follow tutorial that will walk me through the steps to do this?

Thanks!
Jill

Fang
11-05-2005, 08:15 AM
http://www.sitepoint.com/article/users-php-sessions-mysql

flatlander
11-07-2005, 09:14 AM
Hi,
Thanks for the link but it's a little over my head, plus I don't need to do a lot of what that tutorial teaches about.

I just want to collect people's name, email and comments on a form, send them to MySQL and be able to extract the names and email addresses all at once in order to send my newsletter out.

Any other links to good tutorials out there on this subject?

Thanks.

Sheldon
11-07-2005, 05:46 PM
do you know how to write the forms? If not then just go to any html teaching website, http://www.htmlgoodies.com for example.

Then to add the informatino from the form to the DB you can learn everything you need to at http://dev.mysql.com

What server side code do you use/know?

flatlander
11-08-2005, 09:35 AM
Hi Sheldon,
I can build an html form fine, however I haven't had much experience with php, asp or any other server side script.

I've also only used Access DB, but my host only offers MySQL which is brand new to me as well.

I've used Constant Contact in the past, but I'd rather not pay a company to do my new newsletter, but I'm finding it very difficult to figure out how to go about collecting, storing and retrieving people's info and email myself!

Thanks,
Jill

Sheldon
11-08-2005, 10:41 PM
Right If you have PHP installed on your server and have a mySQL DB as you say i have a basic sign-up/write/send newsletter script that i could give you and you can try with the help of up and http://www.php.net modify it to match your ideas.

flatlander
11-09-2005, 09:26 AM
Hey Sheldon,
That would be really helpful. You can email it to me at jill@flatlanderracing.com if you'd like.

Thank you! :)
Jill

Sheldon
11-09-2005, 02:56 PM
script removed

flatlander
11-10-2005, 01:43 PM
Hi Sheldon,
Thank you! I've downloaded the zip - but where do I start? I assume I need to upload them all to my main folder on my server, but then what? Sorry I need so much help with this!

Also, for the newsletter.sql (a sql dump for PHPmyAdmin to set up your databases), do I need to go in and make a new php DB and name it and then use this file?

I've never done any of this before, so if you have some simple directions that would be great. I really appreciate it!

:)

Sheldon
11-10-2005, 03:15 PM
Ok, yes, load them into your webserver, any folder as long as there all together.

Go in to PHPmAdmin and create a new database, name it what ever you like.

Then set up a new user/password and give that user access and all permission to that database you have just set up.

Then input the "newsletter.sql" file into your database. That should set up your tables. To export it i think it is in the menu "SQL" at the bottom of te page.


Then one the DB is running go to "signup.php" and sign up your self.
Once your people have signed up, go to "addnewsletter.php" write your newsletter and you will go from the, easy enough i hope.


If you have any problems with phpmyadmin try going to
phpmyadmin (http://www.phpmyadmin.net/home_page/docs.php)

or post back here

flatlander
11-10-2005, 03:36 PM
Hey Sheldon,
I'm not sure where I go for PHPmyAdmin when I login to my host account? I don't think they offer that.

I can only go into "Manage MySQL" to create a new database which I did. I stil can't figure out how to import the newsletter.sql file into my MySQL database I just created though.

Any suggestions?
- Jill

flatlander
11-10-2005, 03:47 PM
BTW, I did contact my host provider for info on what to do as they don't have PHPmyAdmin - I'll let you know what happens.

Thanks Again!
Jill

Sheldon
11-13-2005, 06:28 PM
Jilll, you can create your database using php functions
some thing like this.
Save this in an empty .php file and upload it to your server and open it up.



<?php //create the two tables

$news = "CREATE TABLE `newsletter` (
`id` int(3) NOT NULL auto_increment,
`title` varchar(50) default NULL,
`content` varchar(255) NOT NULL default '',
`date` timestamp(10) NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='newsletter date and title' AUTO_INCREMENT=11 ";
$create = @mysql_query($news);

if(!$create){ echo("SQL ERROR: $news - " . mysql_error()); }




$users = "CREATE TABLE `users` (
`id` int(2) NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=38 ";
$result = @mysql_query($users);

if(!$result){ echo("SQL ERROR: $users - " . mysql_error()); }



?>

flatlander
11-14-2005, 03:15 PM
Thanks Sheldon,
I'll try that. I'm still working on all this and will be spending some time on it tomorrow morning. Thanks again for ALL your help! I'll let you know how things progress.
:) Jill

Sheldon
11-14-2005, 04:08 PM
Sorry Jill I forgot one of the most important lines in the code,

Use this Version


<?php //create the two tables

include('connect.php');
/*must connect to the database that you have created before you can add tables to it, Make sure you have edited the settings in "connect.php" before running this script!, also check the path to hte file ie: "/common/connect.php" */

$news = "CREATE TABLE `newsletter` (
`id` int(3) NOT NULL auto_increment,
`title` varchar(50) default NULL,
`content` varchar(255) NOT NULL default '',
`date` timestamp(10) NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='newsletter date and title' AUTO_INCREMENT=11 ";
$create = @mysql_query($news);

if(!$create){ echo("SQL ERROR: $news - " . mysql_error()); }




$users = "CREATE TABLE `users` (
`id` int(2) NOT NULL auto_increment,
`name` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=38 ";
$result = @mysql_query($users);

if(!$result){ echo("SQL ERROR: $users - " . mysql_error()); } else{ print 'Tables create successfully Jill'; }



?> Again my apologies.

Sheldon

flatlander
11-14-2005, 04:11 PM
No need to apologize - I'm just thankful for all the help. I can't run it until tomorrow so it's not a problem.

Cheers - Jill

Sheldon
11-19-2005, 04:07 AM
Any luck Jill? Hope installation went well. If you have any problems just post back here.