

create.htmlからcreate2.phpを起動するとエラーが表示されて本来表示したい文字が表示されないのですがどうしたらい

**エラーメッセージ:**

[code]

    Warning: Undefined array key "password" in C:\xampp\htdocs\atupoke\create2.php on line 24
    
[/code]

**フォルダ構成:**

[code]

    ┗create.html
    ┗create2.php
    ┗js
    __┗script.js
    
[/code]

**ソースコード:**  

[code]

    document.getElementById("touroku").onclick = function() {
        const name = document.getElementById("name").value;
        const pass = document.getElementById("password").value;
        const repass = document.getElementById("repassword").value;
        
        var flag = 0;
        if(name.length == 0){flag = 1;}
        if(pass.length == 0){ flag = 1; }
        if(repass.length == 0){ flag = 1; }
        
        if(flag == 1){ alert('必須項目が未記入の箇所があります'); }
        else{
        var regexp = /^([a-zA-Z0-9]{8,})$/;
        if(regexp.test(pass) != true){ alert('パスワードが半角英数8文字以上になっていません'); }
        if(pass != repass){ alert('パスワードが再入力時と違っています'); }
    }
    };
[/code]

[code]

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>create</title>
        <link rel="stylesheet" type="text/css" href="css/setting.css">
        <link rel="icon" href="img_or_ico/atupoke.ico">
    </head>
    <body>
        <form method="post" action="create2.php">
        <div class="login_form_btm">
            <h2>Create</h2>
            <p>ユーザー名とパスワードを書きましょう</p>
            <p>Usename(全角半角OK)</p>
            <input class="id-pass-button" type="text" placeholder="Username" id="name" name="name">
            <p>password(8~)</p>
            <input class="id-pass-button" type="password" placeholder="password" id="pass">
            <p>password(re)</p>
            <input class="id-pass-button" type="password" placeholder="password" id="repass">
            <p><input class="id-pass-button" type="submit" value="Create" id="touroku"></p>
        </div>
    </form>
        <header id="header">
            <div id="video-area">
            <video id="video" webkit-playsinline playsinline muted autoplay loop>
    <source src="video/back.mp4" type="video/mp4">
    <source src="video/back.ogv" type="video/ogv">
    <source src="video/back.webm" type="video/webm">
    <p>動画を再生できる環境ではありません。</p>
    </video>
    </div>
    </header>
    <script text="text/javascript" src="js/script.js"></script>
    </body>
    </html>
[/code]

[code]

    <!DOCTYPE html>
    <html lang="en">
    <head>
       <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <title>create2</title>
       <link rel="stylesheet" type="text/css" href="css/setting.css">
        <link rel="icon" href="img_or_ico/atupoke.ico">
    </head>
    <body>
        <header id="header">
        <?php
       class User{
         private $name;
         private $password;
         public function __construct($name , $password) {
          $this ->name = $name;
          $this ->password = $password;
         }
         public function created() {
          print "<h1>登録が完了しました！{$this->name}さん！</h1>" ;
          }
       }
       $User = new User ($_POST["name"] , $_POST["password"]);
    ?>
            <div id="video-area">
            <video id="video" webkit-playsinline playsinline muted autoplay loop>
    <source src="video/back.mp4" type="video/mp4">
    <source src="video/back.ogv" type="video/ogv">
    <source src="video/back.webm" type="video/webm">
    <p>動画を再生できる環境ではありません。</p>
    </video>
    </div>
    </header>
    </body>
    </html>
[/code]


CC BY-SA 4.0
2023-10-28T03:05:44.690
96606
2023-10-28T06:57:49.887
2023-10-28T06:57:49.887
3060
60169
question
javascript php html
phpがエラーになってしまう