私はそうのように動作します私のウェブサイト上で実装しようとしているマルチページフォームを持っている:PHPオブジェクトをセッションに格納していますか?
1は、顧客の詳細情報を入力します。 - > 2の確認お客様詳細 - - $ _POST $ _ SESSION-- > 3得意先からPDFを生成
私の2番目のページでわかるように、私のフォームの値は$ _POSTから得られます。その同じページで、私のクラスから「顧客」というオブジェクトを作成し、という顧客という名前のオブジェクトを作成し、最初のページからPOSTされたすべての値を保存します。
次に、 "customer"という名前の$ _SESSION変数を設定し、それを自分のオブジェクトに割り当てます。私のサイトの私の最後のページで今
session_start();
//includes html header part of page
include("includes/page/header.php");
//customer class
include("classes.php");
$customer = new customer();
$_SESSION['customer'] = $customer;
私は、次のコードをしている:
session_start();
//assign customer to equal object stored in session
$customer = $_SESSION['customer'];
//to test if successfull , nothing is displayed!
echo $customer->first_name;
return 0;
テストこれは何も私のページに表示されていないので、私のセッションは、私はそれを行うだろうと思った何をしていません。 FYI
:
- 私のクラスの顧客が細かく、正常に動作し、正しく保存し、すべての値を!
- マイpost配列は、最終ページにセッションの罰金
のvar_dumpを進めています。
object(__PHP_Incomplete_Class)#1 (15) { ["__PHP_Incomplete_Class_Name"]=> string(8) "customer" ["first_name"]=> string(5) "Iain" ["second_name"]=> string(6) "Taylor" ["company_name"]=> string(10) "Wired Ltd." ["address_1"]=> string(15) "14 Joseph St" ["address_2"]=> string(8) "West End" ["city"]=> string(7) "Glasgow" ["postcode"]=> string(7) "G45 NP4" ["county"]=> string(29) "Scotland" ["country"]=> string(14) "United Kingdom" ["email"]=> string(31) "[email protected]" ["phone"]=> NULL ["cid"]=> NULL ["reg_date"]=> NULL ["tel"]=> string(11) "01413395678" }
これを動作させる方法はありますか?
ありがとうございました
メリークリスマス!
コンテンツを確認するために 'var_dump($ _ SESSION ['customer'])'を使ってみましたか? –
'$ customer-> first_name'はセッションに割り当てる前に値を持っていますか? –
セッションを設定した後で確認しましたが、セッションをすぐに読み取ることができますか? – Robert