The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

My simple register/deregister script

Hi,
I'm learning php from experience and small internet tutorials, and ive come to a bit of a halt. I want this script (below) to beable to register and deregister users that fill out forms on seperate pages. I think ive got the majority of first part (adding users) correct, but im kind of lost as i havnt found any tutorials that talk about deleting users.

The two pages are register.php and deregister.php with form actions of "process.php?id=register" and "process.php?id=deregister" respectivly.

I want the deregister part of the script to check if the user exists, and if so check the entered password, which if it is correct will delete the user from the db.

// This is where it processes the register.php form and adds the userif ($id=="register") {$db = mysql_connect($db_server, $db_username, $db_password);mysql_select_db($db_name, $db);$result = mysql_query("SELECT * FROM attendies WHERE username='$escpUusername'", $db);

I've just sort of pretended that the values being sent through the form are firstname, lastname, username, and password. You can change these to match the names you are really using. It also looks like you are using 'alias' in the database as your username, you can change it accordingly. I just used the names I felt most comfortable with(the ones I'm used to using).

However, im now experiencing some errors of which i don't understand the source.

When trying to register i receive this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/forrestj/public_html/process.php on line 26
No Database Selected

When trying to deregister (a existing or non existing user) i get this error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/forrestj/public_html/process.php on line 59
That username/password combination doesnt exist on the attendie list.

The only modifications to the code above have been to make it compatible with my database/website, but if need be i can re-post the script.