dongshadu4498 2016-09-12 13:45
浏览 59
已采纳

Html表单成为Php表

So, im trying to get the informatino you put into an HTML into a Table in Php, problem is, i cant find any solutions online. and i dont know much about php yet. this is only my second time asking something so i still dont quite know the way you are supposed to fill in a question. anyway, here is the code in question:

HTML

</head>
<body>
<form action="http://www.cs.tut.fi/cgi-bin/run~jkorpela/echo.cgi"method="post">
<div>
<label for="vnaam">Voornaam</label>
<input type="text" id="vnaam" name="vnaam" required/>
</div>
<div>
<label for="anaam">Achternaam</label>
<input type="text" id="anaam" name="anaam" required/>
</div>
<div>
<label for="tnum">Telefoon Nummer</label>
<input type="text" id="tnum" name="tnum" />
</div>
<div>
<label for="tnum">E-mail</label>
<input type="email" id="tnum" name="tnum" />
</div>
<div>
<label for="adres">Adres</label>
<input type="" id="adres" name="adres" required/> 
</div>
<div>

<label for="land">Land</label>
<select id="land" name="land">
    <option value="ned">Nederland</option>
    <option value="usa">Amerika</option>
    <option value="eng">Engeland</option>
    <option value="bel">België</option>
    <option value="fr">Frankrijk</option>
    <option value="ger">Duitsland</option>
</select>
</div>
<div class="button">
 <button type="submit">Opsturen</button>

</div>
</form>



</body>
</html>

Css

 <style type="text/css">
 form {
 /* Just to center the form on the page */
 margin: 0 auto;
 width: 400px;
 /* To see the outline of the form */
 padding: 1em;
 border: 1px solid #CCC;
 border-radius: 1em;
}
form div + div {
margin-top: 1em;
}
label {
   /* To make sure that all labels have the same size and are properly     aligned */
    display: inline-block;
width: 90px;
text-align: right;
}
 input, textarea {
/* To make sure that all text fields have the same font settings
   By default, textareas have a monospace font */
font: 1em sans-serif;

/* To give the same size to all text field */
width: 300px;
-moz-box-sizing: border-box;
box-sizing: border-box;

/* To harmonize the look & feel of text field border */
border: 1px solid #999;
}
input:focus, textarea:focus {
/* To give a little highlight on active elements */
border-color: #000;
}
textarea {
/* To properly align multiline text fields with their labels */
vertical-align: top;

/* To give enough room to type some text */
height: 5em;

/* To allow users to resize any textarea vertically
   It does not work on all browsers */
resize: vertical;
}
.button {
/* To position the buttons to the same position of the text fields */
padding-left: 90px; /* same size as the label elements */
}
button {
/* This extra margin represent roughly the same space as the space
   between the labels and their text fields */
margin-left: .5em;
}

</style>
  • 写回答

2条回答 默认 最新

  • dshmkgq558192365 2016-09-12 14:12
    关注
     <form method='POST' action='formhandler.php'>
        <input type='text' name='name' value='john'>
        <input type='text' name='address' value='32 flowers street'>
        <input type='text' name='email' value='john@example.com'>
     </form>
    

    A typical form like this one will be delivered to the php file formhandler.php by the browser.

    Then you handle it in your formhandler.php file

    formhandler.php

    $name = isset($_POST['name']) ? $_POST['name'] : "";
    $address= isset($_POST['address']) ? $_POST['address'] : "";
    $email= isset($_POST['email']) ? $_POST['email'] : "";
    echo $name; //john
    echo $address; //32 flowers street
    echo $email; //john@example.com
    

    Now you have the form data. use it as you like, store them in a database, build another html response file to the user or do what ever you want to do with them.

    for example, we are going to feedback the data to the user.

    echo "We have successfully received your inputs as <br>
    <table>
        <tbody>
           <tr><td>name</td><td>$name</td></tr>
           <tr><td>address</td><td>$address</td></tr>
           <tr><td>email</td><td>$email</td></tr>
        </tbody>
    </table>";
    

    Note: in a real life production you need to validate any inputs come to your php files first.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?