我是PHP的新手,需要创建一个表单。当我按submit
时,我的表单不输出我输入到表单中的数据。这些文件是从我的Apache服务器的htdocs
文件夹运行的。任何帮助将不胜感激。
这是我的HTML
代码
<html>
<body>
<style>
body {
background-color: #66c2ff;
font-family: 'Tangerine', serif;
font-size: 24px;
}
</style>
<div id="header" class="section">
<p style="text-align:center;"> <img src="http://i63.tinypic.com/34sgvpy.png"> </p>
<p align="center">Welcome</p>
</div>
<form action="abiform.php" method="post">
<p>Company Name: <input type="text" name="yourname" /><br />
<br />
E-mail: <input type="text" name="email" /><br /></P>
<p>Urgency:
<input type="radio" name="urgency" value="Low" checked="checked" /> Low
<input type="radio" name="urgency" value="Medium" /> Medium
<input type="radio" name="urgency" value="High" /> High</p>
<p>Existing Feature or Issue:
<input type="radio" name="existingissue" value="Yes" checked="checked" /> Yes
<input type="radio" name="existingissue" value="No" /> No
<input type="radio" name="existingissue" value="Not Sure" /> Not Sure</p>
<p>Max Hours Willing to Spend on Issue: <input type="text" name="hours" /><br /></P>
<p>Issue Description:<br />
<textarea name="description" rows="10" cols="40"></textarea></p>
<p>Expected Outcome:<br />
<textarea name="outcome" rows="10" cols="40"></textarea></p>
<p><input type="submit" value="Submit"></p>
</form>
</body>
</html>
我的PHP
表格
<?php
$yourname = check_input($_POST['yourname']);
$email = check_input($_POST['email']);
$urgency = check_input($_POST['urgency']);
$existingissue = check_input($_POST['existingissue']);
$hours = check_input($_POST['hours']);
$description = check_input($_POST['description']);
$outcome = check_input($_POST['outcome']);
?>
<html>
<body>
Company Name: <?php echo $_POST['yourname']; ?><br />
<br />
Company e-mail: <?php echo $_POST['email']; ?><br />
<br />
Urgency: <?php echo $_POST['urgency']; ?><br />
<br />
Existing Feature or Issue? <?php echo $_POST['existingissue']; ?><br />
<br />
Max Hours Willing to Spend on Issue: <?php echo $_POST['hours']; ?><br />
<br />
Issue Description:<br />
<?php echo $_POST['description']; ?>
<br />
Expected Outcome:<br />
<?php echo $_POST['outcome']; ?>
</body>
</html>
<?php
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
答案 0 :(得分:0)
因为你试图在创建之前检查输入,像这样编辑你的php文件。
<?php
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$yourname = check_input($_POST['yourname']);
$email = check_input($_POST['email']);
$urgency = check_input($_POST['urgency']);
$existingissue = check_input($_POST['existingissue']);
$hours = check_input($_POST['hours']);
$description = check_input($_POST['description']);
$outcome = check_input($_POST['outcome']);
?>
<html>
<body>
Company Name: <?php echo $_POST['yourname']; ?><br />
<br />
Company e-mail: <?php echo $_POST['email']; ?><br />
<br />
Urgency: <?php echo $_POST['urgency']; ?><br />
<br />
Existing Feature or Issue? <?php echo $_POST['existingissue']; ?><br />
<br />
Max Hours Willing to Spend on Issue: <?php echo $_POST['hours']; ?><br />
<br />
Issue Description:<br />
<?php echo $_POST['description']; ?>
<br />
Expected Outcome:<br />
<?php echo $_POST['outcome']; ?>
</body>
</html>
答案 1 :(得分:0)
问题出在localhost
上。解决方案是在这个帖子中:PHP code is not being executed, instead code shows on the page。这是https
问题,我必须使用HTML
localhost
打开https
文件