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?

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