0

I got an error while creating a live-check on password on my page.

this is my js

$(document).ready(function()
{
var password;
var repassword;
$('#password').keyup(function (f)
{
    $(this).val($(this).val().replace(/\s/g, ''));

    password = $(this).val();

    if(password.length < 5)
    {
        $("#password-result").html('');
        return;
    }

    if(password.length >= 5){
        $("#password-result").html('<img src="images/available.png" />');
    }
});

$('#repassword').keyup(function (g)
{
    $(this).val($(this).val().replace(/\s/g, ''));

    repassword = $(this).val();

    if(repassword.length < 5)
    {
        $("#repassword-result").html('');
        return;
    }

    if(repassword.length >= 5){
        $("#repassword-result").html('<img src="ajax-loader.gif" />');
        $.post('check.php',{
            'password':password,
            'repassword':repassword
        },
            function(data){
                $("#repassword-result").html(data);
            });
    }
});
});

If there is a way to simplify that then I would appreciate any help :)

And this is my php

if(isset($_POST["repassword"])){
$password = $_POST["password"];
$repassword = $_POST["repassword"];

if($password == $repassword){
    die $password;
}
else{
    die $repassword;
}}

I don't know why i got an error is this part

    die $password;

it says Parse error: syntax error, unexpected '$password' (T_VARIABLE) in C:\xampp\htdocs\ secret \check.php on line 7

Z'K
  • 29
  • 9

1 Answers1

0

die is a function so you'd have to do

die($password);
PhilMasterG
  • 2,425
  • 1
  • 16
  • 22