Jump to content

php header


harkly

Recommended Posts

I am trying to get my page to redirect to another with a header. I am getting the "headers already sent by " error. I've checked for white space and researched but can't seem to find anything the pertains to my code.

 

I am thinking that I am getting the error becuase I am posting to 'self'??

 

If someone could help me with my code or even send me to a good site that deals with this.

 

<?php

        if( isset($_POST['submitLogin']))
          {
            include('login.php');
            login();
            mysql_select_db('test');

            $userID=$_POST["userID"];
            $pswd=$_POST["pswd"];

            $sql="SELECT * FROM user WHERE userID='$userID' and pswd='$pswd'";
            $result=mysql_query($sql);

            $count=mysql_num_rows($result);

            while ($r=mysql_fetch_array($result))
              {
                $exp_date=$r["exp_date"];
                $todays_date=date("Y-m-d");
              }

              if($count==1)
                {
                  if ($exp_date >= $todays_date)
                    {
                      header('Location: aboutMe.php');
                    }
                  else
                    {
                      echo "Billing is bad";
                    }
                }
              else
                {
                echo " <div id='incorrect'>Please verify the username or password.</div>

                <form method='post' action='' name='login' id='login'>
                  <div id='loginForm'>
                    <fieldset>
                      <span class='textbox'>
                        <label for='username'>Username: </label> <input type='text' name='userID' size='25' class='cells' value='$userID'>
                        <br><label for='pswd'>Password: </label> <input type='password' name='pswd' size='25'class='cells' value='$pswd'>
                        <br><label for='pswd'> </label>Remember Me:  <input type='checkbox' name='Remember' value='21'>
                        <br><label for='blank'> </label><a href='changePswd.php'>Forget Your Password?</a>
                        <br><label for='blank'> </label><input type='image' value='Login'  src='img/button_login.gif' width='64' height='25'
                            onmouseover=\"javascript:this.src='img/button_login2.gif';\" onmouseout=\"javascript:this.src='img/button_login.gif';\">

                        <input type='hidden' name='submitLogin' value='true'>

                      </span>
                    </fieldset>
                  </div>
                </form>
                ";
              }
}
        else
          {
            echo "
            <form method='post' action='' name='login' id='login'>
              <div id='loginForm'>
                <fieldset>
                  <span class='textbox'>
                    <label for='username'>Username: </label> <input type='text' name='userID' size='25' class='cells'>
                    <br><label for='pswd'>Password: </label> <input type='password' name='pswd' size='25'class='cells'>
                    <br><label for='pswd'> </label>Remember Me:  <input type='checkbox' name='Remember' value='21'>
                    <br><label for='blank'> </label><a href='changePswd.php'>Forget Your Password?</a>
                    <br><label for='blank'> </label><input type='image' value='Login' src='img/button_login.gif' width='64' height='25'
                    onmouseover=\"javascript:this.src='img/button_login2.gif';\" onmouseout=\"javascript:this.src='img/button_login.gif';\">

                    <input type='hidden' name='submitLogin' value='true'>

                  </span>
                </fieldset>
              </div>
            </form>
            ";
          }
?>

Link to comment
https://forums.phpfreaks.com/topic/193252-php-header/
Share on other sites

From my research the error has something to do with white space, so I removed it all and still getting the error.

 

Warning: Cannot modify header information - headers already sent by (output started at /home/content/i/d/2/id2294/html/singles/login.php:11) in /home/content/i/d/2/id2294/html/singles/login.php on line 49
Link to comment
https://forums.phpfreaks.com/topic/193252-php-header/#findComment-1017590
Share on other sites

I don't think that will work, I probably am missunderstanding. I am having the user log in, then the form is submitted to itself. It will either do 3 things based on if the user & pswd are valid and if the billing is up to date. Not sure how I can switch things around so that the redirect comes first.

Link to comment
https://forums.phpfreaks.com/topic/193252-php-header/#findComment-1017685
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.