Jump to content

tommy168

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tommy168's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey guys So my question is related to the delete and edit functions in a table When I am able to delete entries, I can't edit When I am able to edit entries, I can't delete Let me explain... Started with the table script first (excerpt): echo "<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <table> <tr> <td width=\"55\" class=\"formLabelsS2\"><input type=\"submit\" name=\"delete_mail\" value=\"Delete\" id=\"delete_mail\"></td> </tr> </table>"; echo "<table class=\"sortable\" id=\"query_quick2\" width=\"100%\" >\r\n"; echo "\t<tr><th class=\"sorttable_nosort\" ></th><th class=\"sorttable_nosort\" ></th> <th class=\"sorttable_alpha\" >Promoter Locus</th>\r\n"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr id=\"{$row['id']}\" class=\"$row_color\" > <!--<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\">--> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"/></td> <td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"{$row['id']} \"></td> <td>{$row['pro']}</td> <td><input type=\"submit\" name=\"edit_mail\" value = \"Edit\"/></td> <!--</form>--> </tr>"; } } echo "</table>"; echo "</form>"; Script for deleting entries (excerpt): } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete_mail'])){ //user is deleting existing queries $connect=db_connect_2(); if($_POST['checkbox']){ { foreach($_POST['checkbox'] as $check) { $delete = mysqli_query($connect, "DELETE FROM mailing_list WHERE id = '$check'"); } $msgs[] = "Entry deletion was successful!"; $body = "account.php"; } When "edit_mail" button is pressed: } elseif(isset($_SESSION['user_id']) AND isset($_POST['edit_mail'])){ //user is editing existing queries $body = "mailingList_edit.php"; } A editing form is displayed based on the value of $id: <?php //retrieve user information $conn=db_connect_2(); $id = mysqli_real_escape_string($conn, $_POST['id']); $result = $conn->query("SELECT * FROM mailing_list WHERE id = '$id';"); $mail = $result->fetch_array(); ?> <div class="viewTitles" >Edit Your Queries:</div> <form method = "post" action = "<? echo $_SERVER['PHP_SELF'] ?>"> <table> <tr><td width="88" class="formLabelsS2" align="left">Promoter Locus:</td></tr> <tr><td><input class = "basicTextField" type="text" name="pro_edit" value="<? echo $mail['pro']; ?>"></td></tr> </table> OK so what happens is: I can delete entries with no problems by checking off the entries I want to delete then click delete button But when I try to click "edit" button near a specific entry (individually), it DOES refer to a specific entry, but right after i SORT the table using sorttable.js, it would always refer to the LAST entry. So I am suspecting there's problem with positioning of the <form></form> inside the while loop (see the table script, as I put lot of space in between these lines for emphasis) Note that I put these <form> and </form> lines as comment so I could do what I mention above, otherwise I couldn't even delete any entries if I leave these 2 lines to be part of the while loop BUT !! I could edit specific entry even after I sort the table I know this is long thread, so please let me know if you need more clarification Thanks.
  2. Hey guys I am confused about using checkboxes to delete entries. Yes, just for delete. Codes for table: echo "<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <table> <tr> <td width=\"55\" class=\"formLabelsS2\"><input type=\"submit\" name=\"delete\" value=\"Delete\" id=\"delete\"></td> <td> Please note that entries could not be restored once they are deleted!</td> </tr> </table> </form>"; echo "<table class=\"sortable\" id=\"query_quick1\" width=\"100%\" >\r\n"; echo "<thead>"; echo "\t<tr><th></th><th></th><th>Up.dated Query</th><th>Link</th><th>Promoter</th><th> # </th><th>Up?</th> <th>Ana. Area</th><th> # </th><th>Up?</th> <th>C. Type</th><th> # </th><th>Up?</th><th>Other C. Type</th> <th> # </th><th>Up?</th><th>Gen. Back.</th><th> # </th><th>Up?</th> <th>Other Gen. Back.</th><th> # </th><th>Up?</th><th>Author</th><th> # </th><th>Up?</th> <th>Other</th><th> # </th><th>Up?</th><th>Date</th><th>Email</th> <th>F. Name</th><th>L. Name</th></tr>\r\n"; echo "</thead>"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr class=\"$row_color\" > <form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"></td> <td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"{$rows['id']} \"></td> <td>{$row['query']}</td><td>{$row['link']}</td> <td>{$row['pro']}</td><td>{$row['pro_count']}</td> <td>{$row['pro_update']}</td> <td>{$row['ana']}</td><td>{$row['ana_count']}</td><td>{$row['ana_update']}</td> <td>{$row['cell']}</td><td>{$row['cell_count']}</td><td>{$row['cell_update']}</td> <td>{$row['cellother']}</td><td>{$row['cellother_count']}</td><td>{$row['cellother_update']}</td> <td>{$row['gen']}</td><td>{$row['gen_count']}</td><td>{$row['gen_update']}</td> <td>{$row['genother']}</td><td>{$row['genother_count']}</td><td>{$row['genother_update']}</td> <td>{$row['author']}</td><td>{$row['author_count']}</td><td>{$row['author_update']}</td> <td>{$row['other']}</td><td>{$row['other_count']}</td><td>{$row['other_update']}</td> <td>{$row['date']}</td><td>{$row['Email']}</td> <td>{$row['First_Name']}</td><td>{$row['Last_Name']}</td> </form></tr>"; } } echo "</table>"; php for deleting entries: } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete'])){ $connect=db_connect_2(); foreach($_POST['checkbox'] as $check) { $delete = mysqli_query("DELETE FROM mailing_list WHERE id = '$check'"); } $body = "mailingList.php"; } Error pops up: Warning: Invalid argument supplied for foreach() Of course no entries are deleted due to this warning. Help would be greatly appreciated as always Thanks.
  3. Hey guys Just a quick question: How to embed hyperlink into a database cell? Basically I echo out a table on the user interface of my site and there's an URL in one of the cells I want the user to access it by clicking on it, without copying and pasting the URL into the URL bar of the browser I tried updating the cell in phpmyadmin using <a href = http://www.example.com>http://www.example.com</a> but didn't work out, the resulting cell only had the text format Any help would be appreciated Thanks.
  4. You either need to break each record retrieved from the database into its own form, with its own submit button Could you please elaborate on this point? Because I want to be able to edit individual entry, so i think it's a better idea to have edit buttons right next to the entries by the way just a quick update, the codes have been fixed as follow: $result = $conn->query("SELECT query, link, pro,pro_update,ana,ana_update,cell,cell_update,cellother,cellother_update,gen,gen_update,genother,genother_update,author,author_update,other,other_update,date,id FROM mailing_list WHERE email = '$email' ORDER BY $order LIMIT $start_row, $max_per_page;"); echo "<table class=\"sortable\" id=\"query_quick2\" width=\"100%\" >\r\n"; echo "\t<tr><th class=\"sorttable_alpha\" >Updated Query</th><th width=\"10\" class=\"sorttable_alpha\" >Link</th> <th class=\"sorttable_alpha\" >Promoter Locus</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Anatomical Area</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Cell Type</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Other Cell Type</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Genetic Background</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Other Gen. Back.</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Author</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_alpha\" >Other</th><th class=\"sorttable_alpha\" >Update</th> <th class=\"sorttable_mmdd\" >Date</th><th class=\"sorttable_nosort\" ></th><th class=\"sorttable_nosort\" ></th>\r\n"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\">"; echo "\t<tr id=\"{$row['id']}\" class=\"$row_color\" > <td>{$row['query']}</td><td>{$row['link']}</td> <td>{$row['pro']}</td><td>{$row['pro_update']}</td><td>{$row['ana']}</td> <td>{$row['ana_update']}</td><td>{$row['cell']}</td><td>{$row['cell_update']}</td><td>{$row['cellother']}</td> <td>{$row['cellother_update']}</td><td>{$row['gen']}</td><td>{$row['gen_update']}</td><td>{$row['genother']}</td> <td>{$row['genother_update']}</td><td>{$row['author']}</td><td>{$row['author_update']}</td><td>{$row['other']}</td><td>{$row['other_update']}</td> <td>{$row['date']}</td> <td><input type=\"submit\" name=\"edit_mail\" value = \"Edit\"/></td> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"/></td> <td><input type=\"submit\" name=\"delete_mail\" value =\"Delete\"/></td> </tr>"; echo "</form>"; } } echo "</table>"; now a specific entry could be deleted but another problem arises Right AFTER i sort the table by clicking a column heading, say, promoter locus, (using sortable.js) and then when i try to delete a specific entry, problem arises. Instead of deleting the entry i want, it always deletes the LAST entry. Now as you can see, i select a specific value for $id, using post method from a form But shouldn't the value of $id point to the entry i want to delete when i click the "delete" button near it? (i mean it works fine before i sort the table) Any help would be greatly appreciated Thanks.
  5. Hay guys so i was debugging my mailing list script some mistakes come up in the foreach loop with send_email( ) function in it As a result, it keeps sending emails like crazy (well over 100 emails within half an hour) Now when i want to test the script again, no emails can be sent So i would assume the web server is down because of the huge email flood But how long would it last? And what can I do to get around it, so the pause in between the email floods could be minimized? Thanks
  6. Hey guys I have trouble picking the specific id of an entry i want to delete so please take a look at the codes first Here's the function for making the form: function am_query_display_quick($page,$order ='DATE DESC'){ global $email; $conn = db_connect_2(); $color1 = "tableRowOdd"; $color2 = "tableRowEven"; $RowCount = 0; $result = $conn->query("SELECT pro,pro_update,ana,ana_update,cell,cell_update,cellother,cellother_update,gen,gen_update,genother,genother_update,author,author_update,other,other_update,id FROM mailing_list WHERE email = '$email' ORDER BY $order LIMIT $start_row, $max_per_page;"); echo "<form method = \"post\" action=\".{$_SERVER['PHP_SELF']}.\">"; echo "<table class=\"sortable\" id=\"query_quick2\" width=\"100%\" >\r\n"; echo "\t<tr><th></th><th>Promoter Locus</th><th>Update?</th><th>Anatomical Area</th><th>Update?</th><th>Cell Type</th><th>Update?</th><th>Other Cell Type</th><th>Update?</th><th>Genetic Background</th><th>Update?</th><th>Other Gen. Back.</th><th>Update?</th><th>Author</th><th>Update?</th><th>Other</th><th>Update?</th><th></th>\r\n"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr class=\"$row_color\" ><td><input type=\"submit\" name=\"edit_mail\" value = \"Edit\"/></td> <td>{$row['pro']}</td><td>{$row['pro_update']}</td><td>{$row['ana']}</td> <td>{$row['ana_update']}</td><td>{$row['cell']}</td><td>{$row['cell_update']}</td><td>{$row['cellother']}</td> <td>{$row['cellother_update']}</td><td>{$row['gen']}</td><td>{$row['gen_update']}</td><td>{$row['genother']}</td> <td>{$row['genother_update']}</td><td>{$row['author']}</td><td>{$row['author_update']}</td><td>{$row['other']}</td><td>{$row['other_update']}</td> <td><input type=\"submit\" name=\"delete_mail\" value =\"Delete\"/></td> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"/></td> </tr>"; } } echo "</table>"; echo "</form>"; And this is where the delete command comes into place (excerpt): } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete_mail'])){ //user is deleting existing queries $conn=db_connect_2(); $id = mysqli_real_escape_string($conn, $_POST['id']); echo $id; $sql2 = "DELETE FROM mailing_list WHERE id='$id'"; $result = mysqli_query($conn, $sql2) or mysqli_error($conn); $msgs[] = "Query deleted successfully."; $body = "account.php"; } yes it can delete entries all right but it doesn't delete a specific entry when i click the "delete" button near it somehow, it ALWAYS deletes the last row of entry at the table as you can see, i echoed out $id as it's referring to the LAST entry as well So my question is, how to delete a particular entry when i click the corresponding "delete" button?? Thanks
  7. Hey guys, I got some questions about the while loop It's dealing with the "qset" as you can see below: $get = "SELECT qset from mailing_list where email = '$email'"; $result = mysqli_query($connect, $get) or die($connect); while ($row = mysqli_fetch_array($result)){ extract($row); $qset = rsort($row); $qset = (int)end($row); } if (empty($qset) || $qset < 1){ $qset = 1; return $qset; } elseif ($qset >=1){ $qset = $qset + 1; return $qset; } echo $qset; Nothing echoed out... Why? Also it seems like the script got stuck at the while loop, as no sql commands that follow up are processed Any help is appreciated! Thanks
  8. Here's the URL to the page of the menu, so you can sort of visualize more: http://nagy.mshri.on.ca/Coop_Student/cre/search/Search_Coop_try3.php As you can see, the genetic background menu in the Advanced Search section works like it is supposed to. When you click the "other" option on the drop down menu there (scroll down to the bottom of the menu), it will prompt you to an additional text box But if you compare it with the genetic background menu at the bottom in the update mailing list section, when you click "other", nothing happens... Again, i used the exact same code (copy and paste pretty much as you can see above) and the script for update mailing list is INCLUDED into the main script of the search page, so all the scripts needed for menu to work are all there So what's the problem? By the way, i removed the submit button for update mailing list cause i am still building the script Thanks
  9. Hi guys So i am having a problem with the drop down menu For example, when you click the option "other" from the menu, it will prompt you with an additional text box, as you can see from the script below: <tr> <td valign="top" class="formLabelsS2"><div align="right">Genetic Background: </div></td> <td><select name="genetic_bg[]" size="5" multiple="multiple" class="basicMenu" id="genetic_bg" onChange="toggleOther('genetic_bg','GeneticBGOther','GeneticBGOtherTxt');" > <?php menu_display("genetic_bg"); ?> </select> </td> </tr> <tr id="GeneticBGOther" <?php menu_display_other("genetic_bg");?>> <td class="formLabelsS2"><div align="right">Other</div></td> <td><span class="body"> <input name="GeneticBGOtherTxt" type="text" class="basicTextField" id="GeneticBGOtherTxt" value="<?php echo $_GET['GeneticBGOtherTxt']; ?>" size="35" /> </span></td> </tr> The scripts for menu_display and menu_display_other functions are as follow: function menu_display($menu_name){ $menu = menu_get_menu($menu_name); if($_SERVER['REQUEST_METHOD'] == 'POST') { $method = $_POST; } else { $method = $_SESSION; } if(!empty($menu)){ for($i=0;$i<sizeof($menu);$i++){ //we add the label for javascript showing and hiding divs echo "<option value={$menu[$i]['value']} label=\"{$menu[$i]['title']}\""; if(is_array($method[$menu_name])){ if(in_array($menu[$i]['value'],$method[$menu_name])){ echo "selected=\"selected\"" ; } } else { if($method[$menu_name] == $menu[$i]['value']) { echo "selected=\"selected\"" ; } } echo ">{$menu[$i]['title']}</option><br />"; } } } /* This function checks if the variable $str is in recieved data if not the element is hidden input: select id */ function menu_display_other($menu_name) { $conn = db_connect_2(); if($_SERVER['REQUEST_METHOD'] == 'POST') { $method = $_POST; } else { $method = $_SESSION; } if($menu_name == 'ana_stage'){ $query = "SELECT STG_OID FROM ana_stage WHERE STG_NAME = 'Other';"; } else { $prefix = get_table_prefix($menu_name); $query = "SELECT {$prefix}_ID FROM $menu_name WHERE {$prefix}_NAME = 'Other';"; } $result = $conn->query($query); $row = $result->fetch_array(); $str = $row[0]; if(isset($method[$menu_name])) { //check if it is an array if(is_array($method[$menu_name])) { //check if $str is in the array if(in_array($str, $method[$menu_name])) { //return, the element is displayed return true; } } //not array elseif($method[$menu_name] == $str) { return true; } } // finally hide the element since $str was not selected as one of the options echo "style=\"display:none\""; $conn->close(); } Yes the drop down menu works fine in the original script..... UNTIL i transfer these codes into other scripts I basically use the exact same codes, but somehow the menu is not doing the same thing when I click the "other" option as before in the original script, or in other word, no additional text box is prompted and basically no response what so ever By the way, i included all the necessary scripts. So what causes this problem? Any help is appreciated
  10. help plz ?
  11. Hay wut's happening forum? so i am currently working on a mailing list and its function is to send EVERY single user a notification email once an entry they are looking for on a database is available below is the mailing_list.php which sets up database connection and deals with the fields of the table: <?php include('view_function.php'); global $connect; $connect = mysqli_connect("localhost", "", "") or die(mysqli_error($connect)); $error = mysqli_error($connect); $db_select = mysqli_select_db($connect, ""); $select5 = "SELECT LS_CELL_TYPE FROM link_specificities INNER JOIN links ON link_specificities.LS_LINK = links.L_ID WHERE links.L_ID = $LinkID"; $get5 = mysqli_query($connect, $select5) or die(mysqli_error($connect)); while ($row5 = mysqli_fetch_array($get5)){ extract($row5); $cellType = $row5['LS_CELL_TYPE']; } $select6 = "SELECT CT_NAME FROM cell_type WHERE CT_ID = '$cellType'"; $get6 = mysqli_query($connect, $select6) or die(mysqli_error($connect)); $i = 0; while ($row6 = mysqli_fetch_array($get6)){ extract($row6); $query[$i] = $row6['CT_NAME']; $check = "select first_name, email from mailing_list WHERE query = '$query[$i]'"; $i++; echo $query; } update($check); ?> And below is the view_function.php that's included above: <?php function update($check){ global $query; global $connect; global $LinkID; $result = mysqli_query($connect, $check) or die(mysqli_error($connect)); while ($row3 = mysqli_fetch_array($result)){ extract($row3); $fname = $row3['first_name']; $email = $row3['email']; $to = "$fname <$email>"; $subject = "The query is updated."; $headers = "From: asdfasdfasdf"; $body = " Hello $fname,\r\n\nThis is to inform you that $query is updated, please go to this link to search for it:\r\n\nhttp:/asdfasdfasdfasdf/view/View.php?LinkID=$LinkID \r\n\nRegards,\r\n\"; if(send_email($to,$subject,$body,$headers)){ //there are no errors, return empty array $errors = array(); } else { $errors[] = "Server error, mail could not be sent."; } } } ?> As you can c in mailing_list.php, i echoed out $query, but it only echoed ONE result of that entire array so wut i am trying to do is to make a while loop with a counter in it, but still only one result shows up Basically, i want the $query to output all items in an array so that following SELECT statement can choose the item which matches the required query and send the users the notification email bout such particular query How should i fix it in order to do just that? Thx
  12. so i made further changes to mailing_list.php please take a look and gimme some feedback <?php global $connect; $connect = mysqli_connect("localhost", "asdfasdf", "asdfadf") or die(mysqli_error($connect)); $error = mysqli_error($connect); $db_select = mysqli_select_db($connect, wefdewfdswe"); $pro = $_POST['promoter_locus']; $check = "select mailing_list.id from mailing_list INNER JOIN promoter_locus on promoter_locus.PL_NAME = mailing_list.query"; $result = mysqli_query($connect, $check) or die(mysqli_error($connect)); if (mysqli_num_rows($result)==0){ continue; } else { while ($row = mysqli_fetch_array($result)){ extract($row); $id = $row['id']; } $sql = "select email from mailing_list where id = '$id'"; $query = $_POST['promoter_locus']; $result2 = mysqli_query($connect, $sql) or die(mysqli_error($connect)); while ($row2 = mysqli_fetch_array($result2)){ extract($row2); $email = $row2['email']; } $to = $email; $subject = "The query is updated"; $headers = "From: Cre-X-Mice Database Administrator"."X-Mailer: php"; $body = " Hello This is to inform you that $pro is updated, please go to this link to search for it: http://nagy.mshri.on.ca/Coop_Student/cr ... p_try3.php Regards, Cre-X-Mice Administrator."; if (mail($to, $subject, $body, $headers)){ echo("<p>Message sent!</p>"); } else {echo("<p>Message delivery failed</p>");} } ?> however when I run addEntry.php (which includes mailing_list.php) the following error comes up: Message delivery failed Warning: Cannot modify header information - headers already sent by (output started at /mnt/r0120/d33/s26/b02e3c4b/www/nagy.mshri.on.ca/Coop_Student/cre/addEntry/mailing_list.php:59) in /mnt/r0120/d33/s26/b02e3c4b/www/nagy.mshri.on.ca/Coop_Student/cre/addEntry/StepOne_3.php on line 304 which points to this: if($_SESSION['step'] == 3){ //this means we already did step two and //clicked edit step one on last page header("Location: StepThree_2.php"); exit; } else { include('mailing_list.php'); //this is to check that step one has been completed once we go to step 2 $_SESSION['step'] = 2; header("Location: StepTwo_2.php"); exit; } so my questions are: 1. What's wrong with the header 2. Apparently there aren't any major mistakes in SQL part of mailing_list.php but somehow it echoes out Message delivery failed PLZZZZZZ HELP :confused: :confused:
  13. Help plz?????
  14. so my project is to create a update mailing list to notify the users through email about the entries that they have been searching for, once such entries are updated. Let me explain it bit by bit... First John (for example) searches sthg on database and can't find anything. So John subscribes for the update mailing list as mentioned above. This mailing list has table (as in database) with a field "query", of coz along with user's email and name. On the other hand, other users like Peter submits his entry into the database, and if such entry MATCHES the "query" in the mailing list that Peter requested, he would receive an email informing him like hay the stuff u looking for is in database now So my idea is to connect the Add Entry script with the mailing list, so once the Peter put new entries John could receive notification right away Plz help!!
  15. <?php //Database Credentials include "../db_fns.php"; session_start(); //Database connection $conn = db_connect_2(); if (isset($_SESSION['link']) AND !isset($_POST['Submit'])){ //retrieve link if(is_string($_SESSION['link'])){ $link = unserialize($_SESSION['link']); } else { $link = $_SESSION['link']; } if($link){ //basic stuff $_SESSION['transgene_type'] = (string)$link->tt_id; $_SESSION['promoter_locus'] = $link->promoter; $_SESSION['PromoLocusSynonyms'] = $link->pl_synonyms; $_SESSION['species'] = (string)$link->s_id; //genetic background //clear it just incase there are values since another time $_SESSION['genetic_bg'] = array(); $_SESSION['GeneticBGOtherTxt'] = ""; foreach($link->genetic_bg as $gbg){ //we check if it is a menu selected item or an item that is not in menu if((int)$gbg['GBG_IS_MENU']){ $_SESSION['genetic_bg'][] = $gbg['GBG_ID']; } else { //belongs in other if(empty($_SESSION['GeneticBGOtherTxt'])) { $_SESSION['GeneticBGOtherTxt'] .= $gbg['GBG_NAME']; } else { $_SESSION['GeneticBGOtherTxt'] .= ",".$gbg['GBG_NAME']; } } } $_POST = $_SESSION; }elseif (isset($_POST['Submit'])) { if(isset($_SESSION['link'])) { //we need to unserialize the link if(is_string($_SESSION['link'])){ $link = unserialize($_SESSION['link']); //unserialize() takes a single variable and converts it back into a php value } else { $link = $_SESSION['link']; } } //put $_POST variables into $_SESSION $_SESSION = $_POST + $_SESSION; unset($_SESSION['Submit']); // CHECK FOR ERRORS AFTER SUBMISSION $errors = array(); // Set array if (!$_POST['promoter_locus']) $errors[] = "Please specify a value for \"Promoter or Locus\"".$PromoLocus; if (!$_POST['transgene_type']) $errors[] = "Please specify a value for \"Transgene Type\""; if (!$_POST['inducible_systems'] && !$_POST['InducibleSystemsOther']) $errors[] = "Please specify an \"Inducibility\" value"; } if (count($errors) > 0 ) { $iferrors = "Yes"; } else { [size="4"][b][u] include ('mailing_list.php'); checkPromoter($_POST['promoter_locus'];[/u][/b][/size] //this is to check that step one has been completed once we go to step 2 $_SESSION['step'] = 2; header("Location: StepTwo_2.php"); exit; } } } else { session_trash_(); session_regenerate_id(true); } Note that this script is an excerpt and I make the lines that I put to be bold and underlined. This is the mailing_list.php <?php require('connection.php'); function checkPromoter ($_POST['promoter_locus']) { $check = "select id from mailing_list where query = '$_POST['promoter_locus']'"; $result = mysqli_query($connect, $check) or die(mysqli_error($connect)); if (mysqli_num_rows($result)==0){ continue; } else { $sql = "select email from mailing_list where query = '$_POST['promoter_locus']'"; $query = $_POST['promoter_locus']; $email = mysqli_query($connect, $sql) or die(mysqli_erro($connect)); $to = $email; $subject = "The query is updated"; $headers = "From: asdfasdf"; $body = " Hello This is to inform you that $query is updated, please go to this link to search for it: http://asdfasdf Regards, asdfasdf."; mail($to, $subject, $body, $headers); die(); } } So my questions are 1. Where should I place those bold lines in addEntry.php? I tried to run it but the result is a blank page... Also there's no email sending through to my test email 2. For the line function checkPromoter ($_POST['promoter_locus']), should I put variable like $promoter = $_POST['promoter_locus'] ? Cuz I ran that and the error is Parse error: syntax error, unexpected '[', expecting ')' 3. Can u guys plz help me fix up mailing_list.php? Thx for ur patience to read thru this and ANY HELP IS APPCRECIATED
×
×
  • 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.