嗨,我是一个初学者 PHP 开发人员,我正在尝试创建一个表单生成器。生成的表单有一些问题。例如,当我单击“段落”按钮时,会生成一个包含文本字段和另一个按钮的表单。
我想当我在生成的代码中输入一些文本并按下按钮执行某些功能时,我只打印文本。
这是我的代码:
<form action="" method="post">
<button type="submit" name ="Paragraph">Paragraph Text</button>
<button type="submit" name ="MultipleChoice">Multiple Choice</button>
<button type="submit" name ="Name">Name</button>
<button type="submit" name ="Adress">Address</button>
<button type="submit" name ="Number">Number</button>
<button type="submit" name ="CheckBoxes">Checkboxes</button>
<button type="submit" name ="DropDown">Drop Down</button>
<button type="submit" name ="Phone">Phone</button>
<button type="submit" name ="Email">Email</button>
</form>
<?php
require_once 'addform.php';
$buttons = array('Paragraph', 'MultipleChoice', 'Name',
'Adress', 'Number', 'CheckBoxes', 'DropDown', 'Phone', 'Email');
foreach ($buttons as $button){
if(isset($_POST[$button])){
$title;
$input;
if($button == 'Paragraph'){
?>
<form action="" methods="post">
Paragraph title: <input type="text" name="title"/>
<input type="submit" value="Create" name="create"/>
</form>
<?php
if(isset($_POST['title'])){
$title = $_POST['title'];
echo $title;
}
}
}
break;
}
?>
我在这里做错了什么?