Problem with validation

Asked

Viewed 33 times

0

I have this input in php:

<input id="complement" class='input-without-icon' type="text" placeholder="Complemento/Referência" value='<?php echo $Menu->getAddressComplement() ?>' />

I pass his id to the javascript and via ajax uploading to another file php,

if ($street === $streetOriginal && $town === $townOriginal && $complement === $complementOriginal) {
    $stmtSaveAddress = $conn->prepare("UPDATE address SET street = :street, number = :number, town = :town, complement =                                       :complement, city_id = (select city.city_id from city where city.link = :cityLink) WHERE address_id = :address");
    $stmtSaveAddress->bindValue(':street', $street);
    $stmtSaveAddress->bindValue(':number', ($number <= 0 ? NULL : $number));
    $stmtSaveAddress->bindValue(':town', $town);
    $stmtSaveAddress->bindValue(':complement', $complement);
    $stmtSaveAddress->bindValue(':cityLink', $city);
    $stmtSaveAddress->bindValue(':address', $addressId);

    echo'rua: '.$street;
    echo'number: '.$number;
    echo'bairro: '.$town;
    echo'complement: '.$complement;
    echo'cityLink: '.$city;
    echo'complemento original: '.$complementOriginal;
    echo'complemento: '.$complement;
        if ($stmtSaveAddress->execute()) {
            echo 'trueaddress';
        } else {
            if ($townOriginal != $town) {
                echo 'town';
            }
            if ($streetOriginal != $street) {
                echo 'street';
            }
            if ($complementOriginal != $complement) {
                echo 'complement';
            }
        }
}

I do exactly the same thing to street, town and complement, but I’m only in trouble at complement. I check if you have swear if you have it else, if it does not perform. What can it be? I gave echo variables and are all as they should be.

Here I correct the bad words:

$obs = correctBadWords($obsOriginal); $history = correctBadWords($historyOriginal); $town = correctBadWords($townOriginal); $complement = correctBadWords($complementOriginal); $street = correctBadWords($streetOriginal); $name = correctBadWords($nameOriginal);

  • 2

    Looks like you got a key (}) remaining in the second if... Gives a check...

  • @Magichat really was overstaying, thanks.. But it didn’t solve..

  • Ana, your description doesn’t match the code, where exactly are you checking for swear words? Before doing this check, is the content coming correctly? If yes, post the code that does this check....

  • @Kennyrafael I added to the code where I valid my bad words. It actually corrects the variable.

  • have the code of that function? before going through it is all ok, right?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.