I have tried to figure this one out...trial and error. I have had to smoke the HD on my linux box about 5 times because of my trying different things.

I can't fix this problem no matter what I do.

I am compiling apache 1.3 whit PHP 4. PHP will work fine for displaying pages(except a problem with header errors that I don't have on a hosting server)

Anyway, it works, EXCEPT for cookies and forms.

I have disabled cookies in my code and am still unable to submit forms correctly. Whether it be using PHP SELF or to other pages.

I also know cookies are not being written and my app depends on it.

I only ask for help because I am going insane trying to figure out what I am:
a) not compiling correct
b) not adding to apache
c) not reading to fix my issue

Any help would be appreciated.

Thanks

    Well, it's definately compiling if it is displaying pages, and this will also mean that you've set up apache correctly if you can see anything. When you use the forms, how are you accessing the variables? Do you use $formName (where formName is the name of the input box in the form), or do you use $_POST[formName]?

      $formname

      I currently use bluedomino hosting and they have it setup where i can use just the variable and not use post function.

      I can't seem to duplicate this. I read that this may be something with URLENCODE and libapreq but I can't get anything to work for me.

      thanks for the help though

        You don't HAVE to use the $POST and $GET variables, but only when "register_globals" is switched to 'on' in your php.ini file. The default has been set to 'off', but most hosting companies switch it on, so you'll have to edit your .ini file if you want to be able to use just $varname instead of $_POST[varname].

        I usually use $_POST[varname] even when register_globals is on, as it helps me keep track of where I'm getting my variables from.

        If you're still having probs after this I'm not sure what to suggest, but I can tell you that the problem has nothing to do with your Apache or PHP compiling.

          thanks for the help.

          I will check the register_globals and see what happens.

            If bluedomino have set it up so that you can just use the variable name rather than $_POST[variablename] then register_globals should be on.

              Well I rebuilt everything once again, have tried with/without register globals on.

              It doesn't make a difference at the moment. evidentally it isn't getting past another error.

              Basically when i submit the form it spits back header errors
              I have checked to ensure there are no spaces before or after <? ?>

              Warning: Cannot modify header information - headers already sent by (output started at www/htdocs/requestcounter/login.php:13) in /www/htdocs/requestcounter/login.php on line 108

              Going to the line in the file brings me to my cookie code.
              I have cookies being set(unefficient code I am sure)
              If I remove the cookie code, the header errors go away, but it still does not seem as if the form is being submitted...

              if($exist > 0)	{
              setcookie("usid", "$uid");
              setcookie("admin", "$admin");
              setcookie("user", "$uname");
              setcookie("pass", "$pwd");
              setcookie("first", "$fn");
              setcookie("last", "$ln");
              setcookie("email", "$email");
              

                i just did a little debugging and found that it does submit the form.

                i removed the setcookie code and it finds the user in the database.

                I can't figure out why it isn't letting me set the cookies...
                any suggestions.

                thanks for the help thus far, i really appreciate it.

                  ./configure' '--with-imap=/usr/local/' '--enable-bcmath' 
                  '--enable-calendar' '--with-mysql=/var/lib/autoadmin/mysql/' 
                  '--with-ldap' '--enable-ctype' '--enable-sockets' '--enable-ftp' 
                  '--enable-inline-optimization' '--with-openssl=/usr/local/ssl/' 
                  '--with-gd=/usr/src/gd-1.8.4/' 
                  '--with-apache=/usr/src/apache/apache_1.3.26/' 
                  '--enable-dbase' '--with-db3' '--with-gdbm' '--enable-exif'
                   '--with-gettext' 
                  '--with-gd=/var/lib/misc/autoadmin/skeleton/usr/local/' 
                  '--with-jpeg-dir' '--with-png-dir' '--with-mhash' 
                  '--with-mcrypt' '--with-zlib' 
                  '--with-curl=/var/lib/misc/autoadmin/skeleton/usr/local/' 
                  '--with-ming=../ming-0.2a/php_ext/' '--with-pdflib' 
                  '--with-pspell' '--enable-wddx' '--with-xml' '--with-posix' 
                  '--with-pcre' '--with-dba' '--with-dbase' '--with-freetype-dir=/usr/lib/'

                  The above is the config from Bludeomino, mine of course doesn't have near as much enabled.
                  My question is, would any of the above missing affect cookies directly?

                    Any ideas on why I get header error when trying to set cookies...

                    I can't figure it out...

                      Can you post ALL the code before your "setcookie" lines? (don't forget to blank out any usernames / passwords)

                        <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0052AC" VLINK="#0052AC" ALINK="#0052AC">
                        <CENTER><TABLE WIDTH="700" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#FFFFFF">
                        <TR><TD>
                        
                        <TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BGCOLOR="#000000"><TR BGCOLOR="#000000"><TD BGCOLOR="#000000">
                          <TABLE WIDTH="100%" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#FFFFFF">
                          <TR BGCOLOR="#FFFFFF"><TD BGCOLOR="#FFFFFF">
                            <TABLE WIDTH="100%" CELLPADDING="4" CELLSPACING="1">
                            <TR>
                            <TD BGCOLOR="#F7F7F7">
                              <FONT FACE="Verdana, Arial, Tahoma" SIZE="2" COLOR="#000000">
                              <B>Web Turns</B><BR>
                              </FONT><FONT FACE="Verdana, Arial, Tahoma" SIZE="1" COLOR="#000000">
                        
                          </FONT>
                        </TD>
                        </TR>
                        <TR>
                        <TD BGCOLOR="#DDDDDD">
                          <FONT FACE="Verdana, Arial, Tahoma" SIZE="1" COLOR="#000000">
                        
                          </FONT>
                        </TD>
                        </TR>
                        </TABLE>
                          </TD></TR>
                          </TABLE>
                        </TD></TR>
                        </TABLE>
                        <BR>
                          </FONT>
                        <BR><BR>
                        
                        <TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BGCOLOR="#000000"><TR BGCOLOR="#000000"><TD BGCOLOR="#000000">
                          <TABLE WIDTH="100%" CELLPADDING="1" CELLSPACING="0" BGCOLOR="#FFFFFF">
                          <TR BGCOLOR="#FFFFFF"><TD BGCOLOR="#FFFFFF">
                            <TABLE WIDTH="100%" CELLPADDING="4" CELLSPACING="1">
                            <TR>
                            <TD BGCOLOR="#DDDDDD">
                              <FONT FACE="Verdana, Arial, Tahoma" SIZE="2" COLOR="#000000">
                              <B>Turn Login</B>
                              </FONT><BR>
                              <FONT FACE="Verdana, Arial, Tahoma" SIZE="1" COLOR="#000000">
                              Please enter your username and password.
                              </FONT>
                            </TD>
                            </TR>
                            <TR>
                            <TD BGCOLOR="#F7F7F7">
                              <FONT FACE="Verdana, Arial, Tahoma" SIZE="2" COLOR="#000000">
                        <FORM METHOD="POST" ACTION="<?=$PHP_SELF?>">
                        <TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0">
                        <TR><TD ALIGN="RIGHT">
                        <FONT FACE="Verdana, Arial, Tahoma" SIZE="2" COLOR="#000000">
                        <B>User Name:</B>
                        </FONT>
                        </TD><TD>
                        <INPUT TYPE="TEXT" NAME="username" SIZE="25">
                        </TD></TR>
                        <TR><TD ALIGN="RIGHT">
                        <FONT FACE="Verdana, Arial, Tahoma" SIZE="2" COLOR="#000000">
                        <B>Password:</B>
                        </FONT>
                        </TD><TD>
                        <INPUT TYPE="PASSWORD" NAME="password" SIZE="25">
                        </TD></TR>
                        <TR><TD ALIGN="RIGHT">
                        <FONT FACE="Verdana, Arial, Tahoma" SIZE="2" COLOR="#000000">
                        &nbsp;
                        </FONT>
                        </TD><TD>
                        <INPUT TYPE="SUBMIT" name=login VALUE="Login">
                        <INPUT TYPE="RESET" VALUE="Reset">
                        </TD></TR>
                        </FORM></TABLE>
                        <?
                        
                        
                        if ($login) {
                        require("config.php");
                        
                        
                        mysql_select_db($DB_NAME);
                        
                        $loginquery = mysql_query("SELECT * FROM user WHERE username = '".$username."' AND password = '".$password."'");
                        
                        
                        // was it correct?
                        $exist = mysql_num_rows($loginquery);
                        
                        while ($v = mysql_fetch_array($loginquery)) {
                        
                        $uname = $v[0];
                        $pwd = $v[1];
                        $uid = $v[2];
                        $admin = $v[3];
                        $fn = $v[4];
                        $ln = $v[5];
                        $email = $v[6];
                        
                        
                        if($exist > 0)	{
                        setcookie("usid", "$uid");
                        setcookie("admin", "$admin");
                        setcookie("user", "$uname");
                        setcookie("pass", "$pwd");
                        setcookie("first", "$fn");
                        setcookie("last", "$ln");
                        setcookie("email", "$email");
                        
                        echo "<META http-equiv=\"refresh\" content=\"1; URL=today.php\">";
                        }
                        
                        }
                        
                        }
                        
                        
                        
                        
                        
                        ?>

                        There is the login page code, which fails if I run it with the cookie code. If it is removed, it works without a problem.

                          There's your problem. Your 'setcookie' line has to be written before ANYTHING is printed to the page. You have your entire HTML document printing before it.

                          Move everything between your php tags to the very top of the page. So it should look something like this:

                          <?
                          
                          if ($login) {
                          require("config.php");
                          
                          mysql_select_db($DB_NAME);
                          
                          ....
                          ....
                          ....
                          
                          ?>
                          
                          <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0052AC" VLINK="#0052AC" ALINK="#0052AC">
                          <CENTER><TABLE WIDTH="700" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#FFFFFF">
                          
                          ....
                          ....
                          ....
                          
                          

                          Make sure there's nothing (not even a space) before the "<?" tag.

                            hmmmm. i will have to try that(box is at work)
                            odd that it works just the way it is on my webhost....

                            thanks for the help though I shall let you know how it turns out!!

                            thanks again!

                              well... that worked. i really appreciate the help from everyone!!

                              I am curious as to why it works fine on my hosting company with the code I had before?!

                                As far as I am aware, it SHOULDN'T have happened. Any messages sent to the browser, such as headers, cookies or session_start()-type things must be sent before any HTML.

                                Something to do with the HTTP protocol if my memory serves me correct...

                                  Write a Reply...