Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

css / php error

Options
  • 28-03-2009 4:12pm
    #1
    Registered Users Posts: 757 ✭✭✭


    I have the following code on my page. When it is just the php it works perfectly. However when I add the html to apply the css it gives me this error:
    Warning: Cannot modify header information - headers already sent by (output started at /home/jer/domains/jerlane.com/public_html/Live/changePassword.php:12) in /home/jer/domains/jerlane.com/public_html/Live/changePassword.php on line 55
    

    THe code of the page is this:
    <!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=utf-8" />
    <link rel="stylesheet" type="text/css" href="styles/stylesheet.css" />
    <title>Carbon Metic Calculator - Insufficent Access</title>
    </head>
    
    <body>
    
    <div class="wrapper">
    <p align="center"> <img align="middle" src="images/HeaderOnly.jpg" /></p>
    </div>
    
    <?php
    if(!isset($_COOKIE["user"]))
    header('location:insufficientAcc.php');
    $con=mysql_connect("localhost","jer_test","group11");
    if(!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    $db_selected = mysql_select_db('jer_test', $con);
    if (!$db_selected){
    die ('Can\'t use jer_test : ' . mysql_error());
    }
    $mypassword=$_POST['mypassword']; 
    $newpassword=$_POST['newpassword']; 
    $newpasswordc=$_POST['newpasswordc'];
    $mypassword=stripslashes($mypassword);
    $newpassword=stripslashes($newpassword);
    $newpasswordc=stripslashes($newpasswordc);
    $mypassword=mysql_real_escape_string($mypassword);
    $newpassword=mysql_real_escape_string($newpassword);
    $newpasswordc=mysql_real_escape_string($newpasswordc);
    $user=$_COOKIE["user"];
    $result=mysql_query("SELECT password FROM members WHERE username='$user'",$con);
    $row=mysql_fetch_array($result);
    $existingP=$row["password"];
    $priv=$row["privilage"];
    if($newpassword!=""){
    if($mypassword!=$newpassword){
    if($existingP==$mypassword){
    if($newpassword==$newpasswordc){
    mysql_query("UPDATE members SET password = '$newpassword' WHERE username = '$user'");
    header('location:passChangeConfirm.php');
    }
    
    else{
    echo "One of the entries of the new password was incorrect. Please click <a href=\"http://www.jerlane.com/Live/empChangePass.php\"> here</a> to try again";
    }
    }
    else{
    
    header('location:insufficientAcc.php');
    }
    }
    else{
    echo "Your old and new passwords are the same. Make them different. Please click <a href=\"http://www.jerlane.com/Live/empChangePass.php\"> here</a> to try again";
    }
    
    }
    else{
    echo "You must have a password! Please click <a href=\"http://www.jerlane.com/Live/empChangePass.php\"> here</a> to try again";
    }
    ?>
    
    </body>
    </html>
    
    

    Please help, this has me baffled for about an hour now...


Comments

  • Closed Accounts Posts: 1,200 ✭✭✭louie


    this should above all the code:
    [php]
    <?php
    if(!isset($_COOKIE["user"]))
    header('location:insufficientAcc.php');
    :::::::::::::::::::::::::::::::::::::::::
    [/php]

    or add
    [php]
    ob_start();
    [/php]
    at the top of the page so no content is written to the browser before any checks are made...


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    I don't know PHP, but my guess is that you can't do this stuff:
    [php]header('location:passChangeConfirm.php');[/php]
    once you have written HTML to the page.

    I am not a fan of having big blocks of ASP or PHP in the middle of a document. I would move as much of it as possible to the top of the page so you can separate your HTML and PHP better.


  • Registered Users Posts: 757 ✭✭✭Signpost


    how can i split the code that only the echo's would be surrounded by the <div>??


  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Instead of doing an echo, write to a variable instead.


  • Registered Users Posts: 757 ✭✭✭Signpost


    good thinking! i likes it!


  • Advertisement
Advertisement