亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

PHP 提交請求不起作用

PHP 提交請求不起作用

PHP
千巷貓影 2023-06-24 19:15:55
我創建了一個注冊用戶系統并分為兩個頁面。(registercontrol.php 和 register.php)在register.php中,通?!疤峤弧卑粹o應該將數據發送到registercontrol.php,但是當我單擊“提交”按鈕時沒有任何反應。它只是刷新頁面,什么也不做,成員表中沒有數據。我錯過了什么嗎?注冊.php<?php require('../includes/config.php');//if logged in redirect to members pageif ($user->is_logged_in() ){     header('Location: ../dashboard/index.php');     exit(); }//define page title$title = 'Demo';//include header templaterequire('../layout/header.php');?><input type="text" name="fullname" id="fullname" class="form-control form-control-user" placeholder="Your Name" value="<?php if(isset($error)){ echo htmlspecialchars($_POST['fullname'], ENT_QUOTES); } ?>" tabindex="1" required><?php    //check for any errors    if (isset($infofn)){       foreach ($infofn as $infofn){            echo '<p class="p-3 text-info">'.$infofn.'</p>';        }    }                                   ?><input id="submit" type="submit" name="submit" value="Create Account" class="btn btn-primary btn-user btn-block" tabindex="6">注冊控制.php<?phprequire('../includes/config.php');if(isset($_POST['fullname'])){    //fullname validation    $fullname = $_POST['fullname'];    if (! $user->isValidFullname($fullname)){        $infofn[] = 'Your name must be alphabetical characters';    }   }//if form has been submitted process itif(isset($_POST['submit'])){//if no errors have been created carry on    if (!isset($infofn)){               try {            //insert into database with a prepared statement            $stmt = $db->prepare('INSERT INTO members (fullname) VALUES (:fullname)');            $stmt->execute(array(                ':fullname' => $fullname            ));            $id = $db->lastInsertId('memberID');                        //redirect to index page            header('Location: register.php?action=joined');            exit;        //else catch the exception and show the error.        } catch(PDOException $e) {            $error[] = $e->getMessage();        }    }}
查看完整描述

1 回答

?
揚帆大魚

TA貢獻1799條經驗 獲得超9個贊

您缺少一個表單元素,其action和method屬性設置為您的其他腳本和 to post。在這種情況下action應該是registercontrol.php。如果不設置操作,表單將提交給自身,在本例中為register.php.


像這樣的事情應該可以解決問題(僅添加第一行和最后一行,其余的是您的代碼):


<form action="registercontrol.php" method="post">

    <input type="text" name="fullname" id="fullname" class="form-control form-control-user" placeholder="Your Name" value="<?php if(isset($error)){ echo htmlspecialchars($_POST['fullname'], ENT_QUOTES); } ?>" tabindex="1" required>


    <?php

        //check for any errors

        if (isset($infofn)){

            foreach ($infofn as $infofn){

                echo '<p class="p-3 text-info">'.$infofn.'</p>';

            }

        }                                   

    ?>


   <input id="submit" type="submit" name="submit" value="Create Account" class="btn btn-primary btn-user btn-block" tabindex="6">

</form>


查看完整回答
反對 回復 2023-06-24
  • 1 回答
  • 0 關注
  • 197 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號