我采用的是MVC模式的写法,代码和html分离的写法

<?php
require '../mysql_connect.php';
require('../model/functions.php');
include_once '../views/login.html.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') { // 处理表单
if (isset($_POST['login_submit'])) { $role = $_POST['role'];
$username = $_POST['username'];
$passwd = $_POST['p']; if( user_login($pdo,$role,$username,$passwd) ){
setcookie('userName',$name);
setcookie('password',$psw);
header("location: index.php");
}else{
echo "<script>alert('输入信息错误,登录失败');</script>";
} }elseif (isset($_POST['get_password'])) { $email = $_POST['email'];
user_register($pdo,$email);
}
}

  

我在一个页面内写了两个form表单,但是两个表单都是提交到同一个PHP文件处理,到时提交第二个表单时就一直报这种错误,

 解决方法:

只需要将第四行的html代码移到最后

PHP cannoy modify header information - headers already sent by ....的更多相关文章

  1. 阿里云服务器出现Warning: Cannot modify header information - headers already sent by (output started at 问题的解决方法

    阿里云服务器出现Warning: Cannot modify header information - headers already sent by (output started at 问题的解决 ...

  2. php有些系统会报错或提示 Cannot modify header information - headers already sent by

    Warning: Cannot modify header information - headers already sent by (output started at /home/test/do ...

  3. PHP错误Warning: Cannot modify header information - headers already sent by解决方法

    这篇文章主要介绍了PHP错误Warning: Cannot modify header information - headers already sent by解决方法,需要的朋友可以参考下 今天在 ...

  4. Warning: Cannot modify header information - headers already sent by (output started at

    一般来说在header函数前不能输出html内容,类似的还有setcookie() 和 session 函数,这些函数需要在输出流中增加消息头部信息.如果在header()执行之前有echo等语句,当 ...

  5. PHP:Cannot modify header information - headers already sent by错误的解决方案

    <?php ob_start();setcookie("username","test",time()+3600);echo "the user ...

  6. Warning: Cannot modify header information - headers already sent by ... functions_general.php on line 45

    摘自:有用到 http://blog.csdn.net/besily/article/details/5396268 PHP错误:Warning: Cannot modify header infor ...

  7. php5.6,Ajax报错,Warning: Cannot modify header information - headers already sent in Unknown on line 0

    php5.6ajax报错 Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be remo ...

  8. (转)PHP5使用cookie时报错 cannot modify header information - headers already sent by (......)

    转自:http://blog.csdn.net/buyingfei8888/article/details/8899797 运行有警告Warning: Cannot modify header inf ...

  9. 转载: PHP错误:Warning: Cannot modify header information - headers already sent by ...

    如果在执行php程序时看到这条警告:"Warning: Cannot modify header information - headers already sent by ....&quo ...

随机推荐

  1. oracle 直接连接到数据库 CMD窗口

    打开cmd 在命令行 中输入如下命令  sqlplus sys/zd****!@60.**.203/orcl as sysdba  就直接连上了

  2. 解决“程序包管理器控制台”输入命令找不到Nuget包问题

    问题: 问题原因: Nuget源的地址上不去 解决办法: 1.将Nuget源更新为可以国内使用的官方Nuget源. 1)打开VS2013:工具-->Nuget程序包管理器-->程序包管理器 ...

  3. 纯css实现div三列等高布局的最简单方法简化版/也可以多列

    使用正padding和负margin对冲实现多列布局方法 这种方法很简单,就是在所有列中使用正的上.下padding和负的上.下margin,并在所有列外面加上一个容器,并设置overflow:hid ...

  4. jmeter中登录和提交收银出现的错误

    登录出现的错误 登录界面如图所示: 为了防止登录跳转的问题response code 302的问题,要设置 2.提交收银界面 当系统设置必须传送jison格式时,要在HTTP Header Manag ...

  5. .NET 通过 NPOI 操作 Excel

    目录 .NET 通过 NPOI 操作 Excel 第一步:通过 NuGet 获取 NPOI 包并引入程序集 第二步:引入 NPOI 帮助类 第三步:在程序中调用相应的方法对数据进行导出导入操作 将 D ...

  6. 洛谷 P2935 [USACO09JAN]最好的地方Best Spot

    题目描述 Bessie, always wishing to optimize her life, has realized that she really enjoys visiting F (1 ...

  7. Java面试题全集(下)

    这部分主要是开源Java EE框架方面的内容,包括hibernate.MyBatis.spring.Spring MVC等,由于Struts 2已经是明日黄花,在这里就不讨论Struts 2的面试题, ...

  8. 机器学习之 PCA

    PCA(Principal Component Analysis)是一种常用的数据分析方法.PCA通过线性变换将原始数据变换为一组各维度线性无关的表示,可用于提取数据的主要特征分量,常用于高维数据的降 ...

  9. (八)VMware harbor 成员管理

    (一)VMware harbor 成员管理 可以给项目添加成员,成员必须是已经注册的成员. 添加成员后,成员就会有4种角色:项目管理员,维护人员,开发人员,访客. 1.1 新建成员 1.2 修改角色 ...

  10. vector的基本用法

    #include<iostream> #include<vector> #include<algorithm> using namespace std; int m ...