Jump to content

User Registration


matvespa

Recommended Posts

Hi, my code kept giving me the message "You are already activated" even though im a new user. The code:

 

<?php
define('INCLUDE_CHECK',true);

include("connect.php");
/*mysql_connect("localhost", "****", "****") or die(mysql_error());

mysql_select_db("winecom1_wine7000") or die(mysql_error());*/

session_start();
$_SESSION['capture'] = "";


if ($_POST['form_submitted'] == '1') {
##User is registering, insert data until we can activate it

require_once('recaptchalib.php');
$privatekey = "6LfvjgkAAAAAAKGoQcxC6E7ngXgUsjuyUGiHHAkV ";
$resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

if (!$resp->is_valid) {
$_SESSION['capture'] = "positive";
$_SESSION['RegPreFirst'] = $_POST['tbFirstName'];
$_SESSION['RegPreLast'] = $_POST['tbLastName'];
$_SESSION['RegPreEmail'] = $_POST['tbEmail'];
$_SESSION['RegPreAdd'] = $_POST['tbAddress'];
  header( 'Location: Register.php' );
  die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
       "(reCAPTCHA said: " . $resp->error . ")");
  
  
}




$activationKey =  mt_rand() . mt_rand() . mt_rand() . mt_rand() . mt_rand();
$UserSalutation = $_POST['salutation'];
$UserFirstName = $_POST['tbFirstName'];
$UserLastName = $_POST['tbLastName'];
$UserEmail = $_POST['tbEmail'];
$UserPassword = $_POST['tbPassword'];
$Month = $_POST['month'];
$Day = $_POST['day'];
$Year = $_POST['year'];
$UserDOB = date($Year . "-" . $Month . "-" . $Day);

$UserCountry = $_POST['country'];

$UserAddress = $_POST['tbAddress'];

$PreferRed = $_POST['WineType_Red'];
$PreferWhite = $_POST['WineType_White'];
$PreferFortified = $_POST['WineType_Fortified'];
$PreferSparkling = $_POST['WineType_Sparkling'];

$NewsPreference = $_POST['Newsletter'];
$JoinDate = date("Y-m-d");
$Newsletter = "";
$UserImage = "images/UserProfile/dp.png";

if($PreferRed != "Yes")
{
$PreferRed = "No";
}
else
{
$PreferRed = "Yes";
}

if($PreferWhite != "Yes")
{
$PreferWhite = "No";
}
else
{
$PreferWhite = "Yes";
}

if($PreferFortified != "Yes")
{
$PreferFortified = "No";
}
else
{
$PreferFortified = "Yes";
}

if($PreferSparkling != "Yes")
{
$PreferSparkling = "No";
}
else
{
$PreferSparkling = "Yes";
}

if($NewsPreference != "Yes") 
{
$NewsPreference = "No";
}
else 
{
$NewsPreference = "Yes";
}
/*modified by chaitanya
$find=mysql_query("Select * from user where UserEmail='$UserEmail'") or die(mysql_error());
$no_find=mysql_num_rows($find);
    
if($no_find==0)
{
//modified by chaitanya	*/

$sql="INSERT INTO user (UserSalutation, UserFirstName, UserLastName, UserEmail, UserPassword, UserDOB, UserCountry, UserAddress, JoinDate, PreferRed, PreferWhite, PreferFortified, PreferSparkling, NewsPreference, UserImage, UserStatus, ActivationKey) 
VALUES ('$UserSalutation', '$UserFirstName', '$UserLastName', '$UserEmail', '$UserPassword', '$UserDOB', '$UserCountry', '$UserAddress', '$JoinDate', '$PreferRed', '$PreferWhite', '$PreferFortified', '$PreferSparkling', '$NewsPreference', '$UserImage', 'verify', '$activationKey')";

if (!mysql_query($sql))

  {

  die('Error: ' . mysql_error());

  }

//echo "An email has been sent to $_POST[tbEmail] with an activation key. Please check your mail to complete registration.";
//header ('Location : RegisterThanks.php');
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterThanks.php\">";
##Send activation Email

$to      = $UserEmail;

$subject = " Wine7000.com Registration";

$message = "Welcome to our website!\r\r

You have completed registration at Wine7000.com. Please click on the activation link below to activate your account with Wine7000:\r\r

