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 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记