[PHP-users 431] Re: フォームのチェック

tyunn php-users@php.gr.jp
Sun, 1 Jul 2001 12:09:39 +0900


こんにちは。

◎質問させていただいた元のソース(漏れを訂正)
> > ■aaa.php3
> > <? if($regist){
> >         include('chk.inc');
>      if(!$message){
> >             // 正常に入力された場合の処理
> >         }
         }
> > ?>
> > <html>
> > <body>
> > <?
> >   if ($message==msg01){
> >       echo "**a1が入力漏れです**"";
> >   }
> > ?>
> > <form method=post action=aaa.php3>
> > <input type=text name=a1 value=<? echo $a1;?>>
> > <input type=text name=a2 value=<? echo $a2;?>>
> > <select name=a3><option value=MM>MM</option><option
> > value=SS>SS</option></select>
     <input type=submit name=regist>
> > </form></body></html>
> >
> > ■chk.inc
> > <?
> >   if (!$a1){
> >        header("location: http://host/aaa.php3?message=msg01");
> >        exit;
> >   }
> > ?>

◎BACさん、からのご指摘後修正
 ■aaa.php3
 <? if($regist){
         include('chk.inc');
    if(!$message){
             // 正常に入力された場合の処理
         }
    }
?>
<html>
<body>
<?
   if ($message==msg01){
      echo "**a1が入力漏れです**"";
   }
?>
 <form method=post action=aaa.php3>
 <input type=text name=a1 value=<? echo $a1;?>>
 <input type=text name=a2 value=<? echo $a2;?>>
 <select name=a3><option value=MM>MM</option><option
 value=SS>SS</option></select>
  <!-- select 部分には selected に相当する部分をここでは省いている-->
  <input type=submit name=regist>
  </form></body></html>

 ■chk.inc
 <?
   if (!$a1){
        $message=msg001;
   }
   if (!$a2){
        $message=msg002;
   }
 ?>

どうもありがとうございます。
お手数をおかけしてしまいました。