通过页面传递变量

时间:2012-12-06 12:43:36

标签: php session oracle11g

我有一个index.php页面。一开始我有session_start();在我的index.php中,我包含以下内容

 <div id="affinfocol">          
            <?php include ("search.php"); ?>
            <?php include ("affInfo.php"); ?>
            <!-- Right Col -->
            <div id="rightcol"><br>
                <?php include ("adeAff.php"); ?>
            </div>          
        </div>
        <!--Affilaition -->
        <div id="affiliation">              
            <?php include ("affAccess.php"); ?>             
        </div>  

Search.php是用户输入电子邮件地址以查看其是否存在的位置。在搜索中它会拉回aff_id并将其存储在会话变量

sql="SELECT AFF_ID,LNAME, FNAME,EMAIL,ORG FROM AFFILIATE WHERE rtrim(EMAIL) LIKE '$s_email'";
$email_search = oci_parse($conn,$sql);
oci_define_by_name($email_search, 'ORG', $org);
oci_define_by_name($email_search, 'EMAIL', $e);
oci_define_by_name($email_search, 'FNAME', $fname);
oci_define_by_name($email_search, 'LNAME', $lname);
oci_define_by_name($email_search, 'AFF_ID', $affiliate);

$exec=oci_execute($email_search); 
oci_fetch($email_search);
$rows=oci_num_rows($email_search);
//$af=$affiliate;
$_SESSION['affiliate'] = $affiliate;

affAccess.php还包含一个addAccess.php。这是在单击更新时使用affAccess.php中的其他值更新数据库的位置。这是我的更新代码

if ($Update){
    $dept=rtrim($_POST['dept']);
    $campus=rtrim($_POST['campus']);
    $creat=rtrim($_POST['creat']);
    echo $_SESSION['affiliate'];    
    $sdate=isset($_REQUEST["s_date"])?$_REQUEST["s_date"]:"";
    $edate=isset($_REQUEST["e_date"])?$_REQUEST["e_date"]:"";
    echo "updating";    
    echo " dept is " . $dept;
    echo " campus is ". $campus;


    $sql = "BEGIN PassGen(); END;";
    $stmt = oci_parse($conn,$sql);
    $exec =oci_execute($stmt,OCI_DEFAULT);

    if (!$exec) {
        $e = oci_error($stmt);
        trigger_error(htmlentities($e['message']), E_USER_ERROR);
    }

    if ($exec) {

    } 
$sql="INSERT INTO AFFILIATIONS (AFF_ID, START_DATE,END_DATE,DEPT_ID,CAMP_ID, CREAT_ID, CREATED_TSTAMP, PASSWD)
            SELECT :AffID_bv, to_date(:SDate_bv, 'dd-Mm-yyyy'),to_date(:EDate_bv, 'dd-Mm-yyyy'),:DeptID_bv, :CampID_bv,:CreatID_bv, current_timestamp,'Zq'||dbms_random.string('A',4)||'$8' from dual";
    $stid = oci_parse($conn,$sql);

    //oci_bind_by_name($stid, ":AffID_bv", $_SESSION["affID"]);
    oci_bind_by_name($stid, ":AffID_bv", $_SESSION['affiliate']);
    oci_bind_by_name($stid, ":DeptID_bv", $dept);
    oci_bind_by_name($stid, ":CampID_bv", $campus);
    oci_bind_by_name($stid, ":CreatID_bv", $creat);
    oci_bind_by_name($stid, ":SDate_bv", $sdate);
    oci_bind_by_name($stid, ":EDate_bv", $edate);   

    $exec2 =oci_execute($stid,OCI_DEFAULT);

为了调试它,我在echo $_SESSION['affiliate']的其他页面上回应它。它正在挑选它但是当我点击更新时,$_SESSION['affiliate']丢失了。

0 个答案:

没有答案