Registration form

Correct, you don’t need to store the 2nd copy of the password. I also noticed another issue and you would not get any output is this line:

if (isset($\_GET['register'])) {       // code inside }

You’re not sending a key-value pair named “register” so that will be false and your script just quits without it. You will need to add like a &register=1 to your URL on the Corona side or remove that if statement and matching/ending curly brace.

Rob

username = native.newTextField( 160, 200, 180, 30 ) -- take the local off since it's forward declared username.placeholder = "Username" screenGroup:insert(username) password = native.newTextField( 160, 250,180, 30 ) -- take the local off since it's forward declared password.isSecure = true password.placeholder = "Password" screenGroup:insert(password) password2 = native.newTextField( 160, 300,180, 30 ) -- take the local off since it's forward declared password2.isSecure = true password2.placeholder = "Confirm Password" screenGroup:insert(password2) email = native.newTextField( 160, 350, 180, 30 ) -- take the local off since it's forward declared email.placeholder = "E-mail" screenGroup:insert(email)

That’s the only place I have password2

Is it being sent to your php file?

local function handleButtonEvent( event ) if ( "ended" == event.phase ) then local URL = "https://web.web.com/register.php?username=" .. mime.b64( username.text ) .. "&password=" .. mime.b64(password.text) .. "&email=" .. mime.b64( email.text ) network.request(URL, "POST", networkListener) composer.gotoScene("login") else print( "Something went wrong.") end end

^this is how it should look but you do need to add other fields

local function handleButtonEvent( event ) if ( "ended" == event.phase ) then local URL = "https://web.web.com/register.php?username=" .. mime.b64( username.text ) .. "&password=" .. mime.b64(password.text) .. "&email=" .. mime.b64( email.text ).. "&password2=" .. mime.b64( password2.text ).."&register=1" network.request(URL, "GET", networkListener) composer.gotoScene("login") else print( "Something went wrong.") end end

FYI Scott, I’m trying to get him to use GET instead of POST. PHP sometimes won’t read the key/value pairs from POST requests and there are some additional hoops to jump through to make it work.  GET is more reliable with PHP for small amounts of data.

Rob

Got it fixed above

It shows that the table is created but none of the users info is being shown 

Your sql is off, edit: try this instead

INSERT INTO users (email, pw, username) VALUES ($email, $pw, $username);

It also still allows me to sign up with the same username and password

  1. is it working?

  2. you will have to check this in your php and make sure it does not already exist

INSERT INTO users (email, pw, username) VALUES ($email, $pw, $username);

In my database my password is saved as password . The user account is created but the username , password and email fields are empty 

Try this instead

INSERT INTO users (email, password, username) VALUES ('$email', '$pw', '$username');
$sql = "INSERT INTO users (email, password, username) VALUES ('$email', '$pw', '$username');')";

When I put this it says : sorry something went wrong(my else code)

$sql = "INSERT INTO users (email, password, username) VALUES ('$email', '$pw', '$username')";

I think the problem is that my password isn’t saved as “pw” it’s saved as “password” and the fields aren’t in order 

you set them as

$username = $\_POST['username']; $pw = $\_POST['password']; $email = $\_POST['email'];

Are you sure these values are making it to the php?

Can you post your current PHP script. I think we are looking at older versions (in particular since we are still looking at $_POST which should be gone.

As for the SQL:

$sql = “INSERT INTO users (email, password, username) VALUES (’” . $email . “’, '” . $pw . “’, '” . $username . “’)”;

You have to concatenate the actual variable values into the SQL string.

Rob

if ($_GET[‘password’] == $_GET[‘password2’]) {

                     $username = $_GET[‘username’];

                     $password = base64_decode( $_GET[‘password’]);

                     $password2 = ( $_GET[‘password2’]);

                     $email= base64_decode( $_GET[‘email’]);

           // validate and sanitize all of these inputs

           // and see that they are not blank at the same time

           // Do your MySqli here to find the $username and 

           // bring out result of find in $username_result   

       

       $result = mysqli_query($con ,"SELECT * FROM users WHERE username = 1 AND email = 1 ");

                        if(mysqli_num_rows($result ) > 0)

                        {

                        echo “User exist”;

                        } else {

                        // it is not in use so put it in

                           $sql = “INSERT INTO users (email, password, username) VALUES (’” . $email . “’, '” . $pw . “’, '” . $username . “’)”;

                           if(mysqli_query($con, $sql)){                                  

                           }else{

                           echo “Sorry something went wrong.”;

                           }   

}

                }else{

                echo “Passwords don’t match.”;

                }