Jump to content

Registration page/PHPBB help


treilad

Recommended Posts

I had just gotten my login system working and downloaded PHPBB, when I realized that when people register, I don't want them to have to register again on my forum. I'd like to have a registration code that puts the info into both tables, but I don't want them to have to register with PHPBB first. I don't know how to do that since PHPBB's register script is a lot more complicated than the one I'm running. After that, I also decided to update my registration code, which I haven't gotten working yet. So here is my new code that I copied from somewhere and edited a little bit, (hence the third-party forum):

[code]<?php
ob_start();
include("db.php");

if($_POST['register']){
$username = $_POST['username'];
$password = $_POST['pass'];
$cpassword = $_POST['cpass'];
$email = $_POST['emai1'];

if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL){

echo "A Field was left blank.";
}else{
if($password != $cpassword){
echo "Passwords do not match";
}else{
$password = md5($password));

$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname = mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email from users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if($checkemail>0){
echo "We already have a registered user with that email address. Please only register one account.";
}
if($checkname>0){
echo "This username is already in use. Please try another or <a href="./index.php">login</a>.
}
else
{
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);

  $valnum[1]="789542433888764";
  $valnum[2]="876954214834687";
  $valnum[3]="138732418699423";
  $valnum[4]="546311421867355";
  $valnum[5]="875632177863879";
  $valnum[6]="789876546489646";
  $valnum[7]="847515815845181";
  $valnum[8]="848584185618485";
  $valnum[9]="946181458518515";
  $valnum[10]="321312515813485";
  $random = rand(1, count($valnum));
$userval = "$valnum[$random]";


$query = mysql_query("INSERT INTO users (username, password, email, val_num) VALUES('$username','$password','$email', '$userval')");


mail("$email", "Please validate your account.", "Thank you for registering at YOURSITE. Please use the link below to validate your account.

Username: $username
Validation Code: $userval
To validate your account, visit: http://localhost/validate.php?username={$_POST['username']}

If your username has spaces in it, you must replace them with %20");
echo "You have successfully registered! Please check your email for your validation link!";
}
}
}
}else{
echo ("
<center>
<form method=\"POST\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
Email: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"emai1\"> (Requires Validation)<br />
<input name=\"register\" type=\"submit\" value=\"Register\">
</form>
</center>
");
}
?>[/code]

Here is my login script:

[code]<?php
ob_start();
include("db.php");

if($_POST['register']){
$username = $_POST['username'];
$password = $_POST['pass'];
$cpassword = $_POST['cpass'];
$email = $_POST['emai1'];

if($username==NULL|$password==NULL|$cpassword==NULL|$email==NULL){

echo "A Field was left blank.";
}else{
if($password != $cpassword){
echo "Passwords do not match";
}else{
$password = md5($password));

$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname = mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email from users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if($checkemail>0){
echo "We already have a registered user with that email address. Please only register one account.";
}
if($checkname>0){
echo "This username is already in use. Please try another or <a href="./index.php">login</a>.
}
else
{
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);

  $valnum[1]="789542433888764";
  $valnum[2]="876954214834687";
  $valnum[3]="138732418699423";
  $valnum[4]="546311421867355";
  $valnum[5]="875632177863879";
  $valnum[6]="789876546489646";
  $valnum[7]="847515815845181";
  $valnum[8]="848584185618485";
  $valnum[9]="946181458518515";
  $valnum[10]="321312515813485";
  $random = rand(1, count($valnum));
$userval = "$valnum[$random]";


$query = mysql_query("INSERT INTO users (username, password, email, val_num) VALUES('$username','$password','$email', '$userval')");


mail("$email", "Please validate your account.", "Thank you for registering at YOURSITE. Please use the link below to validate your account.

Username: $username
Validation Code: $userval
To validate your account, visit: http://localhost/validate.php?username={$_POST['username']}

If your username has spaces in it, you must replace them with %20");
echo "You have successfully registered! Please check your email for your validation link!";
}
}
}
}else{
echo ("
<center>
<form method=\"POST\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
Email: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"emai1\"> (Requires Validation)<br />
<input name=\"register\" type=\"submit\" value=\"Register\">
</form>
</center>
");
}
?>[/code]

Any tips on making these cooperate? I haven't done a whole lot to the registration code so I'm quite sure that it needs some/a lot of editing. If it's impossible or would be too much trouble to have registration on my website rather than registering on PHPBB, then I'll gladly just make the registration on PHPBB. Thanks in advance. :)

-Matt
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.