http://siteb.wine7000.com/Verify.php?$activationKey\r\r

You are now part of Wine7000 after you have activated your account. You may start to bid on our auction listings or even upload your own wine to our real time auction platform.\r\r

If this is an error, ignore this email and you will be removed from our mailing list.\r\r

Regards,\r 
Wine7000.com Team";

$headers = 'From: admin@Wine7000.com' . "\r\n" .

    'Reply-To: noreply@ Wine7000.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
{
echo "Mail sent succesfully";
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterThanks.php\">";
}
else
{
echo "Mail cannot be sent. Contact Administrator!!";
// echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterErrorAdmin.php\">";
}

echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterThanks.php\">";
/*
}
else
{
//modified by chaitanya 
echo "A user with this email id is already registered.";
sleep(5);
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=Register.php\">";

}
*/

}
##User isn't registering, check verify code and change activation code to null, status to activated on success
if($queryString = $_SERVER['QUERY_STRING'])
{
$query_new=mysql_query("select * from user where ActivationKey=$queryString");
if(mysql_num_rows($query_new)==1)
{

  $query=mysql_query("update user set ActivationKey = '', UserStatus='activated' where ActivationKey=$queryString ");


  if ($query)
  {
  	 
 echo "Congratulations! you are  now the proud new owner of an Wine7000.com account.";
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=Login.php\">";
  }
else
{
die(mysql_error());
}
}
else
{
echo "You are already activated.";
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterErrorActivated.php\">";
}
//Modified by Chaitanya on 23/12/09 11:38 AM
}




//header( 'Location: RegisterThanks.php' );

?>

 

When i clicked on the activation link which i'll received on my email, it say im already activated. You can try to see the flow at http://siteb.wine7000.com/Register.php

Link to comment
Share on other sites

if ($query)
  {
     
    echo "Congratulations! you are  now the proud new owner of an Wine7000.com account.";
   //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=Login.php\">";
  }
else
{
   die(mysql_error());
}
}
else
{
   echo "You are already activated.";
   //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterErrorActivated.php\">";
}
//Modified by Chaitanya on 23/12/09 11:38 AM
}

You have 2 else statements for the 1 if statement.

Link to comment
Share on other sites

first, if you're going to post code in these forums (ESPECIALLY if you're going to post that much code) please use code tags. note that i've edited your post to put them in.

 

second, you may consider removing your database connection credentials from future posts. one thing that might help with this is to actually look at your code and choose smaller chunks to post, rather than just copying/pasting the whole file. it's not very helpful to simply dump your code and say "something's wrong, fix it." what have you tried so far?

 

you're lucky that rayth has offered a suggestion here - we generally need more information if we're going to help you.

Link to comment
Share on other sites

Sorry abt that mr moderator

 

if ($query)
  {
  	 
 echo "Congratulations! you are  now the proud new owner of an Wine7000.com account.";
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=Login.php\">";
  }
else
{
die(mysql_error());
}
}

//else
//{
echo "You are already activated.";
//echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=RegisterErrorActivated.php\">";
}

 

I've commented the 2nd else but the effect is still the same. Am i doing this correctly?

Link to comment
Share on other sites

my guess would be that this query:

 

select * from user where ActivationKey=$queryString

 

isn't returning what you think it is. you should format it with delimiters around the query string:

 

select * from user where ActivationKey='$queryString'

 

and see where that gets you. also, have you checked that $_SERVER['QUERY_STRING'] contains what you think it does? the if-else structure was okay the first time, so uncomment those lines again.

Link to comment
Share on other sites

Try this and see if it works.

 

if($queryString = $_SERVER['QUERY_STRING']) {
	$query = mysql_query('SELECT * FROM user WHERE ActivationKey="' . $queryString . '"');
	if(mysql_num_rows($query) == 1) {
		$array = mysql_fetch_array($query);
		if($array['UserStatus'] == 'verify') {
			if(@mysql_query('UPDATE user SET UserStatus="activated" WHERE ActivationKey="' . $queryString . '")) {
				echo "Congratulations! you are  now the proud new owner of an Wine7000.com account.";
			}
			else {
				echo mysql_error();
			}
		}
		else {
			echo 'You\'re account has already been activated.'
		}
	} 
	else {
		echo 'We cannot seem to find you\'re account';
	}
}

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.