PDA

View Full Version : PHP register script


Karkar
06-12-2007, 06:34 PM
Where would i go about learning to write a register sort of thing.

I want people to be able to register, have there info automatically be put on the db - into the users table, etc, etc...

Where would i even start?

Mark_W
06-12-2007, 06:41 PM
The PHP - A Beginners Guide tutorial. http://www.dreamweaverclub.com/vtm/php-mysql-apache.php

All you doing is allowing them to write to the database. Part 9 of the tutorials is the main one you need to look at.

Karkar
06-12-2007, 06:41 PM
I've done this tutorial. Believe you me. I accept what you say completely. I've got this down pat. I just need to know.. erm. I'll need to think this one thorugh first

Karkar
06-12-2007, 07:39 PM
Okok. I'm working on a basic registration script... i am getting this error when i launch it:

Parse error: syntax error, unexpected ';' in C:\Documents and Settings\Alex\My Documents\web root\zoobranet\register.php on line 15

Here is the code:

<?php
require_once("connections/connection.php");
////
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$username = $_POST['username'];
$password = $_POST['password'];
$email = $_POST['email'];
$submit = $_POST['submit'];
////
if ($submit && $firstname && $lastname && $username && $password && $email){
//
$query = sprintf("INSERT into users (rl_firstname, rl_lastname, user_name, user_password, user_email) values ('$firstname', '$lastname', '$username', '$password', '$email')");
mysql_query($query)or die(mysql_error());
//
}elseif($submit){
$errorfield = "One or more of your fields is empty !"; ?>
}


followed by all the html.

btw, i'm still a little confused as to what the "or die" does;

mysql_query($query)or die(mysql_error());

Karkar
06-12-2007, 07:43 PM
oops. nevermind i fixed it. The end brace for else if was after my end ?> .. lol. stupid

Mark_W
06-12-2007, 07:56 PM
btw, i'm still a little confused as to what the "or die" does;

mysql_query($query)or die(mysql_error());

Basically it displays an error message on the screen if there is an error.

Karkar
06-12-2007, 07:57 PM
i see! cool, thanks