Computer Science Canada

Registration

Author:  Viper [ Sun Oct 17, 2010 11:59 am ]
Post subject:  Registration

Could someone look this code over and help me figure out why it fails to tell the user the account was created.

What currently happens now is after account is created it just reloads to registration page like there was an error in one of the fields but the account is still created, its been confusing people and causing some to create multiple accounts unknowingly.

If you want to test this error, please use this format for username "CPSI[insert name here]" unless you plan on keeping the account.

thank you in advance.

Change file back to .php to view

Author:  Brightguy [ Sun Oct 17, 2010 12:56 pm ]
Post subject:  Re: Registration

Uh... where actually is the code which is supposed to tell the user the account is created? I don't see any such code... Eh

Author:  DanShadow [ Sun Oct 17, 2010 1:39 pm ]
Post subject:  RE:Registration

Viper wrote:
if ($errorMsg == '') {
$verifycode = md5($username);
$qryins = "Insert into registration (username, firstname, lastname, sex, birth_date, email, password, terms_condition, privacy, newsletter, " .
"sponser, addressline1, addressline2, city, state, postcode, country, phone, registration_date, account_status, registration_ip, verifycode) " .
"values ('$username', '$fname', '$lname', '$gender', '$bdate', '$email', '$pass', $terms, $privacy, $news, " .
"$referrerid, '$addressline1', '$addressline2', '$city', '$state', '$postcode', '$countrycode', '$phoneno', NOW(), 0, '" . $_SERVER["REMOTE_ADDR"] . "', '$verifycode')";
mysql_query($qryins) or die(mysql_error());
$_SESSION["uid"] = mysql_insert_id();


So if the form contains no errors, it commits an insert query into your database, then creates a "uid" session variable.
Assuming you have no page to tell the user the account is created, you could do a few things.
Personally I would either use an if statement "if (isset($_SESSION['uid']))" over your code, and if it comes true you could check your DB to confirm the form POST values have been entered into your database, and give the user a confirmation message.
Alternatively, if the only way you can set $_SESSION['uid'] is to successfully create the account (on this page), you could add a redirect script at the top of your page (to the login page) with a GET parameter to have your login page show that the account was created successfully.

Author:  Viper [ Sun Oct 17, 2010 1:57 pm ]
Post subject:  Re: Registration

If any one is interested in winning a FREE "BidPack" (15$) value. Just be the first to fix the code i provided above then email or repost with your fixed version, which i will check then implement.

Thank you and have fun.

Author:  DanShadow [ Sun Oct 17, 2010 2:26 pm ]
Post subject:  Re: Registration

Ooh, bidpack Smile.

I changed your registration message variable to a session variable, then added a line after your include statements to redirect to your 'Login.php' page, but set the GET parameter to your registration message.

So basically, if the user creates an account (which sets the "uid" and "objregmsg" session variables), the page will redirect to your login page and post the reg msg as a GET parameter in the Login.php? url

So in your Login.php page, you can use $_GET['objregmsg'] or $_SESSION['objregmsg'] to get your registration message.

Author:  Dan [ Sun Oct 17, 2010 2:45 pm ]
Post subject:  Re: Registration

Viper @ 17th October 2010, 1:57 pm wrote:
If any one is interested in winning a FREE "BidPack" (15$) value. Just be the first to fix the code i provided above then email or repost with your fixed version, which i will check then implement.


You are really starting to push it with the spam for your site. Please keep any references to your site, or free offers relating to it, to the contest topic you created. This is your last warning.

Author:  Amailer [ Sun Oct 17, 2010 3:01 pm ]
Post subject:  RE:Registration

Also, you should really use a framework Smile

http://framework.zend.com
http://codeigniter.com
http://github.com/fabpot/symfony / http://symfony-reloaded.org/ (<< is great, loving it so far, don't like 1.0 however)
http://cakephp.org/

Author:  Viper [ Sun Oct 17, 2010 5:30 pm ]
Post subject:  Re: Registration

To Comply With CompSci Rules Please Refer to the link below.



http://compsci.ca/v3/viewtopic.php?t=26271


: