1

フォーム a をフォーム b に送信し、javascript window.open またはフォーム タグ自体の action="" 属性を使用して新しいページにロードしようとすると、すべてが正しく開始されますが、新しいページでは SESSION 変数がロードされます渡されません。ただし、window.open メソッドを削除し、フォームを送信してブラウザに新しいページを手動でロードすると、フォーム b の新しいページの入力フィールドに SESSION 変数が正しく表示されます...

「return false;」と関係があるのだろうかと思いました。フォームaで実行しているonsubmit関数の一部、またはフォーム送信と新しいページの読み込み時に、SESSIONがそれらを保存して新しいページをウィンドウに読み込む前にSESSION値を設定していない場合...あの二人の犯人。ページのリダイレクトを行わなくても機能するので、送信後に新しいページがロードされたときに実際に SESSION 変数を保存していないと思います...新しいページのロード時に SESSION を正しく正常に保存してロードするにはどうすればよいですかフォームbの新しいページで正しく?

索引ファイル (フォーム A)

<?php
session_start();
if(isset($_POST['submit'])) {
    $_SESSION['cable_no'] = $_POST['cable_no'];
    $_SESSION['co_name'] = $_POST['co_name'];
    $_SESSION['prepping_team'] = $_POST['prepping_team'];
    $_SESSION['section_no'] = $_POST['section_no'];
    $_SESSION['tech_name_a'] = $_POST['tech_name_a'];
}
?>
<header>
<script type="text/javascript" language="javascript" src="/jquery/js/jquery-1.9.1.js">       </script>
<script type="text/javascript" language="javascript" src="js/scripts.js"></script>
<link href="css/style.css" type="text/css" rel="stylesheet" />
</header>
<form method="post" onsubmit="uploaddata(); return false;">
HTML CODE
<input type="submit" id="submit" name="submit" value="Continue" />
</form>

JS ファイル

function uploaddata() { 

//Read all of the data from the page
for (eID in prepform) {
    prepform[eID] = document.getElementById(eID).value;
}
//Send to database upload function and verify IF checkboxes are checked
if(document.getElementById("a11").checked && document.getElementById("b11").checked && document.getElementById("c11").checked && document.getElementById("a12").checked && document.getElementById("b12").checked && document.getElementById("c12").checked) {
        upload_prepform();
    }else{
        alert("Please verify that you have checked the known check boxes.")
    }
}   
function upload_prepform() {
    $.ajax({
            type: 'POST',
            url: './php/upload_prepform.php',
            data: prepform,
            async: false,
            dataType: 'text',
            success: function() {
                alert("Thank you. Your Prep form has been submitted.");
            },

            error: function(jqXHR, textStatus, errorThrown) {
                    alert("Error... " + textStatus + "\n" + errorThrown);
            },
            complete: function() {
                window.location.replace("http://dev1.rs.idmyasset.com/gp21-dev/prep_b/");
                alert("Redirecting...");
            }
        });
    };
4

1 に答える 1

3

ファイルを開始する必要があります

<?php
session_start();
?>

html コードの後で使用することはできません

于 2013-03-19T16:05:37.337 に答える