Improvements To Member Registration Site Reg.php

I’d say “Spend more time coding and working through the basics until they’re second nature, and considerably less time writing posts on forums about how bad your memory is”. Writing code, refactoring code, debugging code, optimising code and doing it on a daily basis will develop the mental equivalent of muscle memory. That’s how you remember stuff, and only have to look up ideas you’ve not seen before, or are more complex.


Remember everything? Goodness no!

I might remember more things while I’m using them, but with time away from the code uncertainty creeps in. I remember things I use often, eg.
for ($i; $i < $arr_count; $i++) {
but there are times when I’m not 100% sure which of these are correct eg.

str_pos($needle, $haystack) 
strpos($needle, $haystack) 
str_pos($haystack, $needle) 
strpos($haystack, $needle) 

Thank God! Then, I’m not alone who forgets things on php! Lol!

I often think back as to how I used to manage to code without the internet.

Maybe I should Google for a solution :slight_smile:


Today’s free e-book offer at Packt Press is “Learning PHP 7”. Take the opportunity to get it while you can, as the offer only lasts 24 hours.


A post was split to a new topic: Views on Likes

Right this instant, my mind is on full gear trying to thinkup some wild ideas to launch some script and site that will go viral. I’ll open another thread on this and keep you guys updated (entertained enough to give me likes and feed-back) from time to time whenever anything wacko comes into my head. We live in strange times. In this day and age, the more wacko you are the more money you make and the more famous you become (singers and actors).

I was about to go ahead reading these links:

I only read one and had a question and so popped up here to ask. Finding 3 likes on John_Betong’s post made me forget all that and go off track delving into another subject. Stepped into the rabbit’s hole. And instead of coming out, I’m exploring and going deeper. Wasted my studying time. In half hr got to go out. While out, I’d be pondering at the back of my head about the viral subjects mentioned in my previous post. If anything exciting turns-up, I’m opening another thread in this forum to discuss it for feed-backs. I’ve been obsessing on how to make things go viral from feb - june. Have come-up with a few ideas which I’ll discuss in that new thread. Already discussed little bit here (dream boy/girl membership site).

Anyway, since I won’t learn much in half hr before it’s time to go out. I might aswell grab that ebook TechnoBear brought to our attention. His read my 2 posts upto here and thinking I’m polluting his forum with nonsense. Atleast, he’ll be glad that I’ve decided to download what he suggested. Turned the neg into a pos at the end. :wink:

1 Like

17 posts were split to a new topic: Download difficulties

I forgot to ask: Google for what solution ?
Maybe, people are liking your post because they expect you to find the solution and share it with them I don’t know. Beats me.

There was only a single statement and surprised you were not able to deduct the search query “how to code without using the internet”.

I did search and confirmed the internet usage can easily be abused. Hard copy has a lasting effect rather than glossing over numerous solutions.


If I remember correctly, I think I found-out from another forum, once upon a time, that with pdo there is no binding nonsense! If that is the case then: GOOD.
And for reminding me this: THANKS! :wink:

1 Like


Looking at this code, is it not very clear that the $email, $account_activation_code, $userActivationState and $stmt_two been defined ?
If so, then why do I get these errors ?

Notice: Undefined variable: email in /home/user/public_html/e-id/activate_account.php on line 11
**NULL **
Notice: Undefined variable: account_activation_code in /home/user/public_html/e-id/activate_account.php on line 14

Notice: Undefined variable: userActivationState in /home/user/public_html/e-id/activate_account.php on line 23
**NULL int(0) int(0) **
Notice: Undefined variable: stmt_two in /home/user/public_html/e-id/activate_account.php on line 38

The variables have been defined like these:

	**$email = htmlspecialchars($_GET['email']);**	
	**$account_activation_code = htmlspecialchars($_GET['account_activation_code']);**
        $stmt_one = mysqli_prepare($conn, "SELECT usernames, accounts_activations FROM users WHERE emails = ? AND accounts_activations_codes = ?");**strong text**
**$stmt_two = mysqli_prepare($conn, "UPDATE users SET accounts_activations = ? WHERE usernames = ?");
	mysqli_stmt_bind_param($stmt_two, 'is', $userActivationState, $username);**

Full Script


include 'config.php';

if (!isset($_GET["email"], $_GET["account_activation_code"]) === true){
    $_SESSION['error'] = "Invalid Email Address! Invalid Account Activation Link! This email is not registered! Try registering an account if you do not already have one! <a href=\"register.php\">Register here!</a>";
	echo var_dump($email);
	$email = htmlspecialchars($_GET['email']);	
	echo var_dump($account_activation_code);
	$account_activation_code = htmlspecialchars($_GET['account_activation_code']);
	echo var_dump($stmt_one);
	$stmt_one = mysqli_prepare($conn, "SELECT usernames, accounts_activations FROM users WHERE emails = ? AND accounts_activations_codes = ?");
	echo var_dump($stmt_one);
	mysqli_stmt_bind_param($stmt_one, 'si', $email,  $account_activation_code);
	echo var_dump($userActivationState);
	mysqli_stmt_bind_result($stmt_one, $username, $userActivationState);
	if (mysqli_stmt_execute($stmt_one) && mysqli_stmt_fetch($stmt_one))
		echo var_dump($userActivationState);
		if ($userActivationState != 0)
			echo "Since your account is already activated, why are you trying to activate it again ? Do not do that again and just login from <a href=\"login.php\">this webpage</a> next time! Make a note of that webpage, ok ?";

		echo var_dump($userActivationState);
		$userActivationState = 1;		
		echo var_dump($stmt_two);
		$stmt_two = mysqli_prepare($conn, "UPDATE users SET accounts_activations = ? WHERE usernames = ?");
		mysqli_stmt_bind_param($stmt_two, 'is', $userActivationState, $username);	
		if (mysqli_stmt_execute($stmt_two))
			echo "<h3 style='text-align:center'>Thank you for your confirming your email and activating your account.<br /> Redirecting you to the login page ...</h3>";
			$_SESSION["user"] = $username;
		echo "FAILURE to UPDATE db";

And, do you see any boolean issues on any of the following lines:

**$stmt_one = mysqli_prepare($conn, "SELECT usernames, accounts_activations FROM users WHERE emails = ? AND accounts_activations_codes = ?");**

**mysqli_stmt_bind_param($stmt_one, 'si', $email,  $account_activation_code);**

**if (mysqli_stmt_execute($stmt_one) && mysqli_stmt_fetch($stmt_one))**

I don’t see any boolean issue on the $stmt_one variable atall.
But I get these errors:

Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in /home/user/public_html/e-id/activate_account.php on line 40

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in /home/user/public_html/e-id/activate_account.php on line 42**

The config.php looks like this:


ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');


// session start
if(!session_start()) {

// include files
include 'conn.php';
include 'site_details.php';

// include functions
include 'functions.php';

1 Like

Is there anything you do not understand with that statement?

Unable to give the post numbers because they are not available when using the Mobile version.

1 Like

Looking at my previous post, did you not see the var_dumps floating all over the script ? And, don’t you see what error the var_dump is showing ?

1 Like

Only a single var_dump(…) is required to confirm the value is of the correct type and is valid.

Please also check the online manual to find out how to use var_dump(…) because your usage is incorrect.

1 Like

I added the var_dump() on every one of my $vars so that after updating the code if I encounter a new problem with another variable then I don’t have to add the var_dump on that one too. Thought best to add the var_dump() at the beginning on all $vars. You never know which var’s var_dump() I will need checking and when.
Anyway, I reckon the errors are false positives. Unless, someone can prove otherwise. This is now a big mystery.

The script is using var_dump(…) incorrectly.

Please consult the manual as mentioned in my previous post.

1 Like

The first value which produces an error is the one to check, preferably followed by die();

Because php is interpreted meaning once an error is encountered most likely only garbage will follow.

Lookup GIGO :slight_smile:

Because of your reluctance to follow advice on searching for recommended links, I took the trouble…



Looking at #post 239, don’t you guys agree the errors are false positives ?
I wonder what are the opinions of SpaceShipTrooper, droopsnoot, SamA74, Mittineague and Gandalf. Interested to see how many opinions differ.
Oops! Nearly forgot TechnoBear!

1 Like

No they are not false positives.

As mentioned in umpteen previous posts your var_dump(…) usage is incorrect and will not change regardless of how many times it is used incorrectly.