PHP和HTML问题
下午好,康姆尼 问题是我的index.html上有一个DIV-PA,如果你没有连接,它会显示一个登录窗口;如果你连接,它会显示一个属性窗口 问题是当我使用代码时,我得到了这个stetic错误 除了这个错误,代码工作正常PHP和HTML问题,php,html,Php,Html,下午好,康姆尼 问题是我的index.html上有一个DIV-PA,如果你没有连接,它会显示一个登录窗口;如果你连接,它会显示一个属性窗口 问题是当我使用代码时,我得到了这个stetic错误 除了这个错误,代码工作正常 <div id="apDiv7"> <?php boolean allowed = false; if (allowed) { echo "<br><br><form name="form1" method="post" a
<div id="apDiv7">
<?php
boolean allowed = false;
if (allowed)
{
echo "<br><br><form name="form1" method="post" action="">
<label for="Usuario"></label>
<input type="text" name="Usuario" id="Usuario" align="absmiddle" size="23" >
</form>
<form name="form2" method="post" action="">
<label for="clave"></label>
<br>
<input type="password" name="clave" id="clave" size="23">
</form>
<div><form name="form3" method="post" action="">
<input type="checkbox" name="casilla" id="casilla">
Seguir Logeado
<label for="casilla"></label>
<input type="reset" name="Crear" id="Crear" value="Entrar">
</form>
</div>
<br>
<div><a href="descargar.php">Problema</a>
</div>
<div><a href="file:///C|/xampp/htdocs/descargar.php">Registrarse</a>
</div>"
}else{
echo "another code";
}
?>
</div>
如果我写错了什么,我的英语没有我想要的那么好
先谢谢你。我的问候
编辑:
更重要的是,我对每个句子都使用了回音,尝试了1个引号,尝试了html代码和nothing之间的转换。
PS:在dreamweaver c6的“设计”选项卡中,我没有在浏览器上看到这个问题
最终编辑:您发布的大部分代码都可以正常工作,但由于某些原因(可能是htaccess问题),我的电脑无法正常工作…谢谢大家 您的问题是,您对所有内容都使用了双引号(“),因此您无数次地打开和关闭字符串。事实上,我很惊讶您得到了这样的结果,但我确信您的错误文件已满 试试这个:
div id="apDiv7">
<?php
boolean allowed = false;
if (allowed)
{
echo '<br><br><form name="form1" method="post" action="">
<label for="Usuario"></label>
<input type="text" name="Usuario" id="Usuario" align="absmiddle" size="23" >
</form>
<form name="form2" method="post" action="">
<label for="clave"></label>
<br>
<input type="password" name="clave" id="clave" size="23">
</form>
<div><form name="form3" method="post" action="">
<input type="checkbox" name="casilla" id="casilla">
Seguir Logeado
<label for="casilla"></label>
<input type="reset" name="Crear" id="Crear" value="Entrar">
</form>
</div>
<br>
<div><a href="descargar.php">Problema</a>
</div>
<div><a href="file:///C|/xampp/htdocs/descargar.php">Registrarse</a>
</div>';
}else{
echo 'another code';
}
?>
</div>
divid=“apDiv7”>
或者,这是我在PHP文件中编写HTML时的首选方法
div id="apDiv7">
<?php
boolean allowed = false;
if (allowed)
{
?>
<br><br><form name="form1" method="post" action="">
<label for="Usuario"></label>
<input type="text" name="Usuario" id="Usuario" align="absmiddle" size="23" >
</form>
<form name="form2" method="post" action="">
<label for="clave"></label>
<br>
<input type="password" name="clave" id="clave" size="23">
</form>
<div><form name="form3" method="post" action="">
<input type="checkbox" name="casilla" id="casilla">
Seguir Logeado
<label for="casilla"></label>
<input type="reset" name="Crear" id="Crear" value="Entrar">
</form>
</div>
<br>
<div><a href="descargar.php">Problema</a>
</div>
<div><a href="file:///C|/xampp/htdocs/descargar.php">Registrarse</a>
</div>
<?php
}else{
?>
another code
<?php
}
?>
</div>
divid=“apDiv7”>
塞奎尔洛格多酒店
另一个代码
请注意,HTML不在PHP标记中,而是在PHP if语句中。它仍然有效,这样做时,您不必担心跨越PHP和HTML语法。这是因为您对echo和HTML代码都使用了双引号
在echo上使用单引号,这种情况将不会再次发生。您不需要
echo
。请关闭并重新打开php
代码中的HTML。
此外,您的php变量前面需要一个美元符号。试试这个
<div id="apDiv7">
<?php
$allowed = false;
if ($allowed){
?>
<br><br>
<form name="form1" method="post" action="">
<label for="Usuario"></label>
<input type="text" name="Usuario" id="Usuario" align="absmiddle" size="23" >
</form>
<form name="form2" method="post" action="">
<label for="clave"></label>
<br>
<input type="password" name="clave" id="clave" size="23">
</form>
<div>
<form name="form3" method="post" action="">
<input type="checkbox" name="casilla" id="casilla">
Seguir Logeado
<label for="casilla"></label>
<input type="reset" name="Crear" id="Crear" value="Entrar">
</form>
</div>
<br>
<div><a href="descargar.php">Problema</a>
</div>
<div><a href="file:///C|/xampp/htdocs/descargar.php">Registrarse</a>
</div>
<?php
}
else{
echo "another code";
}
?>
</div>
塞奎尔洛格多酒店
这是带有输出的代码截图。通过添加AddType应用程序/x-httpd-php php4 php3 html htm
,确保在.htaccess
中启用了php
。.htaccess
文件应位于服务器的根目录中(与index.php
相同)
正确显示不同部分的一些代码 现在只有一个表单带有“提交”按钮 由于逻辑太少,我对逻辑语句使用了“替代语法”
<div id="apDiv7">
<?php
/* debug */ var_dump($_POST); // remove this -- i want to see the input.
$allowed = true; // force the login screen to be shown
?>
<?php if ($allowed): ?>
<br><br><form name="form1" method="post" action="">
<label for="Usuario">Usuario</label>
<input type="text" name="Usuario" id="Usuario" align="absmiddle" size="23" >
<br>
<label for="clave">clave</label>
<input type="password" name="clave" id="clave" size="23">
<div>
<input type="checkbox" name="casilla" id="casilla">
Seguir Logeado
<label for="casilla"></label>
<input type="submit" name="Crear" id="Crear" value="Entrar">
</form>
</div>
<br>
<div><a href="descargar.php">Problema</a>
</div>
<div><a href="file:///C|/xampp/htdocs/descargar.php">Registrarse</a>
</div>
<?php else: ?>
another code
<?php endif; ?>
</div>
乌萨里奥
克拉夫
塞奎尔洛格多酒店
另一个代码
检查引号。每次使用“
时,它会关闭/重新打开一个字符串。页面上有三个html表单,没有“提交”按钮。您有一个“重置”按钮,但它只是清除form3的字段。form1和forms2中的数据是如何发送的?另外,如何设置“$allowed”变量以强制显示登录屏幕?谢谢您的回复David先生,我尝试了第一个选项,但仍然遇到相同的问题,第二个选项不起作用,如果/否则,因为它在屏幕上显示两个代码。Regards@user3433247你的错误日志是怎么写的?清除它,重新加载文件,然后查看出现了什么错误。谢谢你,mseifert先生,但是如果/else…仍然在屏幕上显示两个代码(表单和回音),则此代码不起作用。当上述代码粘贴到新文档中并运行时,它将显示另一个代码,而不会显示其他代码。我按照你说的做了,并将上面的代码粘贴到一个新的HTML文档中,但我得到的是表单,而不是“另一个代码”。你收到另一个密码了吗?你在使用html文档吗?对不起,占用了你一些时间!我已经上传了代码的截图并在浏览器中输出。无论使用php扩展还是html扩展,我都会得到相同的结果。通过添加AddType应用程序/x-httpd-php php4 php3 html htm
,确保在.htaccess
中启用了php。.htaccess
文件应该在您服务器的根目录下(与index.php
相同)。我读了一点,它看起来像窗口上的xampp是不可访问的htaccess…我将尝试启用,看看是否可以成功。