我想在控制器内回显一个表单。在那我写了echo form_open,但它不起作用。 这是我在控制器函数中的代码
echo '<button class="btn btn-primary" data-toggle="modal" style="background-color:#428bca;" data-target="#myModal" ></button>';
echo '<div class="modal fade bs-example-modal-sm" tabindex="-1" id="myModal" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">';
echo '<div class="modal-dialog modal-sm">';
echo '<div class="modal-content">';
echo ' <div class="modal-header">';
echo '<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>';
echo '<h4> Do you </h4>';?>
<?php echo form_open('amt_controller/add_amount/'.$schoolID."/".$stID);
echo '<input type="name" class="form-control" name="Amount" id="Amount" placeholder="Enter the amount">';
echo '</div>';
echo '<div class="modal-body">';
echo '<button class="btn btn-primary" style="margin-left:65px;background-color:#428bca;">Submit</button>';?>
<?php echo form_close();
echo '<button type="button" class="btn btn-default" data-dismiss="modal">No</button>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
答案 0 :(得分:0)
删除表单上的php标签打开和关闭,并将它们放置为
echo <<<_END
<html><head><title>PHP from Upload</title></head><body>
<form method = 'POST' action='upload.php' enctype='multipart/form.data'>
Select a JPG, GIF, PNG or TIF File: <input type='file' name='filename' size='10'>
<input type='submit' value='Upload'>
</form>
_END;
if ($_FILES){
$name = $_FILES['filename']['name'];
switch($_FILES['filename']['name']){
case 'image/jpeg': $ext = 'jpg'; break;
case 'image/gif': $ext = 'gif'; break;
case 'image/png': $ext = 'png'; break;
case 'image/tiff': $ext = 'tif'; break;
default: $ext = ''; break;
}
if ($ext){
$n = "image.$ext";
move_uploaded_file($_FILES['filename']['tmp_name'], $n);
echo "<img src='$n'>";
}
else echo "'$name' is not an accepted image file";
}
else echo "No image has been uploaded";
echo "</body></html>";