Jump to content

SalientAnimal

Members
  • Posts

    366
  • Joined

  • Last visited

Everything posted by SalientAnimal

  1. Hi The difficult thing here is that we ahve no idea what your data looks like so can't even identify and common fields. Remember to ensure that you have a successful join you have to have at least one field that has some sort of unique identifier.
  2. I have all the validations in place that insure that setain information is captured on the form, however the problem is not the validation part but rather that at times cerain areas may NOT have any tasks to action. My database structure as an example is: IT_Access General_Access Userinfo General Access will only have to perform a taks when the user needs an access card as an example. However if the user is only updating their details they won't need a access card. In this example when completing the form I only want the entry to be written to the IT_Access and Userinfo tables, the General_Access should not have ay data written to it at all. Currently the reference number is being written to all table each time the form is submitted. Reason is I'm using the Reference number as the common field to join my tables at a later stage in my queries. By Trigger I basically mean that when I hit the form SUBMIT button, the data needs to be written to the individual tables as required and then at the same time to send an e-mail to the areas that need to action a request... So as in the above example... If General Access Administrators has no actions they should not recieve an e-mail, only IT Access and Userinfo Administrators should recieve and e-mail advising them of a task that needs to be completed. In the event that all Administrators have an action to complete they should all recieve and e-mail containign the reference number. Hope I'm making sense?
  3. Are you validating that the field has actually been filled in? I'm not the best at PHP myself, but if this is what you are trying to do I have found that it is easier to do a validation using javascript. Here is a sample of the javascript validation: function validateForm(formnamehere) { if(document.formnamehere.fieldnamehere.value) { alert("This is the alert message that will pop-up for an incomplete field."); document.formnamehere.fieldnamehere.focus(); return false; } The validation is then performed when clicking on submit using the following: <form id="formnamehere" name="formnamehere" method="post" action="" onSubmit="return validateForm(formnamehere);">
  4. Hi All.... I am in some desprate need of help. I have tried searching google for answers but just can't seem to find a solution that works. My problem is as follows: 1. I have a form that submits to multiple databases (Currently 4, but this number can become even more) WORKING 2. Each database has different action points (i.e. different users us and alter the information using an update form) WORKING 3. I need a "trigger" that will not only sumbit to the required database, but also send an e-mail to the parties that have an action to be performed. NOT WORKING I have no idea how to do this. 4. Even though there is no data, besides the reference number to be submitted to a particular database, it is still submitting a entry with only the randomly generated reference number. Is there a way to prevent this from happening? Thanks, Code to my current Submit Page <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("databasename", $con); $sql="INSERT INTO staff_churn (username ,reference ,champ ,churn_type ,effective_date ,department ,exit_department ,position ,contract_type) VALUES ('$_POST[username]' ,'$_POST[reference]_$_POST[lname]' ,'$_POST[fname] $_POST[lname]' ,'$_POST[churn_type]' ,'$_POST[effective_date]' ,'$_POST[department]' ,'$_POST[exit_department]' ,'$_POST[position]' ,'$_POST[contract_type]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $sql="INSERT INTO churn_access (reference ,access_card ) VALUES ('$_POST[reference]_$_POST[lname]' ,'$_POST[access_card]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $sql="INSERT INTO churn_drc (reference ,organogram ) VALUES ('$_POST[reference]_$_POST[lname]' ,'$_POST[direct_report]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $sql="INSERT INTO churn_it (reference ,champ_portal ,pc ,email ,phone ,lan ,g_folders ,h_folders ,distribution ,clarify_access) VALUES ('$_POST[reference]_$_POST[lname]' ,'$_POST[champ_portal]' ,'$_POST[pc]' ,'$_POST[email]' ,'$_POST[phone]' ,'$_POST[lan]' ,'$_POST[g_drive] $_POST[drive_a] $_POST[drive_c] $_POST[drive_e] $_POST[drive_g]' ,'$_POST[h_drive] $_POST[drive_b] $_POST[drive_d] $_POST[drive_f] $_POST[drive_h]' ,'List: $_POST[list_a] $_POST[list_b] $_POST[list_c] $_POST[list_d] $_POST[list_e] $_POST[list_f] $_POST[list_g] $_POST[list_h]' ,'Clarify Level: $_POST[clarify_access]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else { echo "<b><font color='white' face='segoe' size='2'>Your reference number is: $_POST[reference]_$_POST[lname]. Please record this number for future reference.</b>"; include "redirect_churn.html"; } mysql_close($con) ?> Code to the Post Function <form id="churnform" name="churnform" method="post" action="submit_churn.php" onSubmit="return validateForm(churnform);">
  5. Ok so I have managed to get my other problem working, but now I'm sitting with another. I am access a database to display entries captured so that you can then search and update individual records. This is working fine, however there is a small problem: The original submit process the information is captured to multiple tables in a particular database. When the information is then displayed on my page, I am getting duplicate results. Can anyone tell me why? Here is my code to show the information from the two tables: <?php session_start(); $conn = @mysql_connect("localhost","root","password") or exit("Could not establish a connection to MySQL Server. mysql_error()"); $select = @mysql_select_db("database",$conn) or exit("Could not select the appropriate database for this operation. mysql_error()"); if(isset($_COOKIE['ID_my_site'])) { $username = $_COOKIE['ID_my_site']; $name = $_COOKIE['ID_my_name']; $pass = $_COOKIE['Key_my_site']; $check = @mysql_query("SELECT * FROM userinfo WHERE username='$username'") or die("Failed to execute SQL Statement."); while($info = mysql_fetch_array($check)) { if($pass != $info['password']) { header("Location: login.php"); } else{ } } } else{ header("Location:login.php"); } include "navigation/backoffice.html"; ?> <title> © 2012 Churn Management </title> <script type="text/javascript"> var count = 0; var delay = 250; var text = "© 2012 Churn Management "; function scroll () { document.title = text.substring(count, text.length) + text.substring (0, count) if (count < text.length) { count ++; } else { count = 1; } setTimeout ("scroll()", delay); } scroll(); </script> <LINK REL="SHORTCUT ICON" HREF="favicon.ico"> <script language="javascript" src="js/admin.js"></script> <style type="text/css"> <!-- #form1 table tr td { color: #FFF; } #form1 table tr td { font-family: "Segoe Print", Tahoma, "Segoe UI"; font-size: 13px; } #form1 p { color: #FFF; font-size: 36px; font-weight: bold; text-align: center; font-family: "Segoe Print", Tahoma, "Segoe UI"; } --> </style> </head> <link rel="stylesheet" type="text/css" href="http://10.249.135.30"/> </head> <html> <table width="100%" border="0"> <tr> <td width="20%"></td> <td width="80%"><p align="justify"></p></td> </tr> <tr> <p>Input the Reference, to make sure we have the right one:<br> (Quick Search Listed Below)</p> <form method=post action="amend_churn_it.php"> <input type="text" name="record" size="50"> <br> <img src="images/find.png" alt="find"> <input type="submit" name="search" value="Search"> </form> <?php // Show simple format of the records so person can choose the reference name/number // this is then passed to the next page, for all details $con = mysql_connect("localhost" ,"root" ,"password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("database", $con); $sql="SELECT staff_churn.reference , staff_churn.champ , staff_churn.churn_type , staff_churn_it.champ_portal , staff_churn_it.pc , staff_churn_it.email , staff_churn_it.phone , staff_churn_it.lan , staff_churn_it.g_folders , staff_churn_it.h_folders , staff_churn_it.distribution , staff_churn_it.clarify_access FROM staff_churn_it LEFT JOIN database.staff_churn ON database.staff_churn_it.reference = database.staff_churn.reference WHERE champ_portal = 'Champ Portal' OR pc = 'Laptop' OR pc like 'Desktop%' OR email = 'E-Mail' OR phone = 'Soft Phone' OR phone like 'Hard Phone%' OR lan = 'LAN' OR g_folders like 'G%' OR h_folders like 'H%' OR distribution like 'List%' OR clarify_access like 'Clarify Level%' "; $result = mysql_query( $sql) or die(" - Failed More Information:<br><pre>$sql</pre><br>Error: " . mysql_error()); $num_rows = mysql_num_rows($result); if ($myrow = mysql_fetch_array($result)) { echo "<br><p>Outstanding Churn Management<BR></p><br>"; echo "<table border=1>\n"; echo "<tr> <td bgcolor=#444444 align=center><p><b>Reference</p></td> <td bgcolor=#444444 align=center><p><b>Champ</p></td> <td bgcolor=#444444 align=center><p><b>Churn Type</p></td> <td bgcolor=#444444 align=center><p><b>Champ Portal</p></td> <td bgcolor=#444444 align=center><p><b>PC Requirements</p></td> <td bgcolor=#444444 align=center><p><b>E-Mail</p></td> <td bgcolor=#444444 align=center><p><b>Phone</p></td> <td bgcolor=#444444 align=center><p><b>LAN</p></td> <td bgcolor=#444444 align=center><p><b>G:\ Drive</p></td> <td bgcolor=#444444 align=center><p><b>H:\ Drive</p></td> <td bgcolor=#444444 align=center><p><b>Distribution List</p></td> <td bgcolor=#444444 align=center><p><b>Clarify Access</p></td> </tr>\n"; do { printf("<tr> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> <td><p>%s</p></td> </tr>\n" ,$myrow["reference"] ,$myrow["champ"] ,$myrow["churn_type"] ,$myrow["champ_portal"] ,$myrow["pc"] ,$myrow["email"] ,$myrow["phone"] ,$myrow["lan"] ,$myrow["g_folders"] ,$myrow["h_folders"] ,$myrow["distribution"] ,$myrow["clarify_access"] ); } while ($myrow = mysql_fetch_array($result)); echo "</table>\n"; } else { echo "$ref There are currently no pending actions"; } mysql_free_result($result); mysql_close($con); ?></html>
  6. Hi there, I tried updating my query to if(!mysql_query($sql, $con) { die("Error: ".mysql_error(); } else { echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; include "/submit/redirect_churn.html"; } But still I get the white screen when submitting the query. The redirect works perfectly when I am only submitting to one database so I know that the include "/submit/redirect_churn.html"; part is working correctly. Here is the full code: <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("databasename", $con); $sql="INSERT INTO staff_churn (username ,reference ,champ ,churn_type ,effective_date ,department ,exit_department ,position ,contract_type) VALUES ('$_POST[username]' ,'$_POST[reference]' ,'$_POST[fname]' ,'$_POST[churn_type]' ,'$_POST[effective_date]' ,'$_POST[department]' ,'$_POST[exit_department]' ,'$_POST[position]' ,'$_POST[contract_type]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; $sql="INSERT INTO staff_churn_access (reference ,access_card ,champ_portal ,desktop ,email ,hard_phone ,lan ,laptop ,soft_phone ,g_drive ,g_folders ,h_drive ,h_folders ,distribution ,clarify_access) VALUES ('$_POST[reference]' ,'$_POST[access_card]' ,'$_POST[champ_portal]' ,'$_POST[desktop]' ,'$_POST[email]' ,'$_POST[hard_phone]' ,'$_POST[lan]' ,'$_POST[laptop]' ,'$_POST[soft_phone]' ,'$_POST[g_drive]' ,'$_POST[g_drive], $_POST[drive_a], $_POST[drive_c], $_POST[drive_e], $_POST[drive_g]' ,'$_POST[h_drive]' ,'$_POST[h_drive], $_POST[drive_b], $_POST[drive_d], $_POST[drive_f], $_POST[drive_h]' ,'$_POST[list_a], $_POST[list_b], $_POST[list_c], $_POST[list_d], $_POST[list_e], $_POST[list_f], $_POST[list_g], $_POST[list_h]' ,'$_POST[clarify_access]' )"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else { echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; include "/submit/redirect_churn.html"; } mysql_close($con) ?>
  7. Thanks for this... I got it to work. I now have a new problem though where the last part doesn't seem to be working. When the form data is submitted it just displays a blank white page instead of displaying the echo and then running the redirect_churn.html page. echo "<b><font color='white' face='segoe' size='2'>1 record added</b></font>"; include "submit/redirect_churn.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.