Jump to content

cainam29

Members
  • Posts

    75
  • Joined

  • Last visited

Everything posted by cainam29

  1. Thanks Barand. That actually did the trick, I never had thought that there was an All vs ALL issue in the code.
  2. Thanks Barand, So here would be the updated code to fetch data, <?php$servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDBPDO"; // check data before use it and convert from string to expected type, use try, not like here: $status = $_POST['status']; $date = $_POST['date']; $date1 = $_POST['date1']; // use valid data to select rows try { //1. connect to MySQL database $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); //2. set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //3. create query string $sql = 'SELECT column1, column2, status FROM tracker WHERE 1=1'; if ($status != 'ALL') $sql .= ' AND status = :st'; $sql .= ' AND scheduled_start_date BETWEEN :d1 AND :d2'; //4. prepare statement from query string $stmt = $conn->prepare($sql); //5. bind optional parameters if ($status != 'ALL') $stmt->bindParam(':st', $status); //6. bind parameters $stmt->bindParam(':d1', $date); $stmt->bindParam(':d2', $date1); //7. execute statement $stmt->execute(); //8. returns an array containing all of the result set rows $result = $stmt->fetchAll(PDO::FETCH_ASSOC); //get count of rows $numrow = count($result); //print array - there is many solution to print array, //to debug you can do: //print_r($result); } catch(PDOException $e) { echo "Error: " . $e->getMessage(); } $conn = null; if($numrow == 0) echo "No results found."; else echo "Count: $numrow</br>"; { echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th align='center'><strong>Column1</strong></th> <th align='center'><strong>Column2</strong></th> <th align='center'><strong>Status</strong></th> </tr>"; foreach ($result as $row => $info) { echo "<form action='crqretrieve_status_test1.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['column1'] . "<input type=hidden name=column1 value=" . $info['column1'] . " </td>"; echo "<td align='center'>" . $info['column2'] . "<input type=hidden name=column2 value=" . $info['column2'] . " </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . " </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; ?> And Select Options 1-4 works when selected individually but not when selecting ALL (which means selecting all options at the same time), <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> I tried to print the result and I am just getting Status select options 1-4 must be showing in the table If I filter Status to ALL but I am not getting anything. I wonder where the issue is now.
  3. Thanks for the response mac_gyver. So here's what I tried, I updated my code to fetch data to below, <?php$servername = "localhost"; $username = "username"; $password = "password"; $dbname = "myDBPDO"; // check data before use it and convert from string to expected type, use try, not like here: $status = $_POST['status']; $date = $_POST['date']; $date1 = $_POST['date1']; // use valid data to select rows try { $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //create query string $sql = 'SELECT column1, column2, status FROM tracker WHERE 1=1'; if ($status != 'ALL') $sql .= ' AND status = :st'; $sql .= ' AND scheduled_start_date BETWEEN :d1 AND :d2'; // prepare sql $stmt = $conn->prepare($sql); //bind parameters if ($status != 'ALL') $stmt->bindParam(':st', $status); $stmt->bindParam(':d1', $date); $stmt->bindParam(':d2', $date1); $stmt->execute(); //do some output $result = $stmt->fetchAll(); print_r($result); } catch(PDOException $e) { echo "Error: " . $e->getMessage(); } //to count if there are any results $numrow = mysql_num_rows($result); if($numrow == 0) { echo "No results found."; } else { echo "CRQ Count: $numrow"; } { echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th align='center'><strong>Column1</strong></th> <th align='center'><strong>Column2</strong></th> <th align='center'><strong>Status</strong></th> </tr>"; while($info = mysql_fetch_array($result)) { echo "<form action='retrieve_status.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['column1'] . "<input type=hidden name=column1 value=" . $info['column1'] . " </td>"; echo "<td align='center'>" . $info['column2'] . "<input type=hidden name=column2 value=" . $info['column2'] . " </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . " </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; include 'include/DB_Close.php'; $conn = null; ?> But I am getting the error below when I am selecting ALL, Line 69 refers to $numrow = mysql_num_rows($result); Line 98 refers to while($info = mysql_fetch_array($result)) And when i select any of the option I am getting the message, And the same error as selecting ALL, I kind of lost from here and do not know how to proceed anymore.
  4. I have seen a lot of demos or sort of the same questions with the Select All option. But what I want is to just have a drop down that will allow me to select All option and not showing the entire Select box. Individual Select option works but not when I tried to use ALL as an option. Here is my sample HTML: <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> From the code above I would want to filter the result using the All option. So this is the page is where I filter and show the results in a table, <script> $(document).ready(function(){ $("#results").show(); }); </script> <script type="text/javascript"> $(document).ready(function(){ $("#RetrieveList").on('click',function() { var status = $('#status').val(); var date = $('#Date').val(); var date1 = $('#Date1').val(); $.post('retrieve_status.php',{status:status, date:date, date1:date1}, function(data){ $("#results").html(data); }); return false; }); }); </script> <form id="form2" name="form2" method="post" action=""> <table width="941" border="0" align="center"> <tr> <th width="935" colspan="9" scope="col">Status: <select name="status" id="status" style="width: 224px;"> <option value="" selected="selected">Please select...</option> <option value="All">All</option> <option value="Option1">Option1</option> <option value="Option2">Option2</option> <option value="Option3">Option3</option> <option value="Option4">Option4</option> </select> Start Date:<input type="text" name="Date" id="Date" size="8"/> End Date:<input type="text" name="Date1" id="Date1" size="8"/> <input name="action" type="submit" id="RetrieveList" value="Retrieve List" /> </th> </tr> </table> </form> <div id="results"> </div> And this is how I fetch the data, <?php require 'include/DB_Open.php'; $status = $_POST['status']; $date = $_POST['date']; $date1 = $_POST['date1']; if ($_POST['status'] == 'ALL') { $sql_status = '1'; } else { $sql_status = "status = '".mysql_real_escape_string($_POST['status'])."'"; } $sql="SELECT column1, column2, status FROM tracker WHERE status = '" . $sql_status . "' AND scheduled_start_date BETWEEN '" . $date . "' AND '" . $date1 . "' ORDER BY scheduled_start_date"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo "CRQ Count: $numrow"; } { echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th align='center'><strong>Column1</strong></th> <th align='center'><strong>Column2</strong></th> <th align='center'><strong>Status</strong></th> </tr>"; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve_status.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['column1'] . "<input type=hidden name=column1 value=" . $info['column1'] . " </td>"; echo "<td align='center'>" . $info['column2'] . "<input type=hidden name=column2 value=" . $info['column2'] . " </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . " </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; include 'include/DB_Close.php'; ?>
  5. need help java script below not working, its supposed to allow only the word "Resolved" and "Re-assigned" in one of my text area, so if the user enter other values, the form will not be submitted... function checkAllowedWords(){ var allowedWords, textString, textArray, length, word; allowedWords=["Resolved","Re-assigned"]; textString= document.getElementById("$Status").value; //replace the "text-area-element-id" with your actual id for that textarea textArray=str.split(" "); //if comma separated values are provided use "," instead of " " length = textArray.length; word = null; for (var i = 0; i < length; i++) { word = textArray[i]; if (allowedWords.indexOf(word, 0) === -1) { //indexOf() returns the index of the first "word" value found in the "allowedWords" array, and returns -1 if the value was not found in array alert(word + " is not allowed! The accepted values are: " + allowedWords.toString()); //This will popup an alert message for your testing purposes, you can implement anything you wish here to let the user know what's going on } } }
  6. my code below works perfect in Mozilla and Chrome but not in IE8, when i select a Radio button in IE its showing other options for other Radio button, need help in fixing the issue in IE8 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> <script src="jquery.chained.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <link rel="stylesheet" href="style.css" /> <script type="text/javascript" src="infratool.js"></script> <script> $(function() { $("#submit").hide(); $("#Category").change(function() { window.location = $(this).val().split(" ")[0]; if(loc) window.location.href = loc; }) }); </script> <table width="392" border="0"> <td colspan="2" align="center"><form id="form1" name="form1" method="post" action=""> <tr> <td align="center"> <label><input name="Radio1" type="radio" id="TestA" value="TestA" onclick="showSelect();" />TestA</label> <label><input name="Radio1" type="radio" id="TestB" value="TestB" onclick="showSelect();" />TestB</label> </td> </tr> </form> <div id="div-id" align="center"><select name="Category" id="Category" class="hide"> <option value=" TestA TestB" selected="selected">--</option> <option value="TestA1.php TestA">TestA1</option> <option value="TestA2.php TestA">TestA2</option> <option value="TestA3.php TestA">TestA3</option> <option value="TestA4.php TestA">TestA4</option> <option value="TestA5.php TestA">TestA5</option> <option value="TestB1.php TestB">TestB1</option> <option value="TestB2.php TestB">TestB2</option> <option value="TestB3.php TestB">TestB3</option> <option value="TestB4.php TestB">TestB4</option> <option value="TestB5.php TestB">TestB5</option> <option value="TestB6.php TestB">TestB6</option> </select><input type="submit" value="Go" id="submit"/> </div> </table> here are the other java scripts ive been using //Show Select option after clicking Radio button: function showSelect() { var select = document.getElementById('Category'); select.className = 'show'; } //Select option, separates the link from Class $(function(){ var select = $('#Category'), options = select.find('option'); $('[type="radio"]').click(function(){ var visibleItems = options.filter('[value*="' + $(this).val() + '"]').show(); options.not(visibleItems).hide(); if(visibleItems.length > 0) { select.val(visibleItems.eq(0).val()); } }); }); $(function() { $("#submit").hide(); $("#Category").change(function() { window.location = $(this).val().split(" ")[0]; if(loc) window.location.href = loc; }) }); and here is the screenshot in Firefox and IE8 respectively.
  7. I want to pull up the data that corresponds to the value of the drop down and show it to a text area within a fieldset, I want my page to just initially show the drop down then after selecting a value it will show the data in a text area without refreshing the page, here is the code: <div id="mainContent"> <table width="619" border="0" align="center"> <td align="center"><form id="form1" name="form1" method="post" action="" > <fieldset> <legend><strong>EA</strong></legend> <p> <select name="ea_name" id="ea_name"> <option value="" selected="selected">Please select...</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> </p> </fieldset> </form></td> </table> <div id="results"></div> </div> Here is the code that I've tried that will pull up data and show to a text area but all im getting is No results found. <?php require 'include/DB_Open.php'; $ea_name = $_POST['ea_name']; $sql="SELECT * FROM ea_error WHERE ea_name = '" . $ea_name . "'"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo '<fieldset><legend><strong>Information</strong></legend><p> <table width="auto" height="172" border="0"> <tr><th>Error</th></tr> <tr><th>Resolution</th></tr> <tr><th>Contact/s</th></tr>'; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['error'] . "<input type=hidden name=error value=" . $info['error'] . " </td>"; echo "<td align='center'>" . $info['resolution'] . "<input type=hidden name=resolution value=" . $info['resolution'] . " size='11' maxlength='11' /> </td>"; echo "<td align='center'>" . $info['contacts'] . "<input type=hidden name=contacts value=" . $info['contacts'] . "' /> </td>"; echo "</tr>"; echo "</form>"; } } echo "</fieldset>"; include 'include/DB_Close.php'; ?>
  8. i have this code below as part of my entire Select option, <option value="Running Request |Running > 1 hour">Running Request |Running > 1 hour</option> everything works fine except that when i try to view the uploaded data it would have this result: Running Request |Running > 1 hour 1 hour' /> so the 1 hour is duplicated and would have /> in the end, im thinking it could be the > causing it but just cant get through it...please help...i need to remove the excess 1 hour' /> when I view the uploaded data...
  9. i think i figured it out...i just noticed that i am modifying the same file but saved on a different directory...code works perfect...sorry i just got so confused because of my php copying to another directory but then im still modifying the old one...thanks for the advise regarding this $myusername = mysql_real_escape_string ( htmlspecialchars ($_POST['myusername'])); $mypassword = mysql_real_escape_string ( htmlspecialchars ($_POST['mypassword']));
  10. the problem is the user's name is not being displayed...
  11. i wanted to display the user name after they logged in, i have the code below, this is my login.php <tr bgcolor="#FFFFFF"> <td width="71">Username</td> <td width="181"><input name="myusername" type="text" id="myusername" /></td> </tr> <tr bgcolor="#FFFFFF"> <td>Password</td> <td><input name="mypassword" type="password" id="mypassword" /></td> </tr> <tr bgcolor="#FFFFFF"> <td><input type="submit" name="Submit" value="Login" /></td> </tr> here is my checklogin.php <?php $host="*****"; // Host name $username="*****"; // Mysql username $password="*****"; // Mysql password $db_name="*****"; // Database name $tbl_name="*****"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername = mysql_real_escape_string ($_POST['myusername']); $mypassword = mysql_real_escape_string ($_POST['mypassword']); $myusername = htmlspecialchars ($_POST['myusername']); $mypassword = htmlspecialchars ($_POST['mypassword']); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ $row=mysql_fetch_array($result); session_start(); $_SESSION['login'] = "1"; $_SESSION['myusername'] = $row['username']; header("location: infratools.php"); } else { echo "Wrong Username or Password"; session_start(); $_SESSION['login'] = ''; } ?> and here is one of the page where i want to display the user name, infratools.php <?PHP session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header ("Location: infralogin.php"); } ?> <p>Logged in as: <?php echo $_SESSION['myusername']; ?></p>
  12. hi there i think i figured out what i really want now, i think i may just need a client side script to accomplish what i want, so instead of using the SELECT, what i want is to replace it with a TEXT FIELD with the name of the user who logs in, so that when he retrieves data from the DB, he would just have to select the date and user's name is already pre-defined, in that way, datas that will be gerated by the SQL script is just for the user and does not have option to select or view other users records, i think i need a java script code here, can you show me a sample code as well? here is the SELECT which should be replaced by TEXT FIELD with pre-defined USERS value already <select name="XiD" id="XiD"> <option value="USER1">USER1</option> <option value="USER2">USER2</option> <option value="USER3">USER3</option> <option value="USER4">USER4</option> <option value="USER5">USER5</option> <option value="USER6">USER6</option> <option value="" selected="selected">Please Select...</option> </select>
  13. do u have a sample script that i can try to work on...just need a glimpse of the script so i would know how to start...im not asking for the actual code...just need to visualize the script...
  14. well i have SQL for tickets submitted by users...thats it...here are the fields in my SQL: ars_no, phone_number, category_1, category_2, status, create_date, trouble_type_priority, ban_type
  15. im kinda confused here, how can i make such php pages dynamic, now what if i have this code which calls another php page, below is my php page that calls <script type="text/javascript"> $(document).ready(function(){ $("#RetrieveList").on('click',function() { var xid = $('#XiD').val(); var date = $('#Date').val(); $.post('retrieve_ticket.php',{xid:xid, date:date}, function(data){ $("#results").html(data); }); return false; }); }); </script> <form id="form2" name="form2" method="post" action=""> <table width="741" border="0" align="center"> <tr> <th colspan="9" align="center" style="font-size:14px" scope="col">Xid, Name:<span> <select name="XiD" id="XiD"> <option value="USER1">USER1</option> <option value="USER2">USER2</option> <option value="USER3">USER3</option> <option value="USER4">USER4</option> <option value="USER5">USER5</option> <option value="USER6">USER6</option> <option value="" selected="selected">Please Select...</option> </select> </span><span style="font-size:14px"> <label for="date">Date:</label><input type="text" name="Date" id="Date" size="8"/> <input name="action" type="button" id="RetrieveList" value="Retrieve List" /> <input name="Clear" type="reset" id="Clear" value="Clear" onClick="window.location.reload()" /> <p></p> <p></p> <p></p> <p></p> <label for="Clear"></label> <div align="center"></div></th> </tr> </table> </form> and here is the page being called, <html> <head> </head> <body> <script> jQuery(document).ready(function () { jQuery("input[name=checkall]").click(function () { jQuery('input[name=checkall]').prop('checked', this.checked); jQuery('input[name=checkbox]').prop('checked', this.checked); }); // if all checkbox are selected, check the selectall checkbox // and viceversa jQuery("input[name=checkbox]").click(function(){ if(jQuery("input[name=checkbox]").length == jQuery("input[name=checkbox]:checked").length) { jQuery("input[name=checkall]").prop("checked", true); } else { jQuery("input[name=checkall]").prop("checked", false); } }); }); </script> <?php require 'include/DB_Open.php'; $xid = $_POST['xid']; $date = $_POST['date']; $sql="SELECT ars_no, phone_number, category_1, category_2, status, create_date, trouble_type_priority, ban_type FROM tbl_main WHERE employee_id_name = '" . $xid . "' AND resolved_date = '" . $date . "' ORDER BY category_1, category_2, status"; $myData = mysql_query($sql); //to count if there are any results $numrow = mysql_num_rows($myData); if($numrow == 0) { echo "No results found."; } else { echo "Ticket Count: $numrow"; } { echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'> <tr> <th align='center'><strong>Remedy Ticket No.</strong></th> <th align='center'><strong>Phone/Incident No.</strong></th> <th align='center'><strong>Category 2</strong></th> <th align='center'><strong>Category 3</strong></th> <th align='center'><strong>Status</strong></th> <th align='center'><strong>Create Date</strong></th> <th align='center'><strong>Severity</strong></th> <th align='center'><strong>Ban Type</strong></th> <!--<th align='center'><strong>Date Submitted</strong></th>--> </tr>"; while($info = mysql_fetch_array($myData)) { echo "<form action='retrieve_ticket.php' method='post'>"; echo"<tr>"; echo "<td align='center'>" . $info['ars_no'] . "<input type=hidden name=ars_no value=" . $info['ars_no'] . " </td>"; echo "<td align='center'>" . $info['phone_number'] . "<input type=hidden name=phone_number value=" . $info['phone_number'] . " size='11' maxlength='11' /> </td>"; echo "<td align='center'>" . $info['category_1'] . "<input type=hidden name=category_1 value=" . $info['category_1'] . "' /> </td>"; echo "<td align='center'>" . $info['category_2'] . "<input type=hidden name=category_2 value=" . $info['category_2'] . "' /> </td>"; echo "<td align='center'>" . $info['status'] . "<input type=hidden name=status value=" . $info['status'] . "' /> </td>"; echo "<td align='center'>" . $info['create_date'] . "<input type=hidden name=create_date value=" . $info['create_date'] . "' /> </td>"; echo "<td align='center'>" . $info['trouble_type_priority'] . "<input type=hidden name=trouble_type_priority value=" . $info['trouble_type_priority'] . " size='1' maxlength='1' /> </td>"; echo "<td align='center'>" . $info['ban_type'] . "<input type=hidden name=ban_type value=" . $info['ban_type'] . " size='1' maxlength='1' /> </td>"; echo "</tr>"; echo "</form>"; } } echo "</table>"; include 'include/DB_Close.php'; ?> </body> </html>
  16. not that simple as to what i have thought, do you have any sample code that i can try to work on or a tutorial URL where i can learn such things...
  17. that is what i have in mind right now, because each php page that i have would have this section wherein they will not have to input their name, because it already has the value, im trying to read thru forums on how to use dynamic website but nothing seems to fit to what i intend. please help in at least showing me the right direction to achieve this... <tr> <td style="font-size:12px"><strong>iD, Name:</strong></td> <td><input type="text" name="iD" id="iD" value="USER1" readonly="readonly" /></td> </tr>
  18. how can i load a specific pages for specific users, what i have in mind is to create multiple php pages for each user, lets say, php pages A, B, C, D, E, F, G then i would create pages for user 1 - 1A, 1B, 1C, 1D, 1E, 1F, 1G then for 2nd user - 2A, 2B, 2C, 2D, 2E, 2F, 2G so on and so forth for the other users... then i would just edit the header to land the user to their own php pages, is this the correct way to redirect a user to their own page or there is a much better way?
  19. this is fixed now, i've edited code to this <?PHP session_start(); if (!isset($_SESSION['login']) || $_SESSION['login'] == '') { header ("Location: infralogin.php"); exit(); } ?>
  20. i've marked it again as unresolved coz its not working on a page that is linked to my main page, for example, after i login i'll be redirected to main page, now under my main page i'll click on a link, lets say <tr bgcolor="#FFFFFF"> <td align="center"><a href="tickettracker.php">Ticket Uploader</a></td> </tr> now this tickettracker.php has other links inside it and in all those links i have put the code below to protect them, but every time i click on them i am now redirected to the login page again. <?PHP session_start(); session_destroy(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header ("Location: infralogin.php"); } ?> this code works perfectly that when i try to access the page directly im being routed to the login page but that is also whats happening when i click those links after i have already logged in.
  21. Hi trq, thanks for the response, should i be putting that to each php page that i want to be protected or just in the login.php?
  22. how can i protect my PHP page such that when a user just types the entire link on a browser, they will be re-directed to the login page? here is my login.php code: <?php $host="*****"; // Host name $username="*****"; // Mysql username $password="*****"; // Mysql password $db_name="*****"; // Database name $tbl_name="*****"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from form $myusername = mysql_real_escape_string ($_POST['myusername']); $mypassword = mysql_real_escape_string ($_POST['mypassword']); $myusername = stripslashes ($_POST['myusername']); $mypassword = stripslashes ($_POST['mypassword']); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ session_start(); $_SESSION['login'] = "1"; header("location:admin/infratools.php"); } else { echo "Wrong Username or Password"; session_start(); $_SESSION['login'] = ''; } ?> here is my main page which has all the other links to all my php pages: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Infra Tool</title> <link rel="stylesheet" href="style.css" /> </head> <body class="oneColFixCtrHdr" onload="document.form1.myusername.focus();"> <div id="container"> <div id="header" style="background-color:#7BD12E"> <h1 align="Center" style="color:#FFF; font-family: Arial, Helvetica, sans-serif;">PROV InfraTools </h1> <!-- end #header --></div> <div id="mainContent"> <p> </p> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td colspan="2" align="center"> <form id="form1" name="form1" method="post" action="checklogin.php"> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td> </td> </tr> <tr bgcolor="#FFFFFF"> <td align="center"><a href="tickettracker.php">Ticket Uploader</a></td> </tr> <tr bgcolor="#FFFFFF"> <td align="center"><a href="raptool.php">RAP Tool</a></td> </tr> <tr bgcolor="#FFFFFF"> <td> </td> </tr> <tr bgcolor="#FFFFFF"> <td align="center"><a href="login/add_user.php">Add User</a></td> </tr> <tr bgcolor="#FFFFFF"> <td align="center"><a href="login/logout.php">Logout</a></td> </tr> </table> </form></td> </table> <p> </p> <!-- end #mainContent --> </div> <p align="center"> </p> <div id="footer" style="background-color:#7BD12E"> <p style="color:#FFF"></p> <!-- end #footer --></div> <!-- end #container --></div> </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.