Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7

    Passing variables


    In my index.php, I am including search.php, affinfo.php and affacess.php.
    Code:
    <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>
    In search. php I am entering an email address and searching to see if it exists. If it exists, am pulling in Name.affId and Org
    PHP Code:
    $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'] = $af
    In my affInfo page am dispaying out the values
    PHP Code:
    echo "<tr><td>Name:</td><td><input type='text' name='name' value='$fname $lname' align='right' disabled></td>";
            echo 
    "<tr><td>Organisation:</td><td><input type='text' name='org' value='$org' align='right' disabled></td>"
    In my affAccess.php I have drop down boxes as part of a selection. Also on this page is a submit button which calls addAccess.php. This addAcess.php is supposed to update my database with the selected values and the affID from my select statement.
    It picks up the selected values fom the POST method
    PHP Code:
        $dept=rtrim($_POST['dept']);
        
    $campus=rtrim($_POST['campus']);
        
    $creat=rtrim($_POST['creat']); 
    but i cant display the affId value.
    I have used session varaiable for the affID but it loses the value when i click on update submit.
    On each of the pages I have
    PHP Code:
    session_start(); 
    I appreiate any help on this as it is bugging me!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    All other values print out fine from the SELECTed line? Can you show how you print the $affiliate value? All column names in your database are capitalized as well, correct?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    Hi, yes they all print fine, Throughtout the pages I have been testing by
    PHP Code:
    echo $_SESSION['affiliate']; 
    . When I click the update button which calls addAccess.php. I am doing the following:
    PHP Code:
    session_start();
    $a=$_SESSION['affiliate'];
    //$affiliate2=rtrim($_GET['affiliate']);
    echo "add sess is ".$_SESSION['affiliate'];
    echo 
    $a;
    if (
    $Update){
        
    $dept=rtrim($_POST['dept']);
        
    $campus=rtrim($_POST['campus']);
        
    $creat=rtrim($_POST['creat']);
        
    //$test=rtrim(($_POST[$a]);
        //$a=$_SESSION['affiliate'];
        
    echo $a;
        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;
        echo 
    "sess is ".$_SESSION['affiliate'];
    $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"$a);
        
    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); 
    I have tried with $a, and $_SESSION['affiliate'];
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    Hi, I would appreciate any help on this, They all print fine except my session variable on the addAccess.php
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    What DOES print from your session variable? Maybe print the whole array just to see what its got?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    Hi, its prints the correct value on all the pages
    add sess is AF100060

    Code:
    <div id="update"><INPUT size= "20" type="submit" name="Update" value="Update" class="button" ></div>
    PHP Code:
    <?php //echo $a; ?>
    <?php 
    include ("addAcess.php");?>
    but when I click the update update, it seems to loose the value, and i need to add that variable to a database table
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    Is that the top of your addAccess.php file? It seems something is missing. Nothing is setting the $update variable. Can you post your whole addAccess.php, or at least all up to these lines?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    Here is my code
    PHP Code:
    session_start();
    //$affiliate=rtrim($_GET['aff']);
    $a=$_SESSION['affiliate'];
    //$affiliate2=rtrim($_GET['affiliate']);
    echo "add sess is ".$_SESSION['affiliate'];
    echo 
    $a;
    //$affiliate='AF100060';
    echo "SID: ".SID."<br>session_id(): ".session_id()."<br>COOKIE: ".$_COOKIE["PHPSESSID"];

    $Update = (isset($_POST['Update']) ? $_POST['Update'] : null );

    if (
    $Update){
        
    $dept=rtrim($_POST['dept']);
        
    $campus=rtrim($_POST['campus']);
        
    $creat=rtrim($_POST['creat']);
        
    //$test=rtrim(($_POST[$a]);
        
    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;
        
    //echo "sess is ".$_SESSION['affiliate'];
        //$ts=strtotime($sdate);
        //echo "afterstartdate is ".$ts;
        //echo $auth;
        //echo $sdate;
        
        //$ns=setDateDMY($sdate);
        //echo $ns;
        //$ne=setDateDMY($edate);    */
        
        
    $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 TEST2 (AFF_ID,DEPT_ID,CAMP_ID, AUTH_ID, CREATED_TSTAMP, START_DATE, PASSWD)
         //            SELECT :AffID_bv,:DeptID_bv, :CampID_bv,:AuthID_bv, current_timestamp, to_date(:SDate_bv, 'dd/Mm/yyyy'),'Zq'||dbms_random.string('A',4)||'$8' from dual";
        
    $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);
            
        if (!
    $exec2) {
            
    $e oci_error($stid);
            
    trigger_error(htmlentities($e['message']), E_USER_ERROR);
            }
        
        
        
    $commit2=oci_commit($conn);
        if (!
    $commit2) {
            
    $e oci_error($stid);
            
    trigger_error(htmlentities($e['message']), E_USER_ERROR);
        }
        if (
    $commit2){
            
    header("location:index.php");
        } 
    //*/
    }
    ?> 
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    Aight. 2 things. Are you running addAccess.php in another file as an include? If so, can I see the whole top of that file? Also, can I see the form defining its action as addAccess.php?
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    Hi Yes I am. Here is my code for affAccess.php. THis includes addAcess.php
    PHP Code:
    <?php
    session_start
    ();
    ?>

    <script language=JavaScript  src="/Aff/INCLUDE/tcal.js"
    type="text/javascript">
    </script> 

    <?php

    $path
    =$_SERVER['REQUEST_URI'];

    //$affiliate=rtrim($_GET['aff']);
    //session_register("affID");
    //session_register("dept");
    //$_SESSION["affID"]=$affiliate;


    ?>

    <form name ="affiliation" method='POST'  action='' onsubmit='return validateAffiliation(dept,campus,creat,s_date,e_date)'>
        <?php echo "before update sess is ".$_SESSION['affiliate'];        
        echo 
    "SID: ".SID."<br>session_id(): ".session_id()."<br>COOKIE: ".$_COOKIE["PHPSESSID"];
    ?>
        <fieldset><legend> Affiliation: </legend>
        <table cellspacing= "18">
            <tbody>
            <tr><td>Dept:<dt style="text-align:right";>*</td><td>
            <?php
            
    echo "<select name='dept' align='left' id='dept'><option value=''>Select Dept</optiont>";
            while (
    $row1 oci_fetch_array($dept_stmtOCI_BOTH)) {
                if(
    $row1['DNAME']==$dept)                                
                    echo 
    "<option selected value='$row1[DEPT_ID]'>$row1[DNAME]</option>";                            
                else                                
                    echo 
    "<option value='$row1[DEPT_ID]'>$row1[DNAME]</option>";                                
            }
            
    ?>
            </select></td>
            <td>Start Date:<dt style="text-align:right";>*</</td><td><input type="text" name="s_date" id="s_date" class="tcal" value="" /></div>
            </td>
            </tr>
            <tr><td>Campus:<dt style="text-align:right";>*</td><td>
            <?php
            
    echo "<select name='campus' align='left' id='campus'><option value=''>Select Campus</optiont>";
            while (
    $row1 oci_fetch_array($campus_stmtOCI_BOTH)) {
                if(
    $row1['CPNAME']==$dept)                                
                    echo 
    "<option selected value='$row1[CAMP_ID]'>$row1[CPNAME]</option>";                            
                else                                
                    echo 
    "<option value='$row1[CAMP_ID]'>$row1[CPNAME]</option>";                                
            }
            
    ?>
            </select></td>
            <td>End Date:<dt style="text-align:right";>*</</td><td><input type="text" name="e_date" id="e_date" class="tcal" value="" /></div>
            </td>
            </tr>
            <tr><td>Created By:<dt style="text-align:right";>*</td><td>
            <?php
            
    echo "<select name='creat' align='left' id='creat'><option value=''>Select Created By</option>";
            while (
    $row1 oci_fetch_array($creat_stmtOCI_BOTH)) {
                if(
    $row1['CRNAME']==$dept)                                
                    echo 
    "<option selected value='$row1[CREAT_ID]'>$row1[CRNAME]</option>";                            
                else                                
                    echo 
    "<option value='$row1[CREAT_ID]'>$row1[CRNAME]</option>";                                
            }
            
    ?>
            </select></td></tr>
            <tr></tr>
            <tr></tr>
            </tbody>
        </table><br>    
        
        <div id="update"><INPUT size= "20" type="submit" name="Update" value="Update" class="button" ></div>
        
        <?php //echo $a; ?>
        <?php include ("addAcess.php");?>
        
        <?php //echo $_SESSION["affID"]; ?>
        </fieldset>    
    </form>
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    I'd remove session_start() from your addAccess.php file since you are not running this file on its own, so you are calling session_start() twice.

    Are you able to echo $_SESSION['affiliate'] at all? Like before this submission of this form?
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    Hi tried that by removing session_start() from addAccess.php. Yes I am echoing it and it does dispaly the value untill I click update and it somehows looses it. My index. php includes the following files
    PHP Code:
    <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"); ?>
    ANd affAccess.php includes addAccess.php
    So somewhere between my index.php and clicking the update button $_SESSION['affiliate'] is not been retained.
    I echo out $_SESSION['affiliate'] on all my include pages
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    Well, I'm sorry to say I'm a bit at a loss here. You are setting your $_SESSION['affiliate'] only once in this whole project, on your search.php page. The only thing I can guess is when the page reloads, the $affiliate which sets $af which sets $_SESSION['affiliate'] is being offered a different value. What sets your $affiliate? It is not posted in your search.php which you provided.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2008
    Posts
    74
    Rep Power
    7
    My $affiliate is been set from my query to the database
    PHP Code:
    $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;
    $_SESSION['org']=$org
    MAybe Im doing it wrong and I cant think of another way of doing it. What i want to do is search for an email address and if that email exits then pull in its ID and I want to insert that ID into another table with fields posted from my affAccess.php
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    668
    Rep Power
    6
    JUST before setting your SQL statement, echo $s_email to make sure it comes around right. Then place an echo after oci execution of each variable set to make sure its setting each variable correctly.($org,$e,$fname,$lname,$affiliate) I'm not familiar with this oci stuff, so if the issue lies in there, I'm of no help. If this all prints out fine, then I think I'm of no help you you. Seems a basic task, so I'm probably just overlooking a basic item. :-/

    If the new variables don't print right, maybe soemthing like:

    PHP Code:
    $sql="SELECT AFF_ID, LNAME, FNAME, EMAIL, ORG FROM `AFFILIATE` WHERE EMAIL = '" rtrim($s_email) . "'"
    And in your database, is everything really capitalized? Databases are usually case sensitive.
    Last edited by Triple_Nothing; December 11th, 2012 at 09:36 AM.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo