我是这个领域的新手,并且...我认为自己是一个新手...而且我想为一个在这个时刻超过我的知识的网站做点什么。 我在html中有一个表单,我想从该表单生成答案到txt / word / excel文件。我不知道该怎么做。我看到在这个网站上有超过1000个问题,但我找不到我需要的答案。这是表格。请帮我。我必须提一下,我只是一个有着光明未来的16岁程序员:)
<div id="content">
<div class="content_item">
<link rel="stylesheet" href="chestionar_files/formoid1/formoid-solid-green.css" type="text/css" />
<script type="text/javascript" src="chestionar_files/formoid1/jquery.min.js"></script>
<form class="formoid-solid-green" style="background-color:#ffffff;font-size:14px;font-family:'Roboto',Arial,Helvetica,sans-serif;color:#34495E;max-width:480px;min-width:150px" method="post">
<div class="title"><h2>Chestionar</h2></div>
<div class="element-checkbox"><label class="title">Sex</label> <div class="column column1"><label><input type="checkbox" name="checkbox[]" value="Masculin"/ ><span>Masculin</span></label><label><input type="checkbox" name="checkbox[]" value="Feminin"/ ><span>Feminin</span></label></div><span class="clearfix"></span>
</div>
<div class="element-textarea"><label class="title"></label><div class="item-cont"><textarea class="medium" name="textarea2" cols="20" rows="5" placeholder="Ocupatia"></textarea><span class="icon-place"></span></div></div>
<div class="element-number"><label class="title"></label><div class="item-cont"><input class="large" type="text" min="0" max="100" name="number1" placeholder="Varsta" value=""/><span class="icon-place"></span></div></div>
<div class="element-radio"><label class="title">De unde ati aflat de centrul nostru?</label> <div class="column column1"><label><input type="radio" name="radio" value="de la medicul de familie/specialist" /><span>de la medicul de familie/specialist</span></label><label><input type="radio" name="radio" value="de la un fost pacient(prieten/coleg/ruda)" /><span>de la un fost pacient(prieten/coleg/ruda)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de comunicarea directa si telefonica cu receptia?</label> <div class="column column1"><label><input type="radio" name="radio2" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio2" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio2" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de informatiile obtinute la receptie?</label> <div class="column column1"><label><input type="radio" name="radio3" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio3" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio3" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de respectarea datei si orei programarii?</label> <div class="column column1"><label><input type="radio" name="radio4" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio4" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio4" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de profesionalismul asistentelor?</label> <div class="column column1"><label><input type="radio" name="radio5" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio5" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio5" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de profesionalismul doctorilor?</label> <div class="column column1"><label><input type="radio" name="radio6" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio6" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio6" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de timpul de asteptare al rezultatelor?</label> <div class="column column1"><label><input type="radio" name="radio7" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio7" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio7" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de tarifele practicate per serviciu?</label> <div class="column column1"><label><input type="radio" name="radio8" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio8" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio8" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Sunteti multumit(a) de informatiile obtinute de pe site-ul nostru?</label> <div class="column column1"><label><input type="radio" name="radio9" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio9" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio9" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-separator"><hr><h3 class="section-break-title"></h3></div>
<div class="element-radio"><label class="title">Care este impresia dumneavoastra generala despre centrul nostru?</label> <div class="column column1"><label><input type="radio" name="radio10" value="Sunt multumit(a)" /><span>Sunt multumit(a)</span></label><label><input type="radio" name="radio10" value="Sunt oarecum multumit(a)" /><span>Sunt oarecum multumit(a)</span></label><label><input type="radio" name="radio10" value="Sunt nemultumit(a)" /><span>Sunt nemultumit(a)</span></label></div><span class="clearfix"></span>
</div>
<div class="element-email"><label class="title"></label><div class="item-cont"><input class="large" type="email" name="email" value="" placeholder="Email (optional)"/><span class="icon-place"></span></div></div>
<div class="element-rating"><label class="title">Oferiti o nota centrului nostru</label><div class="rating"><input type="radio" class="rating-input" id="rating-5" name="rating" value="5" /><label for="rating-5" class="rating-star"></label><input type="radio" class="rating-input" id="rating-4" name="rating" value="4" /><label for="rating-4" class="rating-star"></label><input type="radio" class="rating-input" id="rating-3" name="rating" value="3" /><label for="rating-3" class="rating-star"></label><input type="radio" class="rating-input" id="rating-2" name="rating" value="2" /><label for="rating-2" class="rating-star"></label><input type="radio" class="rating-input" id="rating-1" name="rating" value="1" /><label for="rating-1" class="rating-star"></label></div></div>
<div class="submit">
<input type="submit" value="Submit"/>
</div>
</form>
<p class="frmd">
<a href="http://formoid.com/v29.php">css form</a>
</p>
<script type="text/javascript" src="chestionar_files/formoid1/formoid-solid-green.js"></script>
</div>
</div>
答案 0 :(得分:0)
简单地将表单内容添加到文本文件中非常简单 - 一种方法可以简单:
<?php
/* create text file in same directory as script */
$textfile = __DIR__ . DIRECTORY_SEPARATOR . 'answers.txt';
if( $_SERVER['REQUEST_METHOD']=='POST'] ){
foreach( $_POST as $field => $value ){
/* string with field name and submitted value */
$qa = $field .':'.$answer.PHP_EOL;
/* write the string to the textfile */
file_put_contents( $textfile,$qa,FILE_APPEND | FILE_TEXT );
}
}
?>
当表单通过POST
提交时,POST数组中的每个表单元素都应该将其名称和值添加到文件中。写入WORD
或EXCEL
文件涉及的内容要多得多,尽管在互联网上有辅助库以简化过程。希望上面有所帮助。