Php echo,清除我周围的html?
我在一个网站上上课,我有一个表单系统。我的朋友正在进行设计,因此索引站点实际上就是这样:Php echo,清除我周围的html?,php,echo,Php,Echo,我在一个网站上上课,我有一个表单系统。我的朋友正在进行设计,因此索引站点实际上就是这样: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nail n' Bolts man</title>
<link href="../../styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
</head>
<body>
<div id="main">
<center>
<div id="header">
Nails & Bolts APS - Admin side
<img src="../images/header.jpg" alt="header" width="" height="" />
</div>
<?php require('php/newEmployee.php'); ?>
</center>
</div>
</body>
</html>
钉子
钉子和螺栓APS-管理侧
然后在newEmployee.php中,我还需要另一个名为varibleEcho.php的文件。基本上,这个文件只有一个带有switch case语句的函数,根据从newEmployee.php调用的内容,回显不同的代码
然而,由于某种原因,当我用谷歌chrome检查网站的来源时,似乎回音清除了除我回音之外的所有内容。这意味着我的元数据cssjquery和类似的文件
你知道它为什么会有这种行为吗
编辑:
以下是整个网站(indes.php):
newEmployee.php
<?php
require('php/variableEcho.php');
if(!isset($_POST['rank']) || !isset($_POST['fname']) || !isset($_POST['lname']) || !isset($_POST['initials']))
{
variableEcho(0);
variableEcho(1);
}
else if($_POST['rank'] == '' || $_POST['fname'] == '' || $_POST['lname'] == '' || $_POST['initials'] == '')
{
variableEcho(0);
variableEcho(3);
variableEcho(1);
}
else if($_POST['password'] != '')
{
echo $_POST['password'];
$hasLetter = false;
$hasNumber = false;
$hasLength = false;
$pwd = $_POST['password'];
$strlen = strlen($pwd);
$pwdarr = str_split($pwd);
$ints = 0;
$chars = 0;
foreach($pwdarr as $x)
{
if(is_int($x))
{
$ints++;
}
if(ctype_alpha($x))
{
$chars++;
}
}
if($ints >= $strlen || $chars >= $strlen)
{
variableEcho(0);
variableEcho(4);
variableEcho(1);
}
if($strlen >= 8)
{
variableEcho(0);
variableEcho(4);
variableEcho(1);
}
}
?>
可变回声
<?php
function variableEcho($echoSelect)
{
switch($echoSelect)
{
case 0:
echo('
<form action="" method="post">
<table>
');
break;
case 1:
echo('
<tr>
<td><label for="fname">First name*</label></td>
<td><input type="text" name="fname" id="fname"/></td>
</tr>
<tr>
<td><label for="lname">Last name*</label></td>
<td><input type="text" name="lname" id="lname"/></td>
</tr>
<tr>
<td><label for="rank">Rank*</label></td>
<td><input type="text" name="rank" id="rank"/></td>
</tr>
<tr>
<td><label for="initials">Initials (3 length)*</label></td>
<td><input type="text" name="initials" id="initials"/></td>
</tr>
<tr>
<td><label for="password">Password</label></td>
<td><input type="text" name="password" id="password"/></td>
</tr>
<tr>
<td><input type="submit"/></td>
</form>
');
break;
case 2:
echo('
<tr>
<td><div class="errText">A password is required for admins.</div></td>
<td></td>
</tr>
');
break;
case 3:
echo('
<tr>
<td><div class="errText">Please fill out all the obligatory fields.</div></td>
<td></td>
</tr>
');
case 4:
echo('
<tr>
<td><div class="errText">The password need to be of atleas one letter, one number, and 8 long.</div></td>
<td></td>
</tr>
');
break;
default:
echo('
biscuit
');
break;
}
}
?>
我解决了我的问题,不幸的是,问题很简单:p
需要'newEmployee.php'
将包含该php文件。在该文件中,我需要另一个文件,其中文件路径是相对于newEmployee.php locaiton的。现在,我从主文件中包括variableEcho和newEmployee
<?php
require('../../php/variableEcho.php');
require('../../php/newEmployee.php');
?>
我不知道是什么原因造成的,但您可以通过删除大部分代码(并验证问题不再发生)并缓慢添加位,直到问题再次出现,来进行故障排除。另外,在案例3中,你没有休息时间。默认情况下不需要中断。我假设问题发生在有人提交表单之后,如果是这样,请检查浏览器中的URL,并确保它是它应该是的,您将表单上的action
属性保留为空,因为它应该发送给自己。根据输入,我向站点回显不同的内容,因此也在默认站点上。