我采用的是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. IE和火狐下的iframe刷新

    前面使用了前端上传插件plupload,在谷歌浏览器中运行完全没问题,但是在IE和火狐下就出现当文档加载完成之后,该文件上传的iframe插件的上传按钮点击无效,当对上传的文件进行一次删除之后,按钮就 ...

  2. openssl 安装配置

    Openssl是个为网络通信提供安全及数据完整性的一种安全协议,囊括了主要的密码算法.常用的密钥和证书封装管理功能以及SSL协议,并提供了丰富的应用程序供测试或其它目的使用.首先下载Openssl包: ...

  3. 基于Myeclipse的三大框架(SSH)整合

    文中主要基于Myeclipse进行配置,配置流程为:Hibernate --> Spring --> 整合 --> struts2 -->整合.注意:在此文中,主要讲述基于注解 ...

  4. Azure资源管理工具Azure PowerShell介绍

    什么是 Azure PowerShell? Azure PowerShell 是一组模块,提供用于通过 Windows PowerShell 管理 Azure 的 cmdlet.你可以使用 cmdle ...

  5. Python 目录和文件基本操作

    今天在写一个小工具的过程中发现对目录和文件的基本操作不是很熟,特此把遇到的常用操作总结汇总下. 获取当前路径:os.getcwd() 目录操作:1.创建目录:os.mkdir('目录名')2.创建多级 ...

  6. 【Linux】Ubuntu18.04镜像下载,新功能介绍

    一.Ubuntu18.04镜像下载 官方下载地址:http://releases.ubuntu.com/18.04/ 官方64位iso下载地址:http://releases.ubuntu.com/1 ...

  7. 2010: C语言实验——逆置正整数

    2010: C语言实验——逆置正整数 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 949  Solved: 691[Submit][Status][We ...

  8. vue 获取汉字的全拼、简拼、首拼

    1.封装公共方法,获取汉字的全拼.简拼.首拼 export const Pinyin = { _JMcode:{ "-":"", "—":& ...

  9. 一、新手必会Python基础

    博客内容: 1.基础语法 2.运算符 3.流程控制 4.列表.元组.字典.集合 5.字符串 6.文件操作 一.基础语法 1.标识符 命名规则: 以字母.下划线开头 其他部分由字母.数字或下划线组成 不 ...

  10. Hibernate查询语句HQL8大特点

    Hibernate拥有一种功能非常强大的查询语言,这种语言被有意得与SQL非常相似,便于开发人员掌握.但不要被HQL的语法表面所迷惑,HQL完全是面向对象的,可以用来过程多态.继承.关联等关系. 1. ...