Registration HELP

???
So for some reason when someone registers for my website they aren’t imputed into my php users table so when people check there email it and click the activation code it says datas missing.
heres my website to seee for yourself

[php]

<?php session_start(); ?> The Dream Flow
<?php

echo “

Register

”;

$submit = $_POST[‘submit’];

//form data
$fullname = strip_tags($_POST[‘fullname’]);
$username = strtolower(strip_tags($_POST[‘username’]));
$password =strip_tags($_POST[‘password’]);
$confirmpassword =strip_tags($_POST[‘confirmpassword’]);
$date = date(“Y-m-d”);
$email = strip_tags($_POST[‘email’]);
if ($submit)
{
//open database
$connect = mysql_connect(“localhost”,“bagobone_Peter”,“boomerdog222”) or die (“Couldn’t connect!”);
mysql_select_db(“bagobone_phplogin”) or die (“couldn’t find database!”);

$namecheck = mysql_query(“SELECT username FROM users WHERE username=’$username’”);
$count = mysql_num_rows($namecheck);

if ($count!=0)

{
die(‘Username already taken’);
}
//check for existance

if($fullname&&$username&&$email&&$password&&$confirmpassword)
{

if ($password==$confirmpassword)
{
//check char length of username and fullname
if (strlen($username)>25||strlen($fullname)>25)
{
echo “Length of Username or Full Name has reached it’s limit”;
}
else
{
//check password length
if (strlen($password)>25||strlen($password)<6)
{
echo “Password must be more then 6 and less then 25”;
}
else
{
//register the user!

$connect = mysql_connect(“localhost”,“bagobone_Peter”,“boomerdog222”) or die (“Couldn’t connect!”);
mysql_select_db(“bagobone_phplogin”) or die (“couldn’t find database!”);

$namecheck = mysql_query(“SELECT username FROM users WHERE username=’$username’”);
$count = mysql_num_rows($namecheck);

//encrypt password
$password = md5($password);
$confirmpassword = md5($confirmpassword);

//open database
$random = rand(23456789,98765432);

$queryreg = mysql_query("INSERT INTO users VALUES

(’’,’$fullname’,’$username’,’$password’,’$email’,’$date’,’$random’,‘0’)

");

//Generate random number for activation

//send acctivation e-mail

$lastid = mysql_insert_id();

//send activation e-mail
$to = $email;
$subject = “Activate your account!”;
$headers = "From: [email protected] ";
$server = “gator1716.hostgator.com”;

ini_set(“SMTP”,$server);

$body = "
Hello $fullname,\n\n
You need to activate your account with the link below
http://www.thedreamflow.com/activate.php?id=$lastid&code=$random\n\n
Keep in mind this website is still a work in progress so Don’t mind the bugs. I’m hoping to have it up and running in the next few months. any suggestions please email me at,
[email protected].

Thanks!
Love, Admin.

";

//function to send email
mail($to, $subject, $body, $headers);
die(“you have been registered plesase check your email to activate it”);
}
}

}
else
echo “Your passwords do not match.”;

}
else
echo “Please fill in all fields!”;

}

?>

Your full name:
Choose a Username:
E-mail:
Choose a Password:
Confirm Password:

[/php]

Hi there,

Please provide the code for your activate.php. If you are getting the error when someone clicks the link in their email message that points to that script, the error maybe in that script. Please provide the script code for further assistance.

Thanks.

Heres my active.php

[php]

<?php $connect = mysql_connect("localhost","bagobone_Peter","boomerdog222") or die ("Couldn't connect!"); mysql_select_db("bagobone_phplogin") or die ("couldn't find database!");

$id = $_GET[‘id’];
$code = $_GET[‘code’];

if ($id&&$code)
{
$check = mysql_query(“SELECT * FROM users WHERE id=’$id’ AND random=’$code’”);
$checknum = mysql_num_rows($check);

if ($checknum==1)
{
  //run a query to activate account 
  $acti = mysql_query("UPDATE users SET activated='1' WHERE id='$id'");	
  die("Your account is Activated. You may now <a href='index.php'>log</a> in.");
}
else
	die("Invalid Id or Activation code.");

}
else
die(“Data missing!”);

?>

[/php]

Hi again,

Is both id and code being passed in the url that is being sent to the email? I’ve tested your script (modifying it a little) and it seems to work for me when both id and code is present in the url.

Cheers!

whats changes in the script did you make 0-o

Hi again,

The problem you are specifying has to do with your IF/ELSE statement of your code since no matter what happens, the else block always triggers. Your IF statement is checking to see if there is a value in the $id and $code variables that you shortened by passing the values in the $_GET arrays. The only way your code is returning “data missing” (which is your else statement), you are either missing $id and/or $code, or the value you are passing in those variables are either 0 or false. This is, unless, I am getting confused by what error message you are receiving when you run the script. Also, I would suggest you use isset() to check your $id and $code as the following code lists:

[php]
if(isset($id, $code))
{
// … some code
}
else
{
// … other code
}
[/php]

Please let me know if I’m getting confused or not.

Cheers!

Sponsor our Newsletter | Privacy Policy | Terms of Service