Ryan
Ryan

Reputation: 13

echo displaying 1 before the correct text

Everything else is working correctly when I am registering a user(they are added to database and activation email is sent) however the text that I am returning from my "echo" to say 'thanks for registering' includes a 1 infront of it and I can't for the life of me work out why as I am doing the same thing in other places and it is working correctly, below is my code:

if (empty($_POST) === false && empty($errors) === true) {
    $allow_email = ($_POST['allow_email'] == 'on') ? 1 : 0;
    echo $allow_email;
    $register_data = array(
        'username'    => $_POST['username'],
        'password'    => $_POST['password'],
        'first_name'  => $_POST['first_name'],
        'last_name'   => $_POST['last_name'],
        'email'       => $_POST['email'],
        'email_code'  => md5($_POST['username'] + microtime()),
        'allow_email' => $allow_email
    );

    register_user($register_data);
    echo 'You have been registered successfully! Please check your email';
    exit();

And this is what is displayed on my site:

1You have been registered successfully! Please check your email

Any help would be greatly appreciated, kindest regards, Steven

Upvotes: 0

Views: 60

Answers (2)

Austin Brunkhorst
Austin Brunkhorst

Reputation: 21130

On the third line of the snippet you provided you echo out $allow_email.

if (empty($_POST) === false && empty($errors) === true) {
    $allow_email = ($_POST['allow_email'] == 'on') ? 1 : 0;
    echo $allow_email;

Because that obviously has no significance you can remove echo $allow_email;.

Upvotes: 2

Edwin Alex
Edwin Alex

Reputation: 5108

Remove

echo $allow_email;

It causes the problem. It displays the value of $allow_email.

Upvotes: 2

Related Questions