PHP:电子邮件表单中不需要的空间

时间:2015-11-08 20:11:48

标签: php forms

每次用户按下发送'按钮没有在表单字段中输入任何数据,一个空格被添加到' name'领域。如果用户在此字段中键入内容并按下发送',则在文本之前也会添加该空格。按钮没有填写其他字段。

我发现如果我删除了'名称'的PHP代码。输入标签,空间消失了。

我想找出造成这种情况的原因,而不是添加代码来清空字段,谢谢。

任何帮助都可以摆脱这个空间。

接触form.php的:

    for (int i = 0; i < positionList.size(); i++) {

        xPost = (float)(mArcRect.centerX() + mArcRadius* Math.cos(Math.toRadians(calculatePointerAngle((positionList.get(i).getPosition()+270)))));
        yPost = (float) (mArcRect.centerY() + mArcRadius * Math.sin(Math.toRadians(calculatePointerAngle((positionList.get(i).getPosition()+270)))));


        setflagX(xPost);
        setflagxY(yPost);
        points.add(new Points(xPost, yPost));


        // }
    }

测试-email.php:

 @Override
      public void onDraw(Canvas canvas) {
        //Draw the flag

    final Resources res = getResources();

// while (coordinates.iterator().hasNext()){
for (int i = 0; i < coordinates.size(); i++) {
    if (i == 0) {

        bm = BitmapFactory.decodeResource(res, R.drawable.ic_flag_red);

        canvas.drawBitmap(bm, coordinates.get(i).getX(),      coordinates.get(i).getY(), null);
        } else {

            bm = BitmapFactory.decodeResource(res, R.drawable.ic_flag_blue);

            canvas.drawBitmap(bm, coordinates.get(i).getX(), coordinates.get(i).getY(), null);

        }
    }



}`

的main.css:

        <?php if( !empty($errors)) : ?>
            <div class="panel">  
                <ul><li><?php echo implode('</li><li>', $errors); ?></li></ul>
            </div>
            <script src="_scripts/scroll.js" type="text/javascript" charset="utf-8"></script>
        <?php endif; ?>

        <form action="testing-email.php" method="post">
            <label>Name *<input type="text" placeholder="Insert your name here.." name="name" autocomplete="off"<?php echo isset($fields['name']) ? ' value= " '. e($fields['name']) . ' " ' : ''?>>
            </label>
            <label>Email *<input type="email" placeholder="Insert your email here.." name="email" autocomplete="off"<?php echo isset($fields['email']) ? ' value=" '. e($fields['email']) . ' " ' : ''?>>
            </label> 
            <label>Message *<textarea placeholder="Insert your message here.." name="message" rows="8"><?php echo isset($fields['message']) ? e($fields['message']) : ''?></textarea>
            </label>

            <input type="submit" value="Send" class="sendEmail">

            <br>
            <p class="muted">* means a required field</p>
        </form>

2 个答案:

答案 0 :(得分:1)

这一行有一个额外的空间:

<label>Name *<input type="text" placeholder="Insert your name here.." name="name" autocomplete="off"<?php echo isset($fields['name']) ? ' value= " '. e($fields['name']) . ' " ' : ''?>>

替换它:

<label>Name *<input type="text" placeholder="Insert your name here.." name="name" autocomplete="off"<?php echo isset($fields['name']) ? ' value="'. e($fields['name']) . '" ' : ''?>>

答案 1 :(得分:1)

Jeroen是对的。您在价值中添加了空格:

value= " '. e($fields['name']) . ' " ' : ''

更改为:

value= "'. e($fields['name']) . '"' : ''