> Yasuo,
>
> the function you call is
>
> > $msg = user_regist();
>
> while in regist_util.inc, the function defined is
>
> > function regist_user() {
>
> Could that be the problem? Do you see any errors about undefined
> functions?

Thanks for your reply.
Code sample only for to show what is does...

In real code, there is no undefiend functions. (I always write code with
maximun error reporting level with any language. PHP error reporting is set
to E_ALL)

I changed code as follows, but no luck. Logic is not changed at all. I put
code in regist_user() function to index.php and get rid of the lines
"function() {" and corresponding "}". (PHP stops executing script TWICE
though)
-----------index.php---------------
if ($HTTP_POST_VARS['submit_btn']) {
  <= ** if I put die('died here') before include, PHP outputs 'died here' as
expected; **
  include('HTML_FILE_I_WANT_TO_DISPLAY_IF_USER_HIT_SUBMIT_BUTTON'); <= This
isn't displayed at all.
  <=**  if I put die('died here') after include, PHP DOES NOT outputs 'died
here' as expected; **
  exit;
}
else {
  include('HTML_FILE_I_WANT_TO_DISPLAY_BY_DEFAULT'); <= this is displyed
  exit;
}
-------------- end --------------
PHP displays default page, but not the page when user hit submit button.
PHP sends  following HTML instead of HTML file that I want to display which
is the same HTML when I didn't put any output  in PHP file. No matter what I
do in HTML or AFTER include statement.
PHP (before include(), PHP works as usual) send following HTML to browser.

--------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=euc-jp"></HEAD>
<BODY></BODY></HTML>
--------------

Strange behavior is code is executed BEFORE the include statement for sure.
(Because die('died here') displyed) PHP does not display HTML file that I
want to and outputs after include(). (File is there for sure and the file is
normal file, not a symlink or like)  (include,require,or like does not make
any difference)

I'm suspecting recent PHP4 source code has 8bit unclean code somewhere. I
use EUC-JP charset and it supposed to work if source code is 8bit clean. (I
haven't checked with older PHP yet nor build PHP with debug.)

Anyway,  looks like I have to simplify my code to see in what condition
include/require stops working as expected.

PS: Do not try with code as follows - it works as expected.
<?php
if (isset($HTTP_POST_VARS['sub_btn'])) {
 include('test2.php');
 exit;
}
else {
 include('test3.php');
 exit;
}
?>


>
> Cheers,
> Ben
>
> Yasuo Ohgaki wrote:
> >
> > This is really strange. PHP fails to exit / die form script after
include /
> > require / include_once / required_once (I tested with all of them, same
> > result).
> > In addition to this, script gets started again automatically from the
> > beginning.
> > (You probably think this is a another newbie mistakes, but I think it is
> > not)
> >
> > Does anyone have the same experience?
> > I'm asking to decide if this is worth to report as a bug. If anyone does
not
> > have this problem but me. I'll just leave it alone. (I cannot reproduce
this
> > with simple script anyway)
> >
> > I cannot reproduce this behavior with simple script, but it does every
time
> > on my script.
> >
> > PHP 4.0.4pl1 with PostgreSQL, mhash, mcript, gd, and others
> > Apache 1.3.17 (mod_php, mod_gzip, mod_ssl and others)
> > RedHat Linux7.0.1/ja
> > (Apache and PHP are build from source)
> >
> > My code does as follows
> >
> > In user registration form (regist.php)
> >  - require_once() to include registration function
> >  - call registration function
> >  - if the function does not exit, display HTML in this registration
file.
> > regist.php looks like
> > ------------
> > <?php
> > require_once('regist_util.inc');
> >
> > $msg = user_regist(); // defined in regist_util.inc
> >
> > ?>
> > <html>
> > <form method=post action=regist.php>
> > <?php @print($msg); // print errors for users'  inputs if there is ?>
> > ........................
> > <input type="text" name="username"></input>
> > <input type="text" name="email"></input>
> > ........................
> > </html>
> > -------------
> >
> > regist_util.inc does <= THIS FILE HAS PROBLEM
> >  - check if there is the same user name is registered
> >  - if there is, return 'Choose other name' error (or other error)
> >  - if not, insert user data into database and send notify email, include
> > other html file
> >        to show user registered successfully. Then exit script.
> > regist_util.inc looks like
> > --------------
> > <?php
> > function regist_user() {
> >   global $HTTP_POST_VARS;
> >   $error = array();
> >   // check inputs add errors, add error like $error[] = 'Error1';
$error[] =
> > 'Error2';
> >   // check database
> >   $db = pg_pconnect();
> >   $qid = pg_exec("select * from user where username = '".
> > $HTTP_POST_VARS['username'] ."'");
> >   if (pg_numrow($qid) > 0) {
> >     $error[] = 'Choose other name';
> >   }
> >   if (count($error) == 0) {
> >     // INSERT DATA - data is inserted if username is new
> >     .........................
> >     // SEND EMAIL - mail is sent if username is new
> >    .......................
> >     <= **** if I put die() or exit() BEFORE include PHP exits from
script as
> > expected. ****
> >     // include HTML file (with just a little PHP code)
> >     include('registered.php'); <= **** THIS IS NOT DISPLAYED AT ALL
******
> >     // If I remove include(), it exits from script.
> >     exit;  <= ************* DOES NOT EXIT or DIE HERE *************
> >
> > // Script seems start from the beginning. It shows 'Choose other name'
error
> > and
> > // there is the data newly creating in database, even if the user table
is
> > empty.
> > // Because data with the username was inserted at 1 first time script
> > iteration.
> > // For the second time, script finds the username (of course) and return
> > 'Choose
> > // other name' error.
> >
> > // Since I did get ANY additional HTML, but HTML codes in regist.php
when
> > // this happened, I thought it might  something to do with
'ob_gzhandler'. I
> > // disabled it. But no difference. This makes difficult to find out what
PHP
> > is
> > // doing, now I'm sure PHP is executing the scripts TWICE.
> > // Reason:
> > //   1) There will be a new db table row every time I use new username.
> > //   2) I get notification email every time I use new username.
> > // (I thought PHP never buffer outputs unless user explicitly to do so)
> >
> > // If I redirect, it works as expected.... I would rather not to show
> > registered.php, since
> > // user does not have to access this page directly. (I can work around
this
> > with different
> > // way, so I will do so)
> >
> > // By the way, I use EUC-JP code, which is multi-byte char code set, in
> > scripts
> > // and HTML part, etc. EUC-JP supposed to work well for many programs
> > written
> > // for single byte char code set. However, it might something to do with
> > char code.
> > // I'm using. So far, I didn't have problems. May be this is the first
time.
> > (I haven't
> > // investigated yet)
> >   }
> > }
> > ---------------
> >
> > registered.php looks like
> > --------------
> > <html>
> > <body>
> > You have been registered to this web site<br>
> > username = <?php @print($HTTP_POST_VARS['username']; ?><br>
> > ..........................
> > </body>
> > </html>
> > ---------------
> >
> > --
> > Yasuo Ohgaki
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to