doushi1510 2017-03-23 08:40
浏览 181

bootstrap php联系表单值显示错误<br /> <b>通知</ b>:未定义变量:<b> C:\ x \ testForm.php </ b>中的myThema <b> 105 </ b> <br />

I am using bootstrap and I want to create a contact Form. I have create a File with the name testForm.php and there I have written my php and my html code(should I make a different files? one for php and one for html?). My file starts with the php code to and after the html code. As soon as I put an <?php echo.... in the html area, everywhere, appears all the time in the site Undefined index: .for example enter image description here

Now I m trying only with one parameter :thema to see if it works and how it works and if I put something to value comes the result like the picture above. My php code:

<?php
if (isset($_POST["submit"])) {
    $thema = $_POST['thema'];



    // Check if thema has been entered
    if (!$_POST['thema']) {
        $errThema = 'Please enter your thema';
    }


}

?>

and my html code:

<!-- MAIN SEITE -->
<h4><p class="text-primary"><u>Neuanforderungsformular</u></p></h4>

<!-- START FORM -->
<form method="post" role="form" action="testForm.php">
<!-- Thema Feld -->
<div class="form-group">
    <label for="usr">Thema / Title:</label>
    <input type="text" id="thema" name="thema" class="form-control input-lg" value="<?php echo htmlspecialchars($_POST['thema']); ?>">
</div>
<!-- Email Adresse Feld-->
<div class="form-group">
    <label for="exampleInputEmail1">Email address</label>
    <div class="input-group col-sm-5">
    <input type="text" class="form-control input-lg" placeholder="Ihre Email Addresse" aria-describedby="basic-addon2">
    <span class="input-group-addon" id="basic-addon2">@teswt.de</span>
</div>

how can I fix the provbem so my contact form will works?

  • 写回答

5条回答 默认 最新

  • doutiaosu2310 2017-03-23 08:44
    关注

    Try this:

    <?php
    if (isset($_POST["submit"])) {
        if (isset($_POST['thema'])){
            $thema = $_POST['thema'];
        } else {
            $thema = 'Please enter your thema';
        }
    }
    ?>
    

    You should check first if $thema has been set. What you did is you are using $_POST['thema'] without checking, thus the error appearing in the text field

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作