简体   繁体   中英

POST a form, the output show differently when echoing

Is kind of unlogical, or i cannot see the mistake. I have a input about 9 input POST from a form. when i post a form, only 1 input tag will show "on" when echo output, other is working okay.

So why it show output like that.

This only part of the code

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
    $namaPenuh = check($_POST["namaPenuh"]);

    echo $namaPenuh;
}

function check($data)
{
    $data = trim($data);
    $data = strtoupper($data);
    $data = stripslashes($data);
    $data = addslashes($data);
    $data = htmlspecialchars($data);

    return $data;
}

?>

<form class="form-horizontal" role="form" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <div class="form-group">
        <label class="col-sm-3 control-label no-padding-right" for="form-namaPenuh"> <b>NAMA PENUH :</b> </label>

        <div class="col-sm-9">
            <input name="namaPenuh" type="text" id="form-namaPenuh" placeholder="CONTOH : AHMAD RAHIM BIN HASSAN" class="col-xs-10 col-sm-5" required />
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-3 col-md-9">
            <button class="btn btn-info" type="submit">
                <i class="ace-icon fa fa-check bigger-110"></i>
                DAFTAR
            </button>

            &nbsp; &nbsp; &nbsp;
            <a class="btn btn-danger" href="index.php">
                <i class="ace-icon fa fa-undo bigger-110"></i>
                KEMBALI
            </a>
        </div>
    </div>
</form>

OUTPUT

ON

If i use that part code for testing it working good, if i run full code, the output is like that.

FULL CODING HERE https://ufile.io/ch38a

change the name for this input.

<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-privacy"> <b> AKTA PRIVASI :</b> </label>

    <div class="col-sm-9">
        <!-- namaPenuh to privacy-->
        <input name="privacy" type="checkbox" id="form-privacy" class="col-xs-10 col-sm-5" required />
    </div>
</div>
<div class="form-group">
    <label class="col-sm-3 control-label no-padding-right" for="form-spam"> <b>ANTI-SPAM :</b> </label>

    <div class="col-sm-9">
        <input name="spam" type="checkbox" id="form-spam" class="col-xs-10 col-sm-5" required />
    </div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM