Fellow Php Programmers,
This is a script that takes over when a user clicks a link emailed to him. The link that verifies the user's email and opens his membership account by switching from "pending status = 0" to "pending status = 1" in mysql db.
I am shown this by my script. And, I want to know why I get these errors:
string(23) "[email protected]" string(40) "472b07b9fcf2c2451e8781e944bf5f77cd8457c8" object(mysqli_stmt)#2 (10) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(2) ["field_count"]=> int(2) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) } NULL
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in /home/EDITED (User)/public_html/e-id/activate_account.php on line 27
bool(false) int(1) string(8) "EDITED (User)"
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in /home/EDITED (User)/public_html/e-id/activate_account.php on line 29
Note the bool(false) in the first warning. Regarding line 27.
Line 27:
This is a script that takes over when a user clicks a link emailed to him. The link that verifies the user's email and opens his membership account by switching from "pending status = 0" to "pending status = 1" in mysql db.
I am shown this by my script. And, I want to know why I get these errors:
string(23) "[email protected]" string(40) "472b07b9fcf2c2451e8781e944bf5f77cd8457c8" object(mysqli_stmt)#2 (10) { ["affected_rows"]=> int(0) ["insert_id"]=> int(0) ["num_rows"]=> int(0) ["param_count"]=> int(2) ["field_count"]=> int(2) ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["sqlstate"]=> string(5) "00000" ["id"]=> int(1) } NULL
Warning: mysqli_stmt_bind_param() expects parameter 1 to be mysqli_stmt, boolean given in /home/EDITED (User)/public_html/e-id/activate_account.php on line 27
bool(false) int(1) string(8) "EDITED (User)"
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in /home/EDITED (User)/public_html/e-id/activate_account.php on line 29
Note the bool(false) in the first warning. Regarding line 27.
Line 27:
Code:
$stmt_two (line 26) looks like this:
mysqli_stmt_bind_param($stmt_two, 'is', $userActivationState, $username);
Code:
<?php
02
include 'config.php';
03
if (!isset($_GET["email"], $_GET["account_activation_code"]) === true){
04
$_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>";
05
exit();
06
}
07
else
08
{
09
$email = htmlspecialchars($_GET['email']);
10
$account_activation_code = htmlspecialchars($_GET['account_activation_code']);
11
$stmt_one = mysqli_prepare($conn, "SELECT usernames, accounts_activations FROM users WHERE emails = ? AND accounts_activations_codes = ?");
12
mysqli_stmt_bind_param($stmt_one, 'si', $email, $account_activation_code);
13
mysqli_stmt_bind_result($stmt_one, $username, $userActivationState);
14
var_dump($email, $account_activation_code, $stmt_one, $userActivationState);
15
if (mysqli_stmt_execute($stmt_one) && mysqli_stmt_fetch($stmt_one))
16
{
17
if ($userActivationState != 0)
18
{
19
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 ?";
20
exit;
21
}
22
$userActivationState = 1;
23
$stmt_two = mysqli_prepare($conn, "UPDATE users SET accounts_activations = ? WHERE usernames = ?");
24
mysqli_stmt_bind_param($stmt_two, 'is', $userActivationState, $username);
25
var_dump($stmt_two, $userActivationState, $username);
26
if (mysqli_stmt_execute($stmt_two))
27
{
28
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>";
29
$_SESSION["user"] = $username;
30
header("location:home.php");
31
exit;
32
}
33
}
34
else
35
{
36
echo "FAILURE to UPDATE db";
37
exit;
38
}
39
}