Dec
27
2008
0

PHP mini-learning side-project for bored wannabe programmers

Your first PHP project.

This project will let random people subscribe to your “site”. This project pretty much just aggregates a bunch of emails so you can email them your “rant of the day” or something random like that.

First you need to get php working on your mac or pc.

I’m not gonna show you how to do everything :) when I say Lookup it means search for stuff on Google or PHP.net.

Hint: Google the bold parts and click on the first link that shows up.

Ok…

First let people sign up to your site:

Go to your phpmyadmin and login as root. It is risky and all and you can disable root access and mess with it if you want. I’m just warning you ahead of time that phpmyadmin can sometimes be very uncoorperative. Anyway, make a database and table with three fields - id, name and email. The id field should have auto-increment on. To turn auto-increment on, you must check the checkbox labeled A.I. (messed me up so badly).

Make a php file. First, we’re going to put html in a php file:

Lookup how to make a html form and make a GET form that takes in a name and email. Also add a hidden variable called process.

Now, add a little php to the form. If you do:

$name = $_GET['name'];

The variable The php form should take the name and email and insert it into the mysql database. Make sure you have the right syntax or life will be hell! I suggest copy pasting because you will need ’s and `s.

Use phpmyadmin to check that your emails are actually added into the database.

Now, to send the email, make a separate php page with a bigger form to fit an email message. Use php to select all emails from the mysql database. You can modify the email so that their names are in the email and use the built in mail() function in php to send the mail automatically to all your friends.

Have fun and I hope everything works for you.

Written by Andy in: Knowledge, tutorial |

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes