尝试输出用户输入的数据

时间:2016-04-07 08:04:56

标签: php html forms

我在尝试将用户输入的数据输出到表单时遇到问题。这是一个2块的形式,我只是想将数据保存到2个变量然后回显变量。但我不明白我哪里出错了。任何帮助赞赏。

    <?php

echo $problem = ""; 


if(isset($_POST['submit']) && $_POST['submit']=="submit"){

    if(!empty($_POST['eWeight']) && $_POST['eWeight']!=''){       
$eWeight = mysqli_real_escape_string($conn, trim($_POST['eWeight']));
    } else {
       $problem .= "Please enter a weight. <br/>";
}

if(!empty($_POST['gym']) && $_POST['gym']!=''){       
$gym = mysqli_real_escape_string($conn, trim($_POST['gym']));
    } else {
       $problem .= "Please enter time at gym. <br/>";
}



echo $eWeight, $gym;





}


?>
<?php
if($conn){
     echo "connected";
}

echo $problem;
echo $eWeight;

?>
  <form class="pure-form pure-form-stacked" name="contact_weight">

 <label for="eWeight">Enter Weight: </label> <input type="number" id="eWeight" name="eWeight" placeholder="88" required/>


 <label for="gym">Enter Time at Gym: </label> <input type="number" id="gym" name="gym" placeholder="60" required/>

<button class="submit" type="submit">Submit Form</button>
</form>

0 个答案:

没有答案