Jump to content

Cheslia

Members
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Cheslia

  • Rank
    Member
  1. Wow, I didn't expect such harsh words, like you've never made syntax errors that you just can't see for looking at it for days! Sorry I ever posted here because you guys are generally very helpful.
  2. OMG John that was it. So simple and so odd that that would make a difference, thank you so much!!! So why would the value= cause it to drop the first element in the select options like that?
  3. I have a php program that calls a function in my class to populate a select tag for display in the page. For some reason I cannot seem to discover, it retrieves the information, it correctly creates the option tags, but then when it displays the dropdown dialog box, the very top entry is missing. I sure could use another set of eyes on this to tell me what I'm missing as I know it has to be something simple. Here is the php page code that calls the function: if ($redisp==1) { $table_ex_entries .= "<table><tr>"; for ($x=0; $x<10; $x++) { //get the categories list with the selected one highlighted in the list $selected = $page->getGroupsForEntriesForm3($_SESSION['UID'],$entry_cat[$x]); //get the value for the off hours radio button if (isset($entry_offhrs[$x]) && $entry_offhrs[$x]=='y') { $set_checked_y = "checked='checked'"; $set_checked_n = ""; } else { if (isset($entry_offhrs[$x]) && $entry_offhrs[$x]=='n') { $set_checked_n = "checked='checked'"; $set_checked_y = ""; } else { $set_checked_n = "checked='checked'"; $set_checked_y = ""; } } $table_ex_entries .= "<tr>"; $table_ex_entries .= "<td><input size='12' name='date" . $x . "' type='text' value='" . $entry_date[$x] . "' id='datetimepicker" . $x . "'></td>"; $table_ex_entries .= "<td><input size='12' name='id" . $x . "' type='text' value='" . $entry_id[$x] . "'></td>"; $table_ex_entries .= "<td><input size='18' name='name" . $x . "' type='text' value='" . $entry_name[$x] . "'></td>"; $table_ex_entries .= "<td><select width='250' name='cat" . $x . "' value='" . $selected . "</select></td>"; $table_ex_entries .= "<td><input size='43' name='desc" . $x . "' type='text' value='" . $entry_desc[$x] . "'></td>"; $table_ex_entries .= "<td><input size='6' name='hrs" . $x . "' type='text' value='" . $entry_hrs[$x] . "'></td>"; $table_ex_entries .= "<td>Yes<input name='offhrs" . $x . "' type='radio' value='y' " . $set_checked_y . "> No <input name='offhrs" . $x . "' type='radio' value='n' " . $set_checked_n . "></td>"; $table_ex_entries .= "</tr>"; } $table_ex_entries .= "</table>"; } Here is the div in the html body (it displays fine as I have some javascript that determines which div to display based on the $redisp==1 show in the above code snippet) <div id="re_entry" style="display:none"> <p align="center"> *<b>Date/Category/Description/Hours are REQUIRED fields</b> <br>Please correct your entries and click Add Entries again to proceed. <br> </p> <?php echo $table_header; ?> <?php echo $table_ex_entries; ?> </div> And here is the function that it calls to create the option tags for the select tag in the first set of code building the html table. Oh and I do have categories preferences so it is retrieving just my list not the whole list in this function. public function getGroupsForEntriesForm3($uid,$category) { $out = ''; $cats = array(); $cat_id = array(); $catname = array(); $dbh = $this->rdb; //check to see if the user has set preferences for their list of categories $dbh->query("SELECT Categories FROM Users WHERE ID = :id"); $dbh->bind(':id', $uid); $row = $dbh->single(); $user_cats = (isset($row['Categories']) ? $row['Categories'] : ''); if ($user_cats == '') { //no special preference for categories so go get them all after getting the user's group ID $dbh->query("SELECT GID FROM Users WHERE ID = :id"); $dbh->bind(':id', $uid); $row = $dbh->single(); $gid = $row['GID']; $cats = $this->getCategories($gid); } else { //user has preference for categories so only go get the ones they have in their preference list to create the select options $dbh->query("SELECT ID, Name FROM Categories WHERE ID IN ($user_cats) ORDER BY Name"); $rows = $dbh->resultset(); $xx=0; foreach ($rows as $row) { $catname[$xx] = $row['Name']; $cat_id[$xx] = $row['ID']; $xx++; } } $dbh = NULL; $select_opt = ""; for ($xx=0; $xx<count($rows); $xx++) { //echo "category ID inside the function is set to " . $category . "<br>"; //echo "catname while while creating the select options set to " . $catname[$xx] . "<br>"; if ($category == $cat_id[$xx]) { //echo "match category is " . $category . " and cat_id[xx] is " . $cat_id[$xx] . " and catname[xx] is set to " . $catname[$xx] . " and xx is set to " . $xx . "<br>"; $select_opt .= "<option selected value='" . $cat_id[$xx] . "'>" . $catname[$xx] . "</option>"; } else { //echo "category is " . $category . " and cat_id[xx] is " . $cat_id[$xx] . " and catname[xx] is set to " . $catname[$xx] . " and xx is set to " . $xx . "<br>"; $select_opt .= "<option value='" . $cat_id[$xx] . "'>" . $catname[$xx] . "</option>"; } } return $select_opt; } Thanks in advance! Ches
  4. Yeah I know it was a lot. I tried to make a "mockup" of just the details, but can't seem to skinny it down enough to reproduce the issue. But thanks for the advice. I'll keep digging or trying to find another workaround.
  5. Thanks for all your help. I ended up working around it by calling another php page. Not what I wanted, but it works.
  6. Sorry about that....I maintain code that someone else wrote and it is a different style than I am used to. The field in question is the $category or $_POST['CAT'] field. I guess I left out one important function that actually builds that dropdown box with values. Here is that function that is called by getCatName(). I hope that helps.... public function getCatName($uid, $cat) { $out = ''; $cats = array(); $dbh = $this->rdb; $dbh->query("SELECT Categories FROM Users WHERE ID = :id"); $dbh->bind(':id', $uid); $row = $dbh->single(); $user_cats = (isset($row['Categories']) ? $row['Categories'] : ''); if ($user_cats == '') { $dbh->query("SELECT GID FROM Users WHERE ID = :id"); $dbh->bind(':id', $uid); $row = $dbh->single(); $gid = $row['GID']; $cats = $this->getCategories2($gid, $cat); } else { $dbh->query("SELECT ID, Name FROM Categories WHERE ID IN ($user_cats) ORDER BY Name"); $rows = $dbh->resultset(); foreach ($rows as $row) { if ($row['ID'] == "$cat") { $cats[$row['Name']] = array('value' => $row['ID'], 'selected' => 'selected' ); } else { $cats[$row['Name']] = array('value' => $row['ID']); } } } $dbh = NULL; return $this->xhtml->select($cats, array('name' => 'CAT', 'class' => 'entries_field_4')); } The way it works is this....when you initially load the page, it does the $redisp==0 portion of the add_entries_page(). It creates the table with everything blank except the categories drop down box (which is built by a very similar function as the one just above with a couple of minor variations). And when you hit the Add Entries button, it checks in the addEntries.php to make sure all the required fields were filled in. And if not, then it goes back to the add_entries_page() and does the portion of the code in the if $redisp == 1. Again, building the table with the remembered values and the already selected choices from the dropdown $categories. But is they change the category selection, it doesn't update that value. All other values are updated, just not that selection from the dropdown. Hope that helps a bit more. Sorry....I didn't want to not post something critical in the code/logic that would end up being needed.
  7. I have a timeclock application where you can add entries into a table. One of the columns is a <select> dropdown tag. If you do not enter one of the required fields, I redisplay the values entered so the user can correct the entries and resubmit to save them. Everything saves (posts) except the <select> dropdown value. The dropdown does show properly, even with the properly selected value. But if you change the value, it doesn't update. It retains the original value. Here is the function from STOP_Timeclock.php class that does the form: public function add_entries_page($msg) { $redisp = $_SESSION['redisp']; $out = ''; $offhrs = "N"; $dbh = new Database; //display the last entry the user saved to the database $dbh->query("SELECT * FROM Entries WHERE UID = :uid and GID = :gid order by Date DESC Limit 1"); $dbh->bind(':uid', $_SESSION['UID']); $dbh->bind(':gid', $_SESSION['GID']); $rows = $dbh->resultset(); foreach ($rows as $value) { $msg .= "Your last entry was: " . date('m-d-Y',strtotime($value['Date'])) . " for: " . $value['Description'] . " - " . number_format($value['Hours'],2,'.','') . " hour(s) were recorded. <br>"; } $select = $this->getGroupsForEntriesForm($_SESSION['UID']); //$select2 = $this->getGroupsForEntriesForm3($_SESSION['UID'],$_SESSION['array_category']); $caption = 'If you leave the Date Box empty, it defaults to today. *<b>Date/Category/Description/Hours are REQUIRED fields</b> <br><br>'; $head = array(array('name' => 'head', '1' => 'Date *', '2' => 'Ticket ID', '3' => 'Ticket Name', '4' => 'Category *', '5' => 'Description of Work Done *', '6' => 'Hours *', '7' => 'Off Hours(Y/N)' )); if($redisp == 0) { $body = array(); unset($_SESSION['array_id']); unset($_SESSION['array_name']); unset($_SESSION['array_category']); unset($_SESSION['array_desc']); unset($_SESSION['array_hours']); unset($_SESSION['array_offhrs']); for ($i = 1; $i < 11; $i++) { $row = array($this->xhtml->input(array('type' => 'text', 'id' => "datepicker$i", 'class' => 'entries_field_1', 'name' => 'DATE[]' )), $this->xhtml->input(array('type' => 'text', 'name' => 'ID[]', 'class' => 'entries_field_2' )), $this->xhtml->input(array('type' => 'text', 'name' => 'NAME[]', 'class' => 'entries_field_3' )), $select, $this->xhtml->input(array('type' => 'text', 'name' => 'DESC[]', 'class' => 'entries_field_5' )), $this->xhtml->input(array('type' => 'text', 'name' => 'HOURS[]', 'class' => 'entries_field_6' )), $this->xhtml->input(array('type' => 'text', 'name' => 'OFFHOURS[]', 'value' => $offhrs, 'class' => 'entries_field_7' )) ); $body[$i] = $row; } } if($redisp == 1) { $body = array(); $name = $_SESSION['array_name']; $id = $_SESSION['array_id']; $category = $_SESSION['array_category']; $desc = $_SESSION['array_desc']; $hours = $_SESSION['array_hours']; $offhrs = $_SESSION['array_offhrs']; $dates = $_SESSION['array_dates']; $max_count = $_SESSION['max_count']; for ($i = 0; $i < $max_count; $i++) { $selected = $this->getCatName($_SESSION['UID'], $category[$i]); $row = array($this->xhtml->input(array('type' => 'text', 'id' => "datepicker$i", 'class' => 'entries_field_1', 'value' => $dates[$i], 'name' => 'DATE[]' )), $this->xhtml->input(array('type' => 'text', 'name' => 'ID[]', 'value' => "$id[$i]", 'class' => 'entries_field_2' )), $this->xhtml->input(array('type' => 'text', 'name' => 'NAME[]', 'value' => "$name[$i]", 'class' => 'entries_field_3' )), "$selected", $this->xhtml->input(array('type' => 'text', 'name' => 'DESC[]', 'value' => "$desc[$i]", 'class' => 'entries_field_5' )), $this->xhtml->input(array('type' => 'text', 'name' => 'HOURS[]', 'value' => "$hours[$i]", 'class' => 'entries_field_6' )), $this->xhtml->input(array('type' => 'text', 'name' => 'OFFHOURS[]', 'value' => "$offhrs[$i]", 'class' => 'entries_field_7' )), ); $body[$i] = $row; if(isset($_POST['CAT'])) { $_SESSION['cats'][$i] = $_POST['CAT']; } else { $_SESSION['cats'][$i] = $category[$i]; } } } $data = array_replace($head, $body); $table = $this->xhtml->table2($data, $caption, array('class' => 'add_time')); $table .= $this->xhtml->input(array('type' => 'submit', 'value' => 'Add Entries' )); $form = $this->xhtml->form(array(array($table), ), array('action' => BASE . '/addEntries.php', 'class' => 'add_time', 'onsubmit' => 'return valid_Add(this)', 'method' => 'post' ) ); $out = $form; $menu = $this->getMenu(); $msg = $this->xhtml->div("$msg", array('id' => 'error')); $out = $this->xhtml->div("$out", array('id' => 'add_entries_form')); $out = $this->xhtml->div("$msg$out", array('id' => 'main')); $out = $this->xhtml->div("$menu$out", array('id' => 'container')); $out = $this->xhtml->body("$out", array('onload' => 'startUp();')); return $out; } And here is the addEntries page that evaluates for all fields and then saves to the database if correct. <?php session_start(); include('includes/config.php'); $msg =''; $x=0; $ok_to_post = 0; $page = new STOP_Timeclock; $xhtml = new XHTML; $dbh = new Database; if (isset($_POST['NAME'])) { $name = array_filter($_POST['NAME']); $_SESSION['array_name'] = $name; } if (isset($_POST['ID'])) { $id = array_filter($_POST['ID']); $_SESSION['array_id'] = $id; } if($_SESSION['redisp'] == 0) { if (isset($_POST['CAT'])) { $category = array_filter($_POST['CAT']); $_SESSION['array_category'] = $category; } } else { $category = $_SESSION['cats']; } if (isset($_POST['DESC'])) { $desc = array_filter($_POST['DESC']); $_SESSION['array_desc'] = $desc; } if (isset($_POST['HOURS'])) { $hours = array_filter($_POST['HOURS']); $_SESSION['array_hours'] = $hours; } if (isset($_POST['OFFHOURS'])) { $offhrs = array_filter($_POST['OFFHOURS']); $_SESSION['array_offhrs'] = $offhrs; } if (isset($_POST['DATE'])) { $dates = array_filter($_POST['DATE']); $_SESSION['array_dates'] = $dates; } $count_category = count($category); //$msg .= "count of category field is " . $count_category . "<br>"; $count_desc = count($desc); //$msg .= "count of desc field is " . $count_desc . "<br>"; $count_hours = count($hours); //$msg .= "count of hours field is " . $count_hours . "<br>"; $count_dates = count($dates); //$msg .= "count of date field is " . $count_dates . "<br>"; if ($count_desc == $count_hours) { if ($count_hours == $count_dates) { $ok_to_post = 1; $max_count = $count_desc; } else { if ($count_hours > $count_dates) { $max_count = $count_desc; } else { $max_count = $count_hours; } $ok_to_post = 0; $msg .= 'You did not enter one of the required fields - Date/Category/Description/Hours are REQUIRED. <br />'; } } else { if ($count_desc > $count_hours) { $max_count = $count_desc; } else { $max_count = $count_hours; } $ok_to_post = 0; $msg .= 'You did not enter one of the required fields - Date/Category/Description/Hours are REQUIRED. <br />'; } //$msg .= "max count is set to " . $max_count . "<br>"; $_SESSION['max_count'] = $max_count; //everything is entered correctly - now process and insert into the database $rowCount = 0; $today = date("Y-m-d"); $count = 0; if ($ok_to_post == 1) { $redisp = 0; $_SESSION['redisp'] = $redisp; $dbh->beginTransaction(); $myquery = "INSERT INTO Entries (`UID`, `GID`, `Date`, `CID`, `TicketNumber`, `TicketName`, `Description`, `Hours`, `OffHours`,`Created_Date`) VALUES (:uid, :gid, :date, :cid, :num, :name, :desc, :hrs, :offhrs, now())"; $dbh->query($myquery); for ($x = 0; $x < $max_count; $x++) { $dbh->bind(':uid', $_SESSION['UID']); $dbh->bind(':gid', $_SESSION['GID']); $dbh->bind(':date', $dates[$x]); $msg .= "category[x] is set to " . $category[$x] . "<br>"; $dbh->bind(':cid', $category[$x]); if (count($id)==0) { $dbh->bind(':num', NULL); } else { $dbh->bind(':num', $id[$x]); } if (count($name)==0) { $dbh->bind(':name', NULL); } else { $dbh->bind(':name', $name[$x]); } $dbh->bind(':desc', $desc[$x]); $msg .= "desc[x] is set to " . $desc[$x] . "<br>"; $dbh->bind(':hrs', $hours[$x]); $msg .= "hour[x] is set to " . $hours[$x] . "<br>"; $dbh->bind(':offhrs', $offhrs[$x]); $result = $dbh->execute(); if (!$result) { $msg .= "Saving entry to the database failed. Please see system administrator. <br />"; continue; } $count += $dbh->rowCount(); } if ($count != $max_count) { $dbh->cancelTransaction(); $msg .= 'An error occurred and all entries could not be added. <br /> For safety, this was rolled back and no entries were added. <br /> Please see system administrator. <br />'; } else { $dbh->endTransaction(); $dbh->query("SELECT * FROM Entries WHERE UID = :uid and GID = :gid and Created_Date >= :date2"); $dbh->bind(':uid', $_SESSION['UID']); $dbh->bind(':gid', $_SESSION['GID']); $dbh->bind(':date2', $today); $rows = $dbh->resultset(); $msg .= "Returned " . count($rows) . " entries successfully written to and retrieved from the database for you today. <br>"; $tothrs = 0; foreach ($rows as $value) { $msg .= "On " . date('m-d-Y',strtotime($value['Date'])) . " for " . $value['Description'] . " - " . number_format($value['Hours'],2,'.','') . " hour(s) were recorded. <br>"; $tothrs = $tothrs + $value['Hours']; } $msg .= "Total hours entered today = " . $tothrs . "<br>"; $msg .= "<br><br>"; } $dbh = NULL; $_SESSION['MSG'] = $msg; header('Location: ' . BASE); } else { $redisp = 1; $_SESSION['redisp'] = $redisp; $_SESSION['MSG'] = $msg; header('Location: ' . BASE); } ?> I am hoping that you all might be able to assist. Thanks in advance.
  8. Another question....what about putting a <div> that will be hidden until this scenario gets triggered, then unhiding it and displaying radio buttons to select for the user to continue vs. a pop-up dialog box? I've been playing with that a bit but having issues. I already have some ajax/jquery going for hiding/showing/input into the textarea div based on a selection from a menu, but not sure how to incorporate it into the existing ajax....or to have a separate function inside the same <script> tag. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $('#csid').bind('change', function(event) { // $("#csid").on("click", function () { console.log($("#csid").val()); var cs_id = $("#csid").val(); var schema_name = '<?php echo $schema ?>'; console.log(schema_name); console.log(cs_id); if(cs_id=="NEW") { var cleartxt = ""; $('#new').show(); $('#existing').show(); $('#newSection').val(cleartxt); } else { $('#new').hide(); $('#existing').show(); $.ajax({ type: 'Post', url: 'display_custext.php', data: { csid: cs_id, //passes the variable cs_id as the $_POST['csid'] to the designated page schema: schema_name, //passes the variable schema_name as the $_POST['schema'] to the designated page }, success: function (data) { var obj = $.parseJSON(data); var result = ""; $.each(obj, function () { result = result + this['PROTOCOL_STEP_CUSTOM_TEXT']; //create what will be passed to the .html tag in the ID='newSection' tagged section of html }); $('#newSection').val(result); //returns the value to display in the <input> tag } }); } }); }); </script> Here's the part of the html form... <form class="h3" method="post" action='new_custext.php'> <span class="error"><?php echo "<br>" . $searchforErr;?></span> <div style="color:blue;font-size:13px" id="feedback"><?php echo $_SESSION['feedback']?></div> <p> Select NEW or an existing Custom Text Script:<br><br> <select size="7" name="text_choices[]" class="select" id="csid"> <?php $page->get_custext($schema); ?> </select><br><br> </p> <div id="new" style="display:none"> Enter a name for your new custom text: <input type="text" name="textname" ><br><br> </div> <div id="existing" style="display:none"> Enter your NEW custom script or modify the existing script here: <br><br> <textarea name="custext" id="newSection" rows="6" cols="100" wrap="soft"></textarea><br><br> </div> <input class="ExtraLargeButton" type="submit" name="submit" value="Submit"> <input class="ExtraLargeButton" type=button name="home" value="Home" onClick="parent.location='index.php'"> <!-- Not used for returning to the LogGUI application, will most likely include link back to V11 when called from V11 <input class="button" type=button name="loggui" value="Log Index Home" onClick="parent.location='<?php echo BASE_LOGGUI_URL; ?>'">--> </form>
  9. Do you know of samples of this anywhere? I'm still pretty new to PHP and definitely green when it comes to using jquery and ajax.
  10. If possible, I would prefer to leave them on this page and just pop-up a dialog box for them to click on. Is that not possible to do?
  11. I've looked around various forums and found different answers, but nothing seems to fix exactly or work for me. Scenario: User is modifying a database table's text column value that already exists in the table in a <textarea> tag. Upon clicking submit, the validation code does a database query to see where the primary key might be associated with other records that would be affected by this change and returns a list of those affected. The code then evaluates if there is anything returned, and if there are rows returned, creates a list to be presented to the user to let them know that their change will affect all these other records that are tied to this particular record. At this point, I want to prompt the user to confirm their choice to update this record, knowing how it will affect the related records that use this record. Hope that is clearer than mud....but here's the snippet of PHP code.... Note: the $_SESSION['feedback'] simply displays its output in a designated <div> tag. if(strlen(trim($ori_list))==0) { //no other ORIs use this custom step, so it is ok to make the update $_SESSION['feedback'] .= "No other ORIs share this custom text script - ok to proceed.<br>"; $upd_ok = 'y'; } else { $_SESSION['feedback'] .= "If you make this change, it will affect these ORIs - " . $ori_list . " Are you sure you want to proceed?<br>"; //display a pop-up confirmation box and get the yes/no answer if ($confirm=='y') { $upd_ok = 'y'; $_SESSION['feedback'] .= "Proceeding with the update to protocol_step_id ". $text_choice . " <br>"; } else { $upd_ok = 'n'; $_SESSION['feedback'] .= "Aborting the update to protocol_step_id ". $text_choice . " <br>"; } } I've tried echo '<script.... type answers, I've tried closing my php with ?>, putting in an <a href> tag with an onclick= then reopening the <?php. I've looked at jquery confirm, and ajax even, but nothing seems to just allow me to pop up a dialog box in this particular place of my logic and return a True/False or Yes/No value back to my code to proceed. Any help would be greatly appreciated as you all seem to be so helpful thusfar with my other questions. Thanks.
  12. Oops, sorry about not encapsulating the code properly, I see that now and will do in the future. I was aware of not having two elements on the page with the same ID, I was removing/adding them back and forth in testing, but just copied them both in the code snippet. I should have clarified. And your solution $('#inputSectionID').val(result); worked perfectly, thanks! I knew it was probably something simple I was missing. Thanks again!
  13. Edited by Psycho: Please use code tags I have a php program containing this script tag.... <script> $(document).ready(function() { $("#csid").on("click", function () { console.log($("#csid").val()); var cs_id = $("#csid").val(); var schema_name = '<?php echo $schema ?>'; console.log(schema_name); console.log(cs_id); $.ajax({ type: 'Post', url: 'display_custext.php', data: { csid:cs_id, //passes the variable cs_id as the $_POST['csid'] to the designated page schema:schema_name, //passes the variable schema_name as the $_POST['schema'] to the designated page }, success: function (data) { var obj = $.parseJSON(data); var result = ""; $.each(obj, function() { result = result + this['PROTOCOL_STEP_CUSTOM_TEXT'] + "<br>"; //create what will be passed to the .html tag in the ID='newSection' tagged section of html }); $('#newSection').html(result); //returns the value to display in the <div> tag } }); }); }); </script> then in the body of my php program I have this section....it will populate the <div> but not the <input> tag. <p> Select NEW or an existing Custom Text Script:<br><br> <select size="7" name="text_choices[]" class="select" id="csid"> <?php $page->get_custext($schema); ?> </select><br><br> </p> <div id="newSection">goes here</div><br><br> <input type="text" id="newSection" class="txtbox"><br><br> this is the display_custest.php code the goes to the database and pulls the data to display....this works fine as well. <?php include_once('includes/config.php'); $dbh_oracle = oci_connect(ORACLE_USER, ORACLE_PASS, ORACLE_NAME); $csid = $_POST['csid']; $schema = $_POST['schema']; $myquery = "select ps.protocol_step_id, PS.PROTOCOL_STEP_CUSTOM_TEXT from " . $schema . ".PROTOCOL_STEP ps where ps.protocol_step_id = " . $csid . " order by PS.PROTOCOL_STEP_DESC"; $sth = oci_parse($dbh_oracle, $myquery); $results = oci_execute($sth); $cus_text = ""; if (!$results) { echo "Could not get the custom text for the protocol step id - " . oci_error(); } else { while($row = oci_fetch_array($sth, OCI_ASSOC)) { $cus_text[]=$row; } } echo json_encode($cus_text); ?> Thanks in advance.
  14. RESOLVED: Thanks everyone for your assistance! It was in the form action calling the first_page again prior to the redirect to the second_page and when the form was submitted, the get was blank, which makes sense. Here is the solution in case anyone else runs into this issue. I've left some of the debug in place to help others as well as it helped me. index2.php -- <?php session_start(); ?> <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="includes/style.css"> </head> <body> <table> <tr> <td width-"750"> <p> Make a choice:<br><br> <a href="first_page.php?page=third_page">Get the third page after first and second pages</a><br> <a href="first_page.php?page=fourth_page">Get the fourth page after first and second pages</a><br> </p> </td> </tr> </table> </body> </html> first_page.php -- <?php error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); // is the page parameter present at all? if (!isset($_GET['page'])) { http_response_code(400); exit('Missing URL parameter: page'); } /* is the parameter valid? - this will fail if the page= is not all numeric if (!ctype_digit($_GET['page']) || $_GET['page'] == 0) { http_response_code(400); exit('Invalid URL parameter: page'); } */ $s=$_GET['page']; $_SESSION['sp']=$s; $_SESSION['test']="test123"; echo "s variable from get is set to " . $s . "<br>"; echo "session variable for page is set to " . $_SESSION['sp'] . "<br>"; echo "session variable for test is set to " . $_SESSION['test'] . "<br>"; if (isset($_POST['submit']) && !empty($_POST['submit'])) { header('Location: second_page.php'); } ?> <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="includes/style.css"> </head> <body> <table> <tr> <td width="750px"> <form method="post" action="first_page.php?page=<?php echo $_SESSION['sp']?>"> <p> HTML text and a select tag here for choices </p> <input type="submit" name="submit" value="Submit"> </form> </td> </tr> </table> </body> </html> second_page.php -- <?php error_reporting(E_ALL); ini_set('display_errors', 1); session_start(); echo "session variable for page is set to " . $_SESSION['sp'] . "<br>"; echo "session variable for test is set to " . $_SESSION['test'] . "<br>"; if (isset($_POST['submit']) && !empty($_POST['submit'])) { if($_SESSION['sp']=="third_page") { header('Location: third_page.php'); } else { if($_SESSION['sp']=="fourth_page") { header('Location: fourth_page.php'); } else { header('Location: index2.php'); } } } ?> <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="includes/style.css"> </head> <body> <table> <tr> <td width="750px"> <form method="post" action="second_page.php"> <p> HTML text and a select tag here for choices </p> <input type="submit" name="submit" value="Submit"> </form> </td> </tr> </table> </body> </html> third_page.php -- <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="includes/style.css"> </head> <body> Congrats, you made it to the third page! </body> </html> fourth_page.php -- <!DOCTYPE HTML> <html> <head> <link rel="stylesheet" type="text/css" href="includes/style.css"> </head> <body> Congrats, you made it to the fourth page! </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.