Jump to content

SalientAnimal

Members
  • Posts

    366
  • Joined

  • Last visited

Posts 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";
    

  8. Ok, so I now t the error message to display. I tried making some changes on line 72 as the error messages say, but still no resolve. Here is the error mesasge:

     

    Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Helsinki' for '2.0/no DST' instead in C:\Server\Apache2.2\htdocs\schedules\champ_search_september202.php on line 72 Parse error: syntax error, unexpected T_ELSE in C:\Server\Apache2.2\htdocs\schedules\champ_search_september202.php on line 72

     

    LINE 72 is the last part of the script where it refers to closing the table and the else should there be no results.

     

     

  9. Hi guys, thanks for the replies. I put the error check into my code but still I am getting an HTTP 500 error page. I know that the query works perfectly as if I run it without the table formatting it returns the desired results, however the information is displayed in such a way that it is difficult t understand.

     

    I'm still very new to php/mysql coding and thus I am aware that unfortunately my code is very very untidy and thus I appreciate all the help that everyone is providing me.

     

    It will be really awesome if you guiys could help me solve this mystry

  10. Hi Everyone,

     

    Well I have a bit of a problem... I have created a search page that I would like to return results from my MySQL database. However for some reason I can not get my page to display the results. Instead I am getting an error page. Below is the code I am using:

     

    In addition to this, should I wish for a user to be able to edit the returned results by clicking a link, how would I do that? :'( :'(

     

    <?php
    session_start();
    ?>
    <link rel="stylesheet" type="text/css" href="css/layout.css"/>
    <html>
    
    <?php
    $record = $_POST['record'];
    echo "<p>Search results for: $record<br><BR>";
    
    $host = "localhost";
    $login_name = "root";
    $password = "P@ssword";
    
    //Connecting to MYSQL
    MySQL_connect("$host","$login_name","$password");
    
    //Select the database we want to use
    mysql_select_db("schedules_2010") or die("Could not find database");
    
    $result = mysql_query("SELECT * 
    FROM schedule_september_2010 
    WHERE 
    champ LIKE '%$record%' ") 
    or die(mysql_error());  
    
    
    // keeps getting the next row until there are no more to get
    while($row = mysql_fetch_array( $result )) {
            // Print out the contents of each row
    echo "<br><p>Your Schedule<BR></p><br>";
    echo "<table border=1>\n";
    echo "<tr>
    <td bgcolor=#444444 align=center><p><b>Champ</p></td>
    <td bgcolor=#444444 align=center><p><b>Date</p></td>
    <td bgcolor=#444444 align=center><p><b>Start Time</p></td>
    <td bgcolor=#444444 align=center><p><b>End Time</p></td>
    <td bgcolor=#444444 align=center><p><b>Department</p></td>
    <td bgcolor=#444444 align=center><p><b>First Break</p></td>
    <td bgcolor=#444444 align=center><p><b>Second Break</p></td>
    <td bgcolor=#444444 align=center><p><b>Login ID</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>
    </tr>\n"
    , $row["champ"]
    , $row["date_time"]
    , $row["start_time"]
    , $row["end_time"]
    , $row["department"]
    , $row["first_break"]
    , $row["second_break"]
    , $row["login_id"]
    );
    
    } while ($row = mysql_fetch_array($result));
    echo "</table>\n";
    } else {
    echo "$champ No Records Found"; 
    } 
    
    mysql_free_result($result);
    mysql_close($con);
    ?>
    </html>
    

  11. Ok I think I might know what you are looking for from me. the problem is I do not know the code that I need to perform the function I want to be performed. I'm going to ry explain again what I am looking for by breaking it up into pieces and then I will include a small part of the code where I would think the function will occur.

     

    1. I have a Database which I will refer to as DB for the example

    2. In my DB I have two tables, namely USERINFO and FORM1

    3. The user logs into the site a session is set and the user is authenticated with the two pieces of code below:

     

    <?php
            session_start();
            if(!isset($_SESSION['user'])){
                    // the user is not logged in so let them login
    ?>

     

    <?php
            session_start();
            include "mysql.php";
            $_POST['username'] = addslashes($_POST['username']); // protects against SQL injection
            $_POST['password'] = addslashes($_POST['password']); // same ^^
            $password = ($_POST['password']); // encrypt the password
            $userrow = mysql_query("SELECT * FROM `userinfo` "
    	. "WHERE `username` = '" . $_POST['username'] . "'"
    	. " AND `password` = '" . $password . "';",$mysql);
            if(mysql_num_rows($userrow) != "1"){
    
    
                    // no rows found, wrong password or username
                    echo "<font color='red' face='Tahoma' size='2'><b>Please verify the username and/or password entered!</b></font>";
                    include "login.php";
            } else {
                    // 1 row found exactly, we have the user!
                    $_SESSION['user'] = $_POST['username'];
                    header("Location: home.php");
            }
    ?>

     

    4. Oce the user is logged in the will complete the form and submit the information. When submitting the form information I would like the update code that updates the FORM1 table to also gather information from the USERINFO table, i.e the auto incremeted ID which serves as a unique identifier. This info along with the info submitted via the form needs to be populated into FORM1 table. Below is my current code for the form, but it is not populating the ID from the USERINFO table

     

    
    $sql="INSERT INTO FORM1
    (id
    ,customer_name
    ,customer_email_address
    ,case_number
    ,msisdn
    ,call_reason
    ,province
    ,comments
    )
    
    VALUES
    ([b]NOT SURE HOW TO GATHER THIS PART FROM MY USERINFO TABLE[/b]
    '$_POST[customer_name]'
    ,'$_POST[customer_email_address]'
    ,'$_POST[case_number]'
    ,'$_POST[msisdn]'
    ,'$_POST[call_reason]'
    ,'$_POST[province]'
    ,'$_POST[comments]')";
    
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "<b><font color='red' face='segoe' size='2'>1 record added</b></font>";
    include "technical_support_tracker.php";
    
    mysql_close($con)
    
    ?> 

     

    I have search everywhere for a solution to this, but have had no luck, please can you try and assist me here as this is quite urgent. Thanks for you patience with me on this. I am still very new to PHP and everything I have done here I have taught myself using google.

     

    I almost forgot tis part, hre is my table structure of the two tables as well as the server info:

     

    -- phpMyAdmin SQL Dump -- version 3.3.2-- http://www.phpmyadmin.net

    Generation Time: Jun 14, 2010 at 07:58 AM -- Server version: 5.1.46

    --

    PHP Version: 5.3.2

    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

     

    Table structure for table `USERINFO`

     

    CREATE TABLE IF NOT EXISTS `userinfo` (`id` mediumint(50) NOT NULL AUTO_INCREMENT

    ,  `username` varchar(60) NOT NULL

    ,  `password` varchar(60) NOT NULL

    ,  `name` text NOT NULL

    , `surname` text NOT NULL

    ,  `email_address` varchar(100) NOT NULL

    ,  `department` varchar(100) NOT NULL

    ,  PRIMARY KEY (`id`)

    ,  UNIQUE KEY `id` (`id`,`username`,`email_address`)

    ,  UNIQUE KEY `e-mail` (`email_address`)

    ,  UNIQUE KEY `username` (`username`)

     

     

    Table structure for table `FORM1`

     

    CREATE TABLE IF NOT EXISTS `FORM1`

    (  `id` varchar(50) NOT NULL

    ,  `date_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP

    ,  `customer_name` varchar(100) NOT NULL

    ,  `customer_email_address` varchar(100) NOT NULL

    ,  `case_number` int(50) NOT NULL

    ,  `msisdn` int(10) NOT NULL

    ,  `call_reason` varchar(50) NOT NULL

    ,  `province` varchar(50) DEFAULT NULL

    ,  `comments` varchar(2500) DEFAULT NULL)

     

     

  12. Ok hope this is what you are looking for. Here is the code to 6 Pages namely my index page which really has no other function that to reroute the user to the Logn screen if they are not logged in or to the home screen if they are logged in. The second page is the login screen, and the third is the  Authoisation script. Once authorised the suer is taken to the home Home Screen, from the home screen the user will select a depart for which they will log a query, I have only included one as all the other pages are the same. And then the script that writes the data to the database.

     

    <!-- INDEX FILE WHICH THEN AUTOMATICALLY ROUTES TO THE LOGIN/HOME PAGE -->
    
    <?php
    session_start(); // start the session
    if(!isset($_SESSION['user'])){
        // check if the user is logged in
        // the user is not logged in
        header("Location: login.php"); // take him/her to the login page
    } else {
        
    header("Location: home.php"); // else take im/her home
    
    }
    ?>
    
    
    
    <?php
            session_start();
            if(!isset($_SESSION['user'])){
                    // the user is not logged in so let them login
    ?>
    
    
    
    <!-- LOGIN FILE WHICH LOGS THE USER INTO THE SITE -->
    
    <html>
    <head>
    <title>© 2010  - CUSTOMER SERVICES LOGIN</title>
    
    <script type="text/javascript">
    var count = 0;
    var delay = 250;
    var text = "© 2010  - CUSTOMER SERVICES LOGIN";
    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">
    </head>
    <link rel="stylesheet" type="text/css" href="layout_cslogin.css"/>
    <body>
    
    <center>
    <div id="bgTopDiv"> 
    <table width="100%" border="0">
    <form name="form" method="post" action="auth.php">
      <tr>
        <td width="166"><img src="images/logo.gif" width="165" height="84" alt=" Logo">
        </td>
        <td colspan="3"><h1> CUSTOMER SERVICES</h1>    </td>
        </tr>
      <tr>
        <td height="197" colspan="2"> </td>
        <td width="15%"> </td>
        <td width="43%"> </td>
      </tr>
      <tr>
        <td colspan="2"> </td>
        <td>
          <p>Username:</p>
        </td>
    
    
    
        <td><input name="username" type="text" id="username" class="textfield"></td>
      </tr>
      <tr>
        <td colspan="2"> </td>
        <td>
          <p>Password:</p>
        </td>
    
    
    
        <td><input name="password" type="password" id="password" class="textfield"></td>
      </tr>
      <tr>
        <td height="46" colspan="2"> </td>
        <td> </td>
        <td><input type="submit" name="Submit" value="→ Login"></td>
      </tr>
      <tr>
        <td height="36" colspan="2"> </td>
        <td> </td>
        <td><a href="user_creation.php">Register New User</a></td>
      </tr>
      <tr>
        <td height="176" colspan="2"> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    </form>
    </center>
    </div>
    </html>
    
    <?php
            } else {
                    // strange, user already logged in, take them to the home page
                    header("Location: index.php");
            }
    ?>
    
    <!-- AUTH PAGE WHICH AUTHORISES THE USERS LOGIN DETAILS -->
    
    <?php
            session_start();
            include "mysql.php";
            $_POST['username'] = addslashes($_POST['username']); // protects against SQL injection
            $_POST['password'] = addslashes($_POST['password']); // same ^^
            $password = ($_POST['password']); // encrypt the password
            $userrow = mysql_query("SELECT * FROM `userinfo` "
    . "WHERE `username` = '" . $_POST['username'] . "'"
    . " AND `password` = '" . $password . "';",$mysql);
            if(mysql_num_rows($userrow) != "1"){
                    // no rows found, wrong password or username
                    echo "<font color='red' face='Tahoma' size='2'><b>Please verify the username and/or password entered!</b></font>";
                    include "login.php";
            } else {
                    // 1 row found exactly, we have the user!
                    $_SESSION['user'] = $_POST['username'];
                    header("Location: home.php");
            }
    ?>
    
    
    
    <!-- USER IS ROUTED TO INDEX PAGE ONCE THEY ARE LOGGED IN -->
    
    <html>
    <head>
    <title>CUSTOMER SERVICES OPERATIONS - HOME MENU</title>
        <LINK REL="SHORTCUT ICON" HREF="favicon.ico">
        <script type="text/javascript">
    var count = 0;
    var delay = 250;
    var text = "©  CS OPERATIONS - HOME MENU                               ";
    function scroll () {
      document.title = text.substring(count, text.length) + text.substring (0, count)
      if (count < text.length) {
        count ++;
      } else {
        count = 1;
      }
      setTimeout ("scroll(1)", delay);
    }
    scroll();
    </script>
        <script src="js/mmenu.js" type="text/javascript"></script>
    <script src="js/menuItems.js" type="text/javascript"></script>
    </head>
    
    <link rel="stylesheet" type="text/css" href="css/layout_home.css"/>
    <table width="200" border="0">
    <tr>
        <td></td>
    <table >
    </tr>
    </table>
    <br>
        <body></body>
    
    
    </body>
    </html>
    
    <!-- USER NAVIGATES TO REQUIRED PAGE - ASSUME PAGE BELOW IS SELECTED TO LOG REQUEST -->
    <!-- WHEN SUBMITTING THE PAGE BELOW I WANT IT TO RECORD THE USRE ID FROM THE USERINFO TABLE INTO THE TECHNICAL_SUPPORT_TRACKER TABLE SO AS TO TRACK WHICH USER HAS SUBMITTED WHICH REQUEST -->
    
    <title> © 2010  - TECHNICAL SUPPORT</title>
    <script type="text/javascript">
    var count = 0;
    var delay = 250;
    var text = " 2010  - TECHNICAL SUPPORT                                 ";
    function scroll () {
      document.title = text.substring(count, text.length) + text.substring (0, count)
      if (count < text.length) {
        count ++;
      } else {
        count = 1;
      }
      setTimeout ("scroll(1)", delay);
    }
    scroll();
    </script>
    <LINK REL="SHORTCUT ICON" HREF="favicon.ico">
    
    <script language="javascript" src="js/technical_support_list.js"></script>
    <script src="js/mmenu.js" type="text/javascript"></script>
    <script src="js/menuItems.js" type="text/javascript"></script>
    <script type="text/javascript" language="JavaScript">
    var FormName = "form1";
    
    var RequiredFields = "customer_name, customer_email_address, case_number, msisdn, call_reason";
    
    function ValidateRequiredFields()
    {
    var FieldList = RequiredFields.split(",")
    var BadList = new Array();
    for(var i = 0; i < FieldList.length; i++) {
    var s = eval('document.' + FormName + '.' + FieldList[i] + '.value');
    s = StripSpacesFromEnds(s);
    if(s.length < 1) { BadList.push(FieldList[i]); }
    }
    if(BadList.length < 1) { return true; }
    var ess = new String();
    if(BadList.length > 1) { ess = 's'; }
    var message = new String('\n\nYou have not completed the following field' + ess + ' :\n');
    for(var i = 0; i < BadList.length; i++) { message += '\n' + BadList[i]; }
    alert(message);
    return false;
    }
    
    function StripSpacesFromEnds(s)
    {
    while((s.indexOf(' ',0) == 0) && (s.length> 1)) {
    s = s.substring(1,s.length);
    }
    while((s.lastIndexOf(' ') == (s.length - 1)) && (s.length> 1)) {
    s = s.substring(0,(s.length - 1));
    }
    if((s.indexOf(' ',0) == 0) && (s.length == 1)) { s = ''; }
    return s;
    }
    // -->
    </script>
    
    
    
    <style type="text/css">
    
    -->
    </style>
    </head>
    <link rel="stylesheet" type="text/css" href="css/layout_technical_support.css"/>
    <body>
    <form id="form1" name="form1" method="post" action="technicalsupportupdate.php" onsubmit="return ValidateRequiredFields();">
    <table width="100%" border="0">
      <tr>
        <td width="20%"><img src="images/logo.gif" alt=" Logo"align="left" /></td>
        <td width="80%"><p align="justify"> CALL TRACKER  TECHNICAL SUPPORT</p></td>
      </tr>
      <tr>
        <td height="449"> </td>
        <td><table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Customer Name :</strong></td>
            <td><input type="text" name="customer_name" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>E-Mail Address :</strong></td>
            <td><input type="text" name="customer_email_address" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Case Number :</strong></td>
            <td><input type="text" name="case_number" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>MSISDN :</strong></td>
            <td><input type="text" name="msisdn" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Call Reason :</strong></td>
            <td width="65%" align="left" valign="middle"><select name="call_reason" id="call_reason">
              <option value="">Select the Call Reason</option>
              <option value="ATM Recharges">ATM Recharges</option>
              <option value="Barrings - International Calls/Roaming">Barrings - International Calls/Roaming</option>
              <option value="Barrings (GPRS, Outgoing Calls, Outgoing SMS)">Barrings (GPRS, Outgoing Calls, Outgoing SMS)</option>
              <option value="Barrings New Activation (Rica)">Barrings New Activation (Rica)</option>
              <option value="IN Lock">IN Lock</option>
              <option value="Manual GPRS Settings">Manual GPRS Settings</option>
              <option value="Manual MMS Settings ">Manual MMS Settings </option>
              <option value="MNP">MNP</option>
              <option value="Modem Dial-Up Settings">Modem Dial-Up Settings</option>
              <option value="Network (Cannot Connect to Network)">Network (Cannot Connect to Network)</option>
              <option value="Network No Reception (Signal Fault) ">Network No Reception (Signal Fault) </option>
              <option value="Phone Email Setup ">Phone Email Setup </option>
              <option value="SMS ">SMS </option>
              <option value="Voicemail Setup ">Voicemail Setup </option>
            </select></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Province :</strong></td>
            <td width="65%" align="left" valign="middle"><select name="province" id="province">
              <option value="">Select the Province</option>
              <option value="Eastern Cape">Eastern Cape</option>
              <option value="Gauteng">Gauteng</option>
              <option value="Kwa-Zulu Natal">Kwa-Zulu Natal</option>
              <option value="Limpopo">Limpopo</option>
              <option value="Mpumalanga">Mpumalanga</option>
              <option value="North West">North West</option>
              <option value="Northern Cape">Northern Cape</option>
              <option value="Polokwane">Polokwane</option>
              <option value="Western Cape">Western Cape</option>
              <option value="Other">Other</option>
            </select></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Comments :</strong></td>
            <td><textarea rows ="5" cols="30" name="comments">
    	</textarea></td>
          </tr>
          <tr>
            <td>
              <p>
              <input type="reset" value="Reset Form">
              </p></td>
              <td>
              <p>
              <input type="Submit" value="Submit">
              </p></td>
          </tr>
          <tr>
    
          </tr>
        </table></td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    
    <!-- SCRIPT THAT WRITES THE CAPTURED DATA TO THE DATABASE -->
    
    <?php
    $con = mysql_connect("localhost"
    ,"root"
    ,"password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("csops", $con);
    
    $sql="INSERT INTO technical_support_tracker 
    (customer_name
    ,customer_email_address
    ,case_number
    ,msisdn
    ,call_reason
    ,province
    ,comments
    )
    
    VALUES
    ('$_POST[customer_name]'
    ,'$_POST[customer_email_address]'
    ,'$_POST[case_number]'
    ,'$_POST[msisdn]'
    ,'$_POST[call_reason]'
    ,'$_POST[province]'
    ,'$_POST[comments]')";
    
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "<b><font color='red' face='segoe' size='2'>1 record added</b></font>";
    include "technical_support_tracker.php";
    
    mysql_close($con)
    
    ?> 
    
    

  13. Please see my code below:

     

    <?php
            session_start();
            if(!isset($_SESSION['user'])){
                    // the user is not logged in so let them login
    ?>
    
    
    <!-- <form method='POST' action='auth.php'>
    Username: 
    <input type='text' name='username' maxLength='16' length='16'><br/>
    Password: 
    <input type='password' name='password' length='16'><br/>
    <input type='submit' value='Login'>
    </form><p><a href='user_creation.php'>Signup
    </a></p> -->
    
    
    
    
    <html>
    <head>
    <title> - CUSTOMER SERVICES LOGIN</title>
    
    <script type="text/javascript">
    var count = 0;
    var delay = 250;
    var text = " - CUSTOMER SERVICES LOGIN              ";
    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">
    </head>
    <link rel="stylesheet" type="text/css" href="css/layout_cslogin.css"/>
    <body>
    
    <center>
    <div id="bgTopDiv"> 
    <table width="100%" border="0" background="images/background.png">
      <tr>
        <td width="166"><img src="images/logo.gif" width="165" height="84" alt="Virgin Mobile Logo">
        </td>
        <td colspan="3"><h1> CUSTOMER SERVICES</h1>    </td>
        </tr>
      <tr>
        <td height="197" colspan="2"> </td>
        <td width="15%"> </td>
        <td width="43%"> </td>
      </tr>
      <tr>
        <td colspan="2"> </td>
        <td>
          <p>Username:</p>
        </td>
    
    
    
        <td><input name="username" type="text" id="username" class="textfield"></td>
      </tr>
      <tr>
        <td colspan="2"> </td>
        <td>
          <p>Password:</p>
        </td>
    
    
    
        <td><input name="password" type="password" id="password" class="textfield"></td>
      </tr>
      <tr>
        <td height="46" colspan="2"> </td>
        <td> </td>
        <td><input type="submit" name="Submit" value="→ Login"></td>
      </tr>
      <tr>
        <td height="36" colspan="2"> </td>
        <td> </td>
        <td><a href="user_creation.php">Register New User</a></td>
      </tr>
    </table>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    <p> </p>
    </div>
    </center>
    
    </html>
    
    <?php
            } else {
                    // strange, user already logged in, take them to the home page
                    header("Location: index.php");
            }
    ?>
    

     

    <?php
            session_start();
            include "mysql.php";
            $_POST['username'] = addslashes($_POST['username']); // protects against SQL injection
            $_POST['password'] = addslashes($_POST['password']); // same ^^
            $password = ($_POST['password']); // encrypt the password
            $userrow = mysql_query("SELECT * FROM `userinfo` "
    . "WHERE `username` = '" . $_POST['username'] . "'"
    . " AND `password` = '" . $password . "';",$mysql);
            if(mysql_num_rows($userrow) != "1"){
                    // no rows found, wrong password or username
                    echo "<font color='red' face='Tahoma' size='2'><b>Please verify the username and/or password entered!</b></font>";
                    include "login.php";
            } else {
                    // 1 row found exactly, we have the user!
                    $_SESSION['user'] = $_POST['username'];
                    header("Location: home.php");
            }
    ?>
    

     

    <!--<php
        $colors = $_POST['colors'];
        $self = $_SERVER['PHP_SELF'];
        $dbh = mysql_connect('dbhost', 'dbuser', 'dbpass') or
    die(mysql_error());
        mysql_select_db('dbname') or die(mysql_error());
    ?>
    -->
    
    
    
    <title> © TECHNICAL SUPPORT</title>
    <script type="text/javascript">
    var count = 0;
    var delay = 250;
    var text = " 2010  MOBILE - TECHNICAL SUPPORT                                 ";
    function scroll () {
      document.title = text.substring(count, text.length) + text.substring (0, count)
      if (count < text.length) {
        count ++;
      } else {
        count = 1;
      }
      setTimeout ("scroll(1)", delay);
    }
    scroll();
    </script>
    <LINK REL="SHORTCUT ICON" HREF="favicon.ico">
    
    <script language="javascript" src="js/technical_support_list.js"></script>
    <script src="js/mmenu.js" type="text/javascript"></script>
    <script src="js/menuItems.js" type="text/javascript"></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="css/layout_technical_support.css"/>
    <body>
    <form id="form1" name="form1" method="post" action="technicalsupportupdate.php" onSubmit="return ValidateForm(); true">
    <table width="100%" border="0">
      <tr>
        <td width="20%"><img src="images/mobilelogo.gif" alt=" Mobile Logo"align="left" /></td>
        <td width="80%"><p align="justify"> MOBILE CALL TRACKER  TECHNICAL SUPPORT</p></td>
      </tr>
      <tr>
        <td height="449"> </td>
        <td><table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Customer Name :</strong></td>
            <td><input type="text" name="customer_name" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>E-Mail Address :</strong></td>
            <td><input type="text" name="customer_email_address" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Case Number :</strong></td>
            <td><input type="text" name="case_number" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>MSISDN :</strong></td>
            <td><input type="text" name="msisdn" align="left" valign="middle"></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Call Reason :</strong></td>
            <td width="65%" align="left" valign="middle"><select name="call_reason" id="call_reason">
              <option value="">Select the Call Reason</option>
              <option value="ATM Recharges">ATM Recharges</option>
              <option value="Barrings - International Calls/Roaming">Barrings - International Calls/Roaming</option>
              <option value="Barrings (GPRS, Outgoing Calls, Outgoing SMS)">Barrings (GPRS, Outgoing Calls, Outgoing SMS)</option>
              <option value="Barrings New Activation (Rica)">Barrings New Activation (Rica)</option>
              <option value="IN Lock">IN Lock</option>
              <option value="Manual GPRS Settings">Manual GPRS Settings</option>
              <option value="Manual MMS Settings ">Manual MMS Settings </option>
              <option value="MNP">MNP</option>
              <option value="Modem Dial-Up Settings">Modem Dial-Up Settings</option>
              <option value="Network (Cannot Connect to Network)">Network (Cannot Connect to Network)</option>
              <option value="Network No Reception (Signal Fault) ">Network No Reception (Signal Fault) </option>
              <option value="Phone Email Setup ">Phone Email Setup </option>
              <option value="SMS ">SMS </option>
              <option value="Voicemail Setup ">Voicemail Setup </option>
            </select></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Province :</strong></td>
            <td width="65%" align="left" valign="middle"><select name="province" id="province">
              <option value="">Select the Province</option>
              <option value="Eastern Cape">Eastern Cape</option>
              <option value="Gauteng">Gauteng</option>
              <option value="Kwa-Zulu Natal">Kwa-Zulu Natal</option>
              <option value="Limpopo">Limpopo</option>
              <option value="Mpumalanga">Mpumalanga</option>
              <option value="North West">North West</option>
              <option value="Northern Cape">Northern Cape</option>
              <option value="Polokwane">Polokwane</option>
              <option value="Western Cape">Western Cape</option>
              <option value="Other">Other</option>
            </select></td>
          </tr>
          <tr>
            <td width="35%" align="right" valign="middle"><strong>Comments :</strong></td>
            <td><textarea rows ="5" cols="30" name="comments">
    	</textarea></td>
          </tr>
          <tr>
            <td>
              <p>
              <input type="reset" value="Reset Form">
              </p></td>
              <td>
              <p>
              <input type="Submit" value="Submit">
              </p></td>
          </tr>
          <tr>
    
          </tr>
        </table></td>
      </tr>
    </table>
    </form>
    </body>
    </html>
    

  14. Hi guys,

     

    My question here is pretty simple. I am struggling to get a PHP page to Query my MySQL data base and to display this on the page in a table. In addition to this, I would like to be able to edit the data in my table from the returned results.

     

    i.e Next to each result row ther should be an edit link, when clicking the link it opens the data and allows you to edit it and then submitting it to the data base to edit the entry.

     

    Another Question I have is how to capture an image, i.e scanned in document to a MySQL database. I would like to create a form that captures a name, surname, email address,  and finally the image or any other file format.

     

    I have started working on the code form my second question, but do not have now to include on this post. Will update that ASAP.

     

    Thanks

    Guys

  15. Hi Guys,

     

    I am rather new to PHP scripting and using it to capture information to a MySQL database. I have created a web based system that asks users to login and then capture certain informtion. However I have having trouble getting all the informaion to write to the databases as required.

     

    1. I would like all my pages to be part of a session login i.e. a user needs to be logged in to access a page. But I am unsure of how to link this to the userinfo table I created.

    2. When submitting a form I would like the id field from the userinfo table to be populated into the form table in this example to the customer_services_tracker table.

     

    Please see below my code for the two php files

     

     

     

    [attachment deleted by admin]

×
×
  • 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.