PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 300,389 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,561 people online right now. Registration is fast and FREE... Join Now!




Log In Script Error :(

 

Log In Script Error :(, Dumb thing!

LadyYepperz

29 Jun, 2009 - 03:24 PM
Post #1

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 27

Hello All!! smile.gif
This is my log in script. Im getting an error I can not get rid of. Please help me figure out why. Thank you


Warning: Cannot modify header information - headers already sent by (output started at /home/ieroticx/header.inc.php:10) in /home/ieroticx/menu_st.inc.php on line 86
/storyindex.php

header.inc.php
CODE
<?php
session_start();
?>


menu_st.inc.php
CODE
<?php
//if cookie IS set
if (isset($_COOKIE['visitor'])){
  $loggedin = $_COOKIE['visitor'];
  $_SESSION['user'] = $loggedin;
  include("loggedin.inc.php");
}
else{
$host="localhost";
$username="";
$password="";
$db="";
$tbl="";

//======================
$con=mysql_connect("$host", "$username", "$password")or die("cannot connect server" . mysql_error());
mysql_select_db("$db", $con)or die("cannot select $db" . mysql_error());

//======================
include("functions.inc.php");
$scname=char_check(trim($_POST['scname']));
$pass=char_check(trim($_POST['pass']));

$loginError = "Login Erorr!";
$register = "<a href='../acctindex.php'><span>Register</span></a>";

  if (!isset($_POST['submit'])){  //form has not been submitted
    echo "<h1><span>Login</span></h1>
    <form name='login' method='post' action='". $_SERVER['PHP_SELF'] ."'>
    <input type='text' name='scname' value='". htmlentities($scname,ENT_QUOTES)."' maxlength='25'  minimum='8' />
    <input type='password' name='pass' value='". htmlentities($pass,ENT_QUOTES) ."' maxlength='25'  minimum='8' />
    <input type='submit' value='Login' class='button' name='submit' />
    </form><br />
    $register";
  }
  else{  //if screen name or password was not entered into the form
    if (strlen($scname)<=0 || strlen($pass)<=0){
      echo "<h1><span>Login</span></h1>
      <form name='login' method='post' action='". $_SERVER['PHP_SELF'] ."'>
      <input type='text' name='scname' value='". htmlentities($scname,ENT_QUOTES)."' maxlength='25'  minimum='8' />
      <input type='password' name='pass' value='". htmlentities($pass,ENT_QUOTES) ."' maxlength='25'  minimum='8' />
      <input type='submit' value='Login' class='button' name='submit' />
      </form><br />
      $register";
    }
    else{ //connect to db
      mysql_select_db("$db", $con)or die("cannot select $db" . mysql_error());
      $sql=mysql_query("Select password FROM $tbl WHERE scname='$scname'");


        if (mysql_num_rows($sql)==0){  //if screen name doesnt exist
          echo "<h1><span>Login</span></h1>
         <form name='login' method='post' action='". $_SERVER['PHP_SELF'] ."'>
          <input type='text' name='scname' value='". htmlentities($scname,ENT_QUOTES)."' maxlength='25'  minimum='8' />
          <input type='password' name='pass' value='". htmlentities($pass,ENT_QUOTES) ."' maxlength='25'  minimum='8' />
          <input type='submit' value='Login' class='button' name='submit' />
          </form><br />
          $register";
        }
        else{ // Incorrect password
          while($login=mysql_fetch_array($sql)){
            if (!$pass == $login['password']){
              echo "<h1><span>Login</span></h1>
              <form name='login' method='post' action='". $_SERVER['PHP_SELF'] ."'>
              <input type='text' name='scname' value='". htmlentities($scname,ENT_QUOTES)."' maxlength='25'  minimum='8' />
              <input type='password' name='pass' value='". htmlentities($pass,ENT_QUOTES) ."' maxlength='25'  minimum='8' />
              <input type='submit' value='Login' class='button' name='submit' />
              </form><br />
              $register";
            }
            else{ //create cookie
              $expires = mktime()+(86400*30);
              $domain = "www.iEroticX.com";
              $login = $scname;
/*line 86 */  setcookie("visitor", $login, $expires, "/", $domain);
              echo $_SERVER['PHP_SELF'];
            }
          }
        }
    }
  }
}
?>


story index.php
I dont know why this page has been included in this error except maybe both the header and menu pages are includes on this page. But there is no code that effects either of the others.

This post has been edited by LadyYepperz: 29 Jun, 2009 - 03:26 PM

User is offlineProfile CardPM
+Quote Post


CTphpnwb

RE: Log In Script Error :(

29 Jun, 2009 - 04:14 PM
Post #2

D.I.C Lover
Group Icon

Joined: 8 Aug, 2008
Posts: 2,065



Thanked: 151 times
Dream Kudos: 100
Expert In: PHP

My Contributions
I can't see the problem, but then I can't see what's in logged.inc.php or in functions.inc.php.

User is offlineProfile CardPM
+Quote Post

LadyYepperz

RE: Log In Script Error :(

29 Jun, 2009 - 07:28 PM
Post #3

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 27

Easily resolved.

loggedin.inc.php
CODE
<?php
print "
<h1><span>Logged In As</span></h1>";
    echo $loggedin;
?>


functions.inc.php
(because my scripts get long i put all my functions in one separate include file)
CODE
<?php
// ++++++++++ allowed upload extentions ++++++++++
function isAllowedExtension($fileName) {
  $allowedExtensions = array("bmp", "gif", "jpg", "jpeg", "pjpeg", "png");
  return in_array(end(explode(".", $fileName)), $allowedExtensions);
}

// ++++++ deletes the users old pic from the directory folder ++++++
function deletePic($var){
  if($var !== "bright.jpg"){
      if($dir=opendir(getcwd())){
        while(($files = readdir($dir)) !== false){
            if($files == $var){
                unlink($var);
            }
        }
      }
     closedir($dir);
  }
}

// ++++ remove illegal characters from s/n & p/w ++++
function char_check($var){
$illegal = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "{", "}", "[", "]", ";", ":", "\'", "\'", ",", "<", ">", "?", "/", "\\", " ");
$var=str_replace($illegal, "", "$var");
return $var;
}

// +++++  encodes special characters ++++
function replace_chars($var){
$illegal=array( "'", ",",  "\"", "<", ">", "/", "~", ",", "|", "!", "$", "%", "(", ")", "*", "+", "-", "/", "=", "?", "@", "[", "\\", "]", "^", "_", "`", "{", "|", "}", ":", "…", "“", "”", "•", "™", "€", "‚", "ƒ", "„", "†", "‡", "ˆ", "‰", "Š", "‹", "Œ", "Ž", "‘", "‘", "–", "—", "˜", "š", "›", "œ", "ž", "Ÿ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
$replace=array("'", ",", """, "<", ">",  "⁄", "˜","‚", "¦", "!", "$", "%", "(", ")", "*", "+","-", "/", "=", "?", "@", "[", "\", "]", "^", "_", "`", "{", "|", "}", ":", "…", "“", "”", "•", "™", "€", "‚", "ƒ", "„", "†", "‡", "ˆ", "‰", "Š", "‹", "Œ", "Ž", "‘", "’", "–", "—", "˜", "š", "›", "œ", "ž", "Ÿ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
$var=str_replace($illegal, $replace, "$var");
return $var;
}

// +++++++++++check cdate++++++++++++++
function copy_check($var){
    if(!is_numeric($var) || strlen($var)>4 || strlen($var)<4 || $var>2009){
    $var=str_replace($var, "2009", "$var");
    return $var;
    }
    else{
    return $var;
    }
}

// +++++++++ date & time ++++++++++
$postDate=date("m-d-y");
$comDate=date("D. m/d/y h:i a");

// +++++ Random Generator Letters & Numbers +++++
function assign_random_value($num)
{
// accepts 1 - 36
  switch($num)
  {
    case "1":
     $rand_value = "A";
    break;
    case "2":
     $rand_value = "B";
    break;
    case "3":
     $rand_value = "C";
    break;
    case "4":
     $rand_value = "D";
    break;
    case "5":
     $rand_value = "E";
    break;
    case "6":
     $rand_value = "F";
    break;
    case "7":
     $rand_value = "G";
    break;
    case "8":
     $rand_value = "H";
    break;
    case "9":
     $rand_value = "I";
    break;
    case "10":
     $rand_value = "J";
    break;
    case "11":
     $rand_value = "K";
    break;
    case "12":
     $rand_value = "L";
    break;
    case "13":
     $rand_value = "M";
    break;
    case "14":
     $rand_value = "N";
    break;
    case "15":
     $rand_value = "O";
    break;
    case "16":
     $rand_value = "P";
    break;
    case "17":
     $rand_value = "Q";
    break;
    case "18":
     $rand_value = "R";
    break;
    case "19":
     $rand_value = "S";
    break;
    case "20":
     $rand_value = "T";
    break;
    case "21":
     $rand_value = "U";
    break;
    case "22":
     $rand_value = "V";
    break;
    case "23":
     $rand_value = "W";
    break;
    case "24":
     $rand_value = "X";
    break;
    case "25":
     $rand_value = "Y";
    break;
    case "26":
     $rand_value = "Z";
    break;
    case "27":
     $rand_value = "0";
    break;
    case "28":
     $rand_value = "1";
    break;
    case "29":
     $rand_value = "2";
    break;
    case "30":
     $rand_value = "3";
    break;
    case "31":
     $rand_value = "4";
    break;
    case "32":
     $rand_value = "5";
    break;
    case "33":
     $rand_value = "6";
    break;
    case "34":
     $rand_value = "7";
    break;
    case "35":
     $rand_value = "8";
    break;
    case "36":
     $rand_value = "9";
    break;
  }
return $rand_value;
}

function get_rand_id($length)
{
  if($length>0)
  {
  $rand_id="";
   for($i=1; $i<=$length; $i++)
   {
   mt_srand((double)microtime() * 1000000);
   $num = mt_rand(1,36);
   $rand_id .= assign_random_value($num);
   }
  }
return $rand_id;
}

// ++++++++++ hitcounter ++++++++++
function hitcounter($num){
    $var=$num+1;
    return $var;
}

// +++++++ Limit Comment Size +++++++
function limitComm($var){
    if(strlen($var)>400){
    $var=substr_replace($var, "", 400);
    }
    return $var;
}

// +++++ Random Number Generator +++++
function assign_random_number($num)
{
// accepts 1 - 36
  switch($num)
  {
    case "1":
     $rand_value = "1";
    break;
    case "2":
     $rand_value = "2";
    break;
    case "3":
     $rand_value = "3";
    break;
    case "4":
     $rand_value = "4";
    break;
    case "5":
     $rand_value = "5";
    break;
    case "6":
     $rand_value = "6";
    break;
    case "7":
     $rand_value = "7";
    break;
    case "8":
     $rand_value = "8";
    break;
    case "9":
     $rand_value = "9";
    break;
    case "10":
     $rand_value = "0";
    break;
  }
return $rand_value;
}

function get_rand_num($length)
{
  if($length>0)
  {
  $rand_num="";
   for($i=1; $i<=$length; $i++)
   {
   mt_srand((double)microtime() * 1000000);
   $num = mt_rand(1,10);
   $rand_num .= assign_random_number($num);
   }
  }
return $rand_num;
}

// +++++ email check +++++
function spamcheck($field){//filter_var() sanitizes the e-mail
   $field=filter_var($field, FILTER_SANITIZE_EMAIL);

//filter_var() validates the e-mail
if(filter_var($field, FILTER_VALIDATE_EMAIL)){
    return TRUE;
  }
  else{
    return FALSE;
  }
}
?>


This post has been edited by LadyYepperz: 29 Jun, 2009 - 07:33 PM
User is offlineProfile CardPM
+Quote Post

no2pencil

RE: Log In Script Error :(

29 Jun, 2009 - 07:36 PM
Post #4

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,225



Thanked: 289 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
QUOTE(LadyYepperz @ 29 Jun, 2009 - 05:24 PM) *

Warning: Cannot modify header information - headers already sent by (output started at /home/ieroticx/header.inc.php:10) in /home/ieroticx/menu_st.inc.php on line 86
/storyindex.php

When you send headers, it absolutely must be the 1st output. Any echo, print, or other output will create the html headers, & then the header command will fail because the headers have already been sent (thus, the error already sent).

Glad to see that you got this fixed!
User is online!Profile CardPM
+Quote Post

LadyYepperz

RE: Log In Script Error :(

29 Jun, 2009 - 07:48 PM
Post #5

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 27

no not fixed.. only thing resolved was CT's request for me to post those other includes. sorry.


So instead of using
CODE
echo $_SERVER['PHP_SELF'];

i should use
CODE
<?php
header( 'Location: http://www.iEroticX.com/storyindex.php' );
?>

to reload the whole page?

This post has been edited by LadyYepperz: 29 Jun, 2009 - 07:53 PM
User is offlineProfile CardPM
+Quote Post

LadyYepperz

RE: Log In Script Error :(

29 Jun, 2009 - 08:09 PM
Post #6

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 27

storyindex.php
CODE
<?php
    include_once("/home/ieroticx/header.inc.php");

$host="localhost";
$username="";
$password="";
$db="";

$con = mysql_connect("$host", "$username", "$password")or die("cannot connect server" . mysql_error());
mysql_select_db("$db")or die("cannot select $db" . mysql_error());

      print"<h1><span>Top Rated Stories</span></h1>
<ul>";

$tbl2="storycoms";
      $sql=mysql_query("SELECT *, AVG(stars) from $tbl2 GROUP BY unum HAVING AVG(stars)>= 4");

      //top rated story
      while($each=mysql_fetch_array($sql)){
    $check=$each[author];
    $checktbl="accounts";

            $checksql=mysql_query("SELECT * FROM $checktbl WHERE scname='$check'");
            while($chk=mysql_fetch_array($checksql)){
              if($chk[status]== 1){
                print "<li>$each[title] by <a href='/elite/s_elite.php?423413=$each[author]' title='$each[author]'><span class='fatt'>$each[author]</span></a></li>";
              }
              else{
                print "<li><a href=/story/comments.php?1767726108=$each[unum] title='$each[title]</a> by<span class='fatt'> $each[author]</span></li>";
              }
            }
      }

print "</ul>



<h1><span>Whats New From <acronym title='www.iEroticXpressions.com'>IEX's</acronym> Elite</span></h1>";


$tbl8="elite";
  $sql8=mysql_query("SELECT * FROM $tbl8 WHERE type='story' LIMIT 5")or die("cannot select $tbl3" . mysql_error());


print "<ul>";  //new elite story additions
  while($row2=mysql_fetch_array($sql8)){
    print "<li>$row2[title] by <a href='/elite/s_elite.php?423413=$row2[author]' title='$row2[author]'><span class='fatt'>$row2[author]</span></a></li>";
    }

    print "</ul>

<h1><span>Newest Stories by Members</span></h1>";


$tbl3="stories";
  $sql4=mysql_query("SELECT * FROM $tbl3 LIMIT 5")or die("cannot select $tbl3" . mysql_error());


print "<ul>";   //new member story additions
  while($row=mysql_fetch_array($sql4)){
    print "<li><a href='/story/comments.php?1767726108=$row[unum]' title='$row[title]'>$row[title]</a> by <span class='fatt'>$row[author]</span></li>";
    }
    mysql_close($con);
    print "</ul>

<h1><span>A Few Simple Guidelines</span></h1>
  <ul>
      <li>Constructive critism is more than welcomed on <acronym title='www.iEroticXpressions.com'>IEX</acronym>. In fact, say anything you like about any story or poem posted on <acronym title='www.iEroticXpressions.com'>IEX</acronym>.  Your honesty is welcomed by one and all.
      <li><b>BUT</b> personal attacks on the writers are <b>NOT</b> and will <b>NOT</b> be tolerated.  A personal attack <b>WILL</b> result in you being banned immediately.
  </ul>";


print "</div>";

        include_once("/home/ieroticx/menu_st.inc.php");
        include_once("/home/ieroticx/footer.inc.php");
?>

User is offlineProfile CardPM
+Quote Post

no2pencil

RE: Log In Script Error :(

29 Jun, 2009 - 11:16 PM
Post #7

i R L33t Skiddie, k?
Group Icon

Joined: 10 May, 2007
Posts: 13,225



Thanked: 289 times
Dream Kudos: 2875
Expert In: Goofing Off

My Contributions
What comes before this:
QUOTE(LadyYepperz @ 29 Jun, 2009 - 09:48 PM) *

CODE
<?php
header( 'Location: http://www.iEroticX.com/storyindex.php' );
?>

to reload the whole page?


User is online!Profile CardPM
+Quote Post

LadyYepperz

RE: Log In Script Error :(

30 Jun, 2009 - 10:05 AM
Post #8

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 27

its not in my scripts... i was asking a question.

im going to try it out later tonight and let you guys know how if it works
User is offlineProfile CardPM
+Quote Post

LadyYepperz

RE: Log In Script Error :(

3 Jul, 2009 - 11:25 AM
Post #9

New D.I.C Head
*

Joined: 15 Jun, 2009
Posts: 27

Sorry to all those who were helping me for being away so long. I sprained my wrist really bad and had to take a break. Im back to work now. And will be working on this script again.

Thanx everyone.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 09:39PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month