berserk 60 Junior Poster

ok i have sort of made some progress, i read on some help fofums that

data: $("#note_form").serialize()

is a much better way of getting ALL the data from the form so i tried it and after tweaking some other things i get the prompt working correctly after the button is pressed. however i echo out my sql line from my addnote.php page and there is still nothing reaching the page as far as data. Is there something else im doing wrong? also i changed the method from get to post but it didnt seem to fix this issue so its probably something else im not seeing.

here is the full code for reference

<script>
                            function no_redirect(){
                              // var note_text=$('#note_text').val();
                              // var cnotes=$('#cnotes').val();
                              // var  formData = "note_text="+note_text+"&cnotes="+cnotes;
                              $.ajax({
                                  url : "addnote.php",
                                  type: "POST",
                                  // data : formData,
                                  data: $("#note_form").serialize(),
                                  success: function(data, textStatus, jqXHR)
                                  {
                                      //data - response from server
                                      alert(data);
                                  },
                              });
                            }
                            </script>
                            <form action="#######.php" method="POST" id="note_form">
                            <div class="span12">
                              <h4 style="color:#1577a6;">Notes</h4>

                              <input type="hidden" name="cnotes" id="cnotes" value="<?php echo $tempuser8[$u]; ?>"/>
                              <textarea class="field span12" id="note_text" name="note_text" type="text" rows="9" maxlength="10000"><?php echo $tempuser9[$u];?></textarea>
                              <!-- <input id="add_note" type="submit" class="pull-right" name="add_note" value="Add Note"></submit> -->
                              <a href="#" class="btn btn-info pull-right" onclick="no_redirect()">Add Note</a>
                            </div>
                          </form>

here is the php script

$con = mysqli_connect($host,$uname,$pass,$database) or die(mysqli_error($con));

$customer_notes                     = NULL;
$row                                = NULL;


$customer_notes                 = $_POST['note_text'];
$row                            = $_POST['cnotes'];


// $sql = "INSERT INTO userprofile
//             (customer_notes)
//             VALUES
//             ('".$customer_notes."')";

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";
echo $note_sql;
echo "<br>";
$result …
berserk 60 Junior Poster

thats all partly my fault for not giving more description as to what im working for. The reason behind this is that i need the page to not redirect, and just the data sent to the database, if i do this with that form it will redirect me every time, i did try a quick fix and put a header in the form action file so that when it redirected it would take me back but thats an unpractical solution for what im working on. Is the a way to push the output from the form php file to a prompt or something on the current screen so that the page isnt redirected but im still getting an response? If you need any more details please ask cause i know this is a tricky scenario, this is not a feature im particularly familiar with so its been really troublesome.

berserk 60 Junior Poster

Im sure this question has been asked before but i cannot seem to get what i need working right for me. i need this ajax to process my php form, i got that for, at least i think. I wrote some ajax to do this and it WILL at least give a responce but nothing in the database is changed so its not actually doing anything, heres my ajax/javascript to add a little more detail the reason im doing this is because i dont want the page to redirect after you hit the submit button. id just like it to pop up a success window or something.

<script>
                            function no_redirect(){
                              var note_text=$('#note_text').val();
                              var cnotes=$('#cnotes').val();
                              var  formData = "note_text="+note_text+"&cnotes="+cnotes;
                              $.ajax({
                                  url : "addnote.php",
                                  type: "GET",
                                  data : formData,
                                  success: function(data, textStatus, jqXHR)
                                  {
                                      //data - response from server
                                      alert(data);
                                  },
                              });
                            }
                            </script>

and here is my html form

<form action="" method="get">
                            <div class="span12">
                              <h4 style="color:#1577a6;">Notes</h4>

                              <input type="hidden" name="cnotes" id="cnotes" value="<?php echo $tempuser8[$u]; ?>"/>
                              <textarea class="field span12" id="note_text" name="note_text" type="text" rows="9" maxlength="10000"><?php echo $tempuser9[$u];?>

and just in case here is my php file

$con = mysqli_connect($host,$uname,$pass,$database) or die(mysqli_error($con));

$customer_notes                     = NULL;
$row                                = NULL;


$customer_notes                 = $_GET['note_text'];
$row                            = $_GET['cnotes'];


// $sql = "INSERT INTO userprofile
//             (customer_notes)
//             VALUES
//             ('".$customer_notes."')";

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";
$result = mysqli_query($con, $note_sql);  
if($result){
    // header( "Location: index.php" );
} else{
    // echo("Input data has failed Please go back and resubmit");
}

idk why …

berserk 60 Junior Poster

NOPE NOPE NOPE i apologize for wasting your time jstfsklh211 this was a stupid error and i should have seen it but i simply was not paying enough attention, NOW TO MAKE UP FOR IT!

ill explain what i did wrong and how i fixed this, you see when i echo out the value in the html part of the form it was actually not echoing anything because i was missing THIS ";" at the end of my line, this method entirely works now that i have managed to fix it but yeah that was my ONLY issue. again sorry for the mix up, but regardless jstfsklh211 thank you for you assistence.

berserk 60 Junior Poster

i apologize for not including this before

here is the full form code

<form action="addnote.php" method="get">
                            <div class="span12">
                              <h4 style="color:#1577a6;">Notes</h4>

                              <input type="hidden" name="cnotes" values="<?php echo $u ?>"/>
                              <textarea class="field span12" id="note_text" name="note_text" type="text" rows="9" maxlength="10000"></textarea>
                              <input id="add_note" type="submit" class="pull-right" name="add_note" value="Add Note"></submit>
                            </div>
                          </form>

and im glad you pointed out printing it cause this narrows it down a bit, theres no data being passed to my id element of my sql string

UPDATE users SET customer_notes='sdasdcsdfvsdfvsdfvdfsvsdfv' WHERE id=''

this is what i got when i printed out $note_sql

berserk 60 Junior Poster

I am in need of help on this one :( i cannot seem to figure out what i have done wrong, i set up my code just like in teh examples i read and i dont really see anything wrong with the logic (as far as i can tell) but the code will RETURN as data added successfully but i know better cause nothing shows up in teh database.

heres the html

<input type="hidden" name="cnotes" values="<?php echo $u ?>"/>
                              <textarea class="field span12" id="note_text" name="note_text" type="text" rows="9" maxlength="10000"></textarea>
                              <input id="add_note" type="submit" class="pull-right" name="add_note" value="Add Note"></submit>

this code is what i used to collect the data for the submission, i used a hidden input to get the value of the rom number for each entry in my table, then i just take the textarea and add that to the database, really im updating the database with that value being added to an already existing entry in my database, but this is where my issue starts.

In my sql line $note_sql it doesnt seem to really update anything

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";

here is the whole code

$con = mysqli_connect($host,$uname,$pass,$database) or die(mysqli_error($con));

$customer_notes                     = NULL;

if(isset($_GET['add_note']))
{
    $customer_notes                 = $_GET['note_text'];
    $row                            = $_GET['cnotes'];
}

// $sql = "INSERT INTO userprofile
//             (customer_notes)
//             VALUES
//             ('".$customer_notes."')";

$note_sql = "UPDATE users SET customer_notes='".$customer_notes."' WHERE id='".$row."'";

$result = mysqli_query($con, $note_sql);  
if($result){
    echo ("DATA SAVED SUCCESSFULLY");
} else{
    echo("Input data has failed Please go back and resubmit"); …
berserk 60 Junior Poster

I have been working with this table for some time now and i cannot figure out how to get the nested feature working correctly, when i try to insert the nested table into the original table is admitidly does go in but it removes all the formatting from my previous table and just screws up everything. is there a certian way i need to nest my html table inside the outertable? Maybe im just not setting up the classes right? Regardless i can get the nested table working sort of correctly but my outer table has features i want to keep, namely search, sort, pagination, etc.. But when i nest my table it removes all of this completely, how can i retain these features while nesting my tables? Also my nested table is a collpasable/expandable style table so its initailly hidden from the user until you click the row then the table expands, my current setup (ugly and not practical at all) has the nested table hidden and will show up when the row is clicked but the nested table appears outside the table at the bottom of the screen, i cant find any help and have gotten little to no progress made despite reading for days, any help you may be able to provide would be life saving!

Thats all the code for my table page i have, i am using bootstrap.css and bootstrap.js

<head>
   <meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <!-- This link is …
berserk 60 Junior Poster

I have this table that i have been modifiying and working with for some time now, its for displaying lots of data both condensed and expandle for each row but also searchable and sortable. Here is my problem, my table used to have perfect sorting and searching before i added the expandable and collapsable feature and now i can get my search or sort back. I have narrowed it down to a specific place that seems to mess my whole code up (note that i am using bootstrap and am not entirely familiar with nested tables) here is what i have so far:

Thats all my included files

<html lang='en'>
<head>
   <meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <!-- This link is for the formatting on the navigation bar at the top -->
   <link rel="stylesheet" href="navbar.css">

    <!-- These are the formatting links for the table -->
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">
    <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">

   <!-- Scripts for the tables auto resizing, search, etc... -->
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/bootstrap.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>
    <script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>
</head>

This is all my html table code

<div class="col-lg-6">    
<div class="row-fluid">
<div class="span12">
 <div class="container">
          <form method="post" action="##########.php" >
              <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered table-condensed" id="example">
                  <br>
                  <thead>
                      <tr>
                          <th></th>
                          <th>Status</th>
                          <th>Name</th>
                          <th>Last 6 VIN#</th>
                          <th>Account</th>
                          <th>Repo Sale Date</th>
                      </tr>
                  </thead>
                  <tbody>
                  <?php 
                  $query=mysqli_query($con, "SELECT * FROM users")or die(mysqli_error($con));
                  $rownumber = 0;
                  while($row=mysqli_fetch_array($query)){
                  $rownumber++;
                  $id=$row['id'];
                  ?>    <!-- This is for declaring …
berserk 60 Junior Poster

YES! with enough time and concentration the answer can be found, and i would be delighted to share this solution to help any wondering php'ers that happen across this by any chance.

FIRSTLY turns out this CAN be done in php, or at least the logic, you are still going to use javascript like bootstrap and jquery to call classes so it will know what to do with said php logic. Here is what i have.

<tr data-toggle="collapse" data-target="#row<?php echo $loopcounter; ?>" class="accordion-toggle">
<td><center>
<span class="arrow">&#9660;</span>
</center></td>
<td><?php echo @$row['status'] ?></td>
<td><?php echo @$row['username'] ?></td>
<td><?php echo @$row['last_6_vin'] ?></td>
<td><?php echo @$row['account'] ?></td>
<td><?php echo @$row['repo_sale_date'] ?></td>
</tr>

Notice what i did here, i still declared the id as row for the data-target to work properly with jquery BUT i added that php loopcounter in there, the loop counter is used in the while loop when creating the php table, like below.

<?php 
$query=mysqli_query($con, "SELECT * FROM users")or die(mysqli_error($con));
$loopcounter = 0;
while($row=mysqli_fetch_array($query)){
$loopcounter++;
$id=$row['id'];
?>

simply initialize the loopcounter and then in teh while loop add one each time and this will become your individualized row ID for making each table entry open and close. I am NOW in the process of figuring out how to get them to open and close singularly so as to not open so many at the same time but that one is for a later date. I hope this helps anyone who struggles with this as i have and …

diafol commented: Thanks for sharing +15
berserk 60 Junior Poster

OH and just as a reference if these would help me get any more information regarding this subject ill include everything i can.

<meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <!-- This link is for the formatting on the navigation bar at the top -->
   <link rel="stylesheet" href="navbar.css">

    <!-- These are the formatting links for the table -->
    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">
    <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">

   <!-- Scripts for the tables auto resizing, search, etc... -->
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/bootstrap.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>
    <script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>
berserk 60 Junior Poster

I moved the class calls to the <tr> like you said and unfortunatly nothing worked after that :( i am not having any luck with this at all and really my only issue is that it will only work on that first row entry on my table, the rest of the rows if clicked with just open the first collpased row, is there some way to set these apart because i feel like my issue now is very small and simple but im just not seeing it.

berserk 60 Junior Poster

Okay so i have definitly made some progress. I found that this line in my code is most likely where the problem needs to be fixed.

<tr>
   <td colspan="12" >
     <div class="accordian-toggle collapse" id="row">
       <table width="100%">
         <thead>
           <tr>

Is there any way i can modify this to where each individual row in the table is expandable and collapsable, so far like before its just the first entry but I KNOW from tinkering that each entry is getting information individually so thats perfect, all i need is for the row to each be expandable, although i see some issues like how my table is being generated with a while loop in php/html, so it makes sense that the first entry is working like it should because the html is only set for the first entry, all entries after are not set properly.

Would i be able to modify that id="row" to where its different for each iteration of the html in the while loop? like similar to what i have for the php table.

if im completely off the right track let me know cause im just brainstorming here lol

berserk 60 Junior Poster

thank you :D

berserk 60 Junior Poster

OK with lots of tinkering and reading i narrowed the issue down to this one place in my html when im calling classes.

<tr>
   <td colspan="12" >
      <div class="accordian-toggle collapse" id="row">
         <table>
            <thead>
               <tr>

When I call that class accordian-toggle if i leave out the initial state "collape" then i can see that each of my entry are in fact getting the data individually its just that i cant seem to set them to open and close dynamically. So i really only need to know where the code is in my Javascript file so i can either edit it or use something else, my problem now is that since im using boostrap the file is HUGE and i have no idea where to even start looking :( such a simple feature but yet so complex to implement correctly.

berserk 60 Junior Poster

OKAY i have been working on this for a little while and i feel i am getting close but there are a few things i can't seem to find on the internet that are good examples/tutorials/reading materials.

1.) i need my table to expand and collapse (got that figured out) only issue is that only first entry expands and collapses, need all of them too.

2.) i need my table to expand and collapse for each individual entry, currently my table will only expand or collapse based on the first entry of the table no matter which entry you click on.
There are going to be thousands of entries in this table so i need a way to automate the process of displaying data per entry without writing code for each individual entry, this is my main problem i'm facing.

3.) for some reason when set up a nested table inside my current table the search, page number, and page entry list with the navigation arrows disappears. Not sure if this has anything to do with incorrectly calling the classes based on my nested tables or what but i need that fixed.
currently i have the expand and collapse function set up as the entire table entry is clickable and it will expand and collapse but id like to have it where only the button in the first column will do this, i don't really mind this either way so its not a big deal.

This is the …

berserk 60 Junior Poster

I will move this topic to the javascript forum.

berserk 60 Junior Poster

PHEW thats a lot of information to sort through. So i need to use ajax almost entirely for this even to handle correctly. I understand i just hope this will be an easy thing to figure out.

Thank you for you time and assistence.

berserk 60 Junior Poster

I was thinking of maybe being able to write the logic i need in php but if im on the wrong track then i would not be suprised. if this can be done with javascript or simple html then im all ears.

berserk 60 Junior Poster

OKAY i have been working on this for a little while and i feel i am getting close but there are a few things i can't seem to find on the internet that are good examples/tutorials/reading materials.

  1. i need my table to expand and collapse (got that figured out)
  2. i need my table to expand and collapse for each individual entry, currently my table will only expand or collapse based on the first entry of the table no matter which entry you click on.
    There are going to be thousands of entries in this table so i need a way to automate the process of displaying data per entry without writing code for each individual entry, this is my main problem i'm facing.
  3. for some reason when set up a nested table inside my current table the search, page number, and page entry list with the navigation arrows disappears. Not sure if this has anything to do with incorrectly calling the classes based on my nested tables or what but i need that fixed.
  4. currently i have the expand and collapse function set up as the entire table entry is clickable and it will expand and collapse but id like to have it where only the button in the first column will do this, i don't really mind this either way so its not a big deal.

This is the html code that i have so far (the css/javascript are based on bootstrap)

<div class="col-lg-6">
  <div class="panel panel-default"> …
berserk 60 Junior Poster

gotcha, quick question though, is there a limit to the level of selectors you can have in a css file? I mean do they have to follow a specific formatting like ui, li, ul, and so on and so forth? Hope this isnt a dumb question lol

berserk 60 Junior Poster

Agreed, regardless i feel both of you heavily guided me to the right solution :D

berserk 60 Junior Poster

AH HA so it did have something to do with me not seperating the sub menu from the menu in the css. Thank you also sir, this has helped me learn a little bit more about this craft. I will work on applying your fix simply for educational purposes and good practices! :D

berserk 60 Junior Poster

YOU SIR ARE BRILLIANT! i know this was a simple problem but i feel that its the simple things that make a program nice to use. Thank you so much for your assistance. Though i would like to know, why is it that this line is needed? I have used this code before and it has worked in the past, i agree i am usign a custom tab code now i just couldnt figure out why is was pushing everything down.

again thank you for your assistance

berserk 60 Junior Poster

Also update to your posts, i changed the z index and even tried changing the positions from absolute to relative and vice versa but nothing worked. when i hover over the menu it will puch everything down, but if your not hoevered over then its fine. Am i missing some wrapper div or something?

berserk 60 Junior Poster

Here is the whole css code

@import url(http://fonts.googleapis.com/css?family=Raleway);
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

#cssmenu:after,
#cssmenu > ul:after {
  content: ".";
  display: block;
  clear: both;
  visibility: hidden;
  line-height: 0;
  height: 0;
}

#cssmenu {
  width: auto;
  border-bottom: 6px solid #1577a6;
  font-family: Calibri, sans-serif;
  line-height: 1;
}

#cssmenu ul {
  background: #ffffff;
}

#cssmenu > ul > li {
  float: left;
}

#cssmenu.align-center > ul {
  font-size: 0;
  text-align: center;
}

#cssmenu.align-center > ul > li {
  display: inline-block;
  float: none;
}

#cssmenu.align-right > ul > li {
  float: right;
}

#cssmenu.align-right > ul > li > a {
  margin-right: 0;
  margin-left: 0px;
}

#cssmenu > ul > li > a {
  z-index: 2;
  padding: 18px 25px 5px 25px;
  font-size: 15px;
  font-weight: 400;
  text-decoration: none;
  color: #1577a6;
  -webkit-transition: all .2s ease;
  -moz-transition: all .2s ease;
  -ms-transition: all .2s ease;
  -o-transition: all .2s ease;
  transition: all .2s ease;
  margin-right: 0px;
}

#cssmenu > ul > li.active > a,
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li > a:hover {
  color: #ffffff;
}

#cssmenu > ul > li > a:after {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: -1;
  width: 100%;
  height: 120%;
  border-top-left-radius: 2px;
  border-top-right-radius: 2px;
  content: "";
  -webkit-transition: all .2s ease;
  -o-transition: all .2s ease;
  transition: all .2s ease;
  -webkit-transform: perspective(5px) rotateX(2deg);
  -webkit-transform-origin: bottom;
  -moz-transform: perspective(5px) …
berserk 60 Junior Poster

I have this dilemma where I need to make my sub-menus hover over the other content on my page but I cannot seem to do this, I have searched and searched but to no avail. I am to the point where I just need a little bit of guidance on this. I’m still relatively new to css but have slowly gotten the hang of it over time. I just cannot seem to figure this one out though.

My issue is that when I hover over the tabs in my tab menu the drop come is triggered BUT it pushes everything else down, what I need is for it to simply hover over everything else.

This is the HTML code that I use.

<div id='cssmenu'>
        <ul class="clearfix">
            <li><a href="/xampp/customertable/">Home</a></li>
            <li>
                <li class='active'><a href="/xampp/profile/">Profile<span class="arrow">▼</span></a>

                <ul class="sub-menu">
                    <li><a href="#">In Cinemas Now</a></li>
                    <li><a href="#">Coming Soon</a></li>
                    <li><a href="#">On DVD/Blu-ray</a></li>
                    <li><a href="#">Showtimes & Tickets</a></li>
                </ul>
            </li>
            <li><a href="#">T.V. Shows</a></li>
            <li class="current-item"><a href="#">Photos</a></li>
            <li><a href="#">Site Help</a></li>
        </ul>
</div>

While this is my css code, its ugly i know but its all i got lol.

/*----- Menu Outline -----*/

#cssmenu ul ul {
  display: none;
}

#cssmenu ul li:hover > ul {
  display:block;
}

/*Formatting for the text inside the submenu*/
#cssmenu li:hover > a, .current-item > a {
    text-decoration:none;
    color:#ffffff;
}

/*----- Bottom Level (sub Menu) -----*/
#cssmenu li:hover .sub-menu {
    z-index:1;
    opacity:1;
}

.clearfix:after {
    display:inline-block;
    clear:both;
}

.sub-menu {
    width:103%;
    padding:0px 0px;
    position:absolute;
    top:80%;
    left:0px;
    z-index:-1;
    opacity:0;
    transition:opacity linear 0.15s;
    box-shadow:0px …
berserk 60 Junior Poster

Understood, ty for the headsup, i was looking into that but i was coming across many posts talking about how its a security risk in the way i wantde to use it.

berserk 60 Junior Poster

This is perfect, i have also been looking into cereals idea as well. Honestly eithe rof these solutions will work for me but i may end up looking into cereals a bit more, i just need to read up mainly. My question diafol is will i be able ot use your code as a stand alone application, like maybe set it up and then package it using cereals idea, so that i can include it to be able to set up this whole project instantly, basically like an installer but simply moves the files to the correct place.

Also i just wanted to mention that i truly appreciate everything you guys have done. This has been more informative than anything a college class could offer and i thank you for that. The internet is a great place to learn but can be meaningless without the proper guidance.

If there is anything i can do for you guys in the future please dont hesitate to PM me, i will be honered to assist!

berserk 60 Junior Poster

The client i initially built this for are gonna run it off an old dedicated PC and they will have access to it over the local network, the computer isnt even hooked to the net and no traffic aside from this will go to it. This is more of a cheap solution than anything, and no the numbers arent confidential so its not a big deal if they get leaked in some way.

I too was worried about providing them with this solution via xampp, would it be easier to provide them with some online database so that the program can be internet/web based instead of in house.

How much harder would it be to set this up? Wouldnt i need to set up a domain of some kind and run the software that way?

berserk 60 Junior Poster

Thats pretty much what id like to accomplish, im deploying my software is for a small call center but they are presented with numbers they are not allowed to call but the files are huge (they range from over 1 million numbers a file and theres normally 3 to 5 files), and they have old hardware and can take anywhere from 30 minutes to an hour to load these files in a text editor, they do load a LOT faster in libre but that idea was shot down immediatly and i got little explanation as to why, so thats the point of my program is to speed this up, only thing is that if i potentially sold to others id need a way for the user to set this up and me not have to be there (automated setup) but i dont know much about batch scripting and it might be easier to write up a guide on how to install it but i doubt many companies would like a set up like that. IDK im really just coming up with this as i go lol

berserk 60 Junior Poster

I understand what you mean diafol, i guess emailing an exe would seem a little strange now adays, a zip would be more appreopriate, but my problem is i wanted to make a self extracting package that will extract and replace the entire htdocs folder in xampp, thats probably gonna be the limit to what i can do but essentially itll similar to an executable, where you will click it and it will extract like i mentioned earlier. Id like to do this on linux as well but ill stick to windows for now, and thank you gabrielcastillo, this may be sorta what im looking for, instead of being a stand alone application (which i will definitly use this later on for my next project) itll still be web based so itll run in the browser.

berserk 60 Junior Poster

god i am sorry i wasted your time, there was never an issue to begin with this is working perfectly fine, although flawed in the security department as diafol pointed out, it is after further testing working fine. For some reason after i cleared my browsing cache in chrome it then began working flawlessly, not sure exactly what happened there but i am happy now.

Also thank you diafol for linking me to such excellent password verification, my new project is securing my program even further now that i know i can make it easily much better. This has been an incredible learning experience, again thank you so much!

one more small question, do either of you know of a way to package xampp projects into executable files, preferably on windows and linux as these are typical hosting evironments for web based/network based solutions

diafol commented: no problem +15
berserk 60 Junior Poster

Sorry, i dont mean to sound dumb but where would the snippets section be? and can you give examples of PDO, im looking at it through a google search but i dont really get how this works? Sorry I apologize for my ignorance, like i said before im still learning.

berserk 60 Junior Poster

not a dumb question at all, and i did before but now when i have that line in there it will go on through to the page, when i take the line out it will check, is there something else i have to use with session_start?

berserk 60 Junior Poster

ok here is what i did, i made the folowing changes to my code to get it to echo the results of all the variables i could var_dump

if(isset($_POST['login']))
{
    //get username and password entered by user
    $myusername=mysqli_real_escape_string($con,$_POST['username']);
    $mypassword=mysqli_real_escape_string($con,$_POST['password']);

    $sql="SELECT username, password FROM admin WHERE username='".$myusername."' AND BINARY password='".$mypassword."' UNION SELECT username, password FROM superuser WHERE username='".$myusername."' AND BINARY password='".$mypassword."'";
    $check= mysqli_query($con,$sql);
    $row = mysqli_fetch_row($check);

    if($row[0]!="" && $row[1] !="") //compare username and password to ones  found in database
    {

         ## set logged_in to true
        $_SESSION['logged_in']= true;
         ## set username session
        $_SESSION['user'] = $row[0]; 

        var_dump($row);
        echo "<br>";
        var_dump($row[0]);
        echo "<br>";
        var_dump($row[1]);
        echo "<br>";
        var_dump($_SESSION['logged_in']);
        echo "<br>";
        var_dump($_SESSION['user']);
        echo "<br>";
        var_dump($_SESSION);
        echo "<br>";
        //header('location: table.php');
        exit();
    }
    else
    {
        $error="Your Login Name or Password is invalid";
        //echo "$error";
        //echo "<META http-equiv=' refresh' ;URL='index.php'>";
    }
}

and from this i got the follows results on screen, unfortunatly everything checks out from what i can tell, no empty variables or sessions, unless im missing something which is completely possible.

array(2) { [0]=> string(5) "Admin" [1]=> string(5) "Admin" } 
string(5) "Admin" 
string(5) "Admin" 
bool(true) 
string(5) "Admin" 
array(2) { ["logged_in"]=> bool(true) ["user"]=> string(5) "Admin" } 

also @diafol, sorry if im using bad coding practices, or overal wrong code. Im still learning about security in php and mysql which i have realized has been a huge undertaking, if there are any articles or anything u can add to what you were talking about please let me know, i will happily accept any suggestions you make …

berserk 60 Junior Poster

I was using this code before and it worked but then i updated my code base to php 5.3 and now it doesnt work anymore. I have looked over the logic time and time again and it should work fine, what am i doing wrong, or am i using deprecated functions again? here is my login index.php file

<?php
ini_set('session.save_path', '/opt/lampp/htdocs/tmp'); // linux specific line for setting session tmp path
session_start();
$con = mysqli_connect("localhost", "root", "", "numbers") or die(mysqli_error($con));
$error = NULL;

if(isset($_POST['login']))
{
    //get username and password entered by user
    $myusername=mysqli_real_escape_string($con,$_POST['username']);
    $mypassword=mysqli_real_escape_string($con,$_POST['password']);

    $sql="SELECT username, password FROM admin WHERE username='".$myusername."' AND BINARY password='".$mypassword."' UNION SELECT username, password FROM superuser WHERE username='".$myusername."' AND BINARY password='".$mypassword."'";
    $check= mysqli_query($con,$sql);
    $row = mysqli_fetch_row($check);
    if($row[0]!="" && $row[1] !="") //compare username and password to ones  found in database
    {

         ## set logged_in to true
        $_SESSION['logged_in']= true;
         ## set username session
        $_SESSION['user'] = $row[0]; 

        header('location: table.php');
        exit();
    }
    else
    {
        $error="Your Login Name or Password is invalid";
        //echo "$error";
        //echo "<META http-equiv=' refresh' ;URL='index.php'>";
    }
}

This part works fine, at least i think it does.

while this little part here is whats giving me the trouble.

if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] == false){
    header('Location: index.php');
    exit();
}

Before i could put that in front of any file i wanted to protect with a password, now it doesnt work anymore, anyone can just copy the url and paste it in and it will take you right to the page without prompting for a password, it should …

berserk 60 Junior Poster

i can happily say that i dont need asistence with this problem anymore, i did apply my solution in probably the worst way but it works and thats what matters, i can improve everything at my leisure and thats what i wanted all along, and id be happy to post my solution here for others when they run into problems.

<!-- This is the export by date button -->
</form>
<form action="export.php" >

<div style="width:100%;" class = "export"> 
<div class="alert alert-info">
&nbsp
<?php echo "Export By Date e.g. From 2014-06-27 Too 2014-07-01";?>

</div>
<br>
<span style="white-space: nowrap;">


<?php echo "From:" ?>&nbsp
<input type="text" name="b" class="tcal" id="text" />&nbsp
<?php echo "To" ?>&nbsp
<input type="text" name="e" class="tcal" id="text" />&nbsp


<div class = "exportbtn"> 
<input type="submit" class="btn btn-info" value="Export to CSV file" name="export">
</div>

</span>

</div>
</form>

This is the html for using and accessing my export, which my export.php is the export file by date.

here is the code i used to only print to csv the selected date range that was made by the user in the html file.

$output = "";

$sql = "SELECT * FROM usernumdata";

$result = mysql_query($sql, $con) or die($sql . '<br/>' . mysql_error());
$columns_total = mysql_num_fields($result);

// Get The Field Name

for ($i = 1; $i < $columns_total; $i++) 
{
    $heading = mysql_field_name($result, $i);
    $output .= '"'.$heading.'",';
}
$output .="\n";


// Get Records from the table


$contractDateBegin = date('m/d/Y', strtotime($_GET['b']));
$contractDateEnd = date('m/d/Y', strtotime($_GET['e']));

while ($row = mysql_fetch_array($result)) 
{
    if (($row['date'] >= $contractDateBegin) && …
berserk 60 Junior Poster

ok i started to think maybe i can get the date range in an if statement rather than the sql string, and it worked, but its not limiting the date range its just printing everything out, i think this could work but im not sure whats wrong with it.

// Get Records from the table

    $current = new DateTime(); // Today
    //echo $current->format('m/d/Y'); // echos today! 
    $contractDateBegin = new DateTime($b);
    $contractDateEnd  = new DateTime($e);

    while ($row = mysql_fetch_array($result)) 
    {
        if (($current >= $contractDateBegin) && ($current <= $contractDateEnd))
        {
            for ($i = 1; $i < $columns_total; $i++) {
                $output .='"'.$row["$i"].'",';
            }
        }
        $output .="\n";
    }

thats the new while statement, and the new sql statement is this

$sql = "SELECT * FROM usernumdata";
berserk 60 Junior Poster

ok i changed it but im still getting the same result, i changed the date column to a date format, is there anything else i can do?

berserk 60 Junior Poster

do you mean just select the date field in the database and use that

berserk 60 Junior Poster

no change :< has this been removed or something as a feature, i dont understand how this isnt working anymore, maybe we have to use datetime format, idk i feel like im rambling 0.o

berserk 60 Junior Poster

i think i know what you are talking about and if i dont give the right files please let me know

the table dump im assuming is the .sql

there is a csv file thats also got some data but there isnt much, sorry about that, ill make more if u need it.

also i just wanted to say thank you for all of your help, i honestly would have given up on this already so thanks again.

berserk 60 Junior Poster

i did but im so unsure of myself that i have no idea how to set this up, i have been stuck on thi sfor days im gonna go insane 0.o

this is what i tried but its prolly wrong

$sql = "SELECT * FROM usernumdata WHERE DATE_FORMAT(NOW(),'%Y-%m-%d') >= '".$b."' AND DATE_FORMAT(NOW(),'%Y-%m-%d') <= '".$e."'";

am i missing a time on the end of date? idk i feel like im just shooting in the dark

berserk 60 Junior Poster

okay i ultimately found the root of the problem here, its entirely in this one line $sql = "SELECT * FROM usernumdata WHERE DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN '".$b."' AND '".$e."'"; if i change that line to $sql = "SELECT * FROM usernumdata"; then my export works BUT it doesnt export by dat eit just exports all the data, i need to be able to compare the dates and export based on those dates, is there a way to do it?

berserk 60 Junior Poster

i just tried taking the data from the database file and putting it all into an array file called array.php but that failed miserably i have no idea what to do on this problem :(

berserk 60 Junior Poster

sorry that was my bad for not clearly labeling, the connect is passed through to a header file which is passed to the index file
here is the connect

<?php
mysql_select_db('numbers',mysql_connect('localhost','root',''))or die(mysql_error());
?>

would it be better to do the array in one file and pas it through to any files that might need the stored data?

berserk 60 Junior Poster

sorry but can you give me a visual, i thought i was connecting the export.php like in the other file. idk im slightly confused lol

berserk 60 Junior Poster

this is the entire html index file with the export.php call at the bottom

<?php include('header.php'); ?>

<body>

<head>
<style>
.nav {
    width: 100%;
    float: right;
    margin: 0 0 1em 0;
    padding: 0;
    border-bottom: 1px solid #ccc;
    text-align: center;  }
xl {
    list-style: none;
    width: 700px;
    margin: 0 auto;
    padding: 0; }
.nav li {
    display: inline; }

.nav a:hover{
    color:red;
}
.nav li a {
    display: inline-block;
    padding: 8px 15px;
    text-decoration: none;
    font-weight: bold;
    color: #069;
    border-right: 1px solid #ccc; }

</style>
</head>

    <div class="row-fluid">
        <div class="span12">


            <div class="container">


<br><br>
                            <form method="post">
                        <table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">

                        <div class="nav">
                        <div id="menu">

                            <li class="menuitem"><a href="/">Home</a></li>
                            <li class="menuitem"><a href="/search/">Search</a></li>
                            <li class="menuitem"><a href="/table/">Reports</a></li>
                            <li class="menuitem"><a href="/upload/">Gov. File Upload</a></li>
                            <li class="menuitem"><a href="/Multi_Delete/">Report Management</a></li>
                          <li class="menuitem"><a href="/admin/">Administration</a></li>

                        <br>
                    </div>
                    </div>

                            <div class="alert alert-info">

                                <strong><i class="icon-user icon-large"></i>&nbsp;Do Not Call Information From User Submitted Data</strong>

                            </div>
                            <thead>

                                <tr>

                                    <th>Employee Name</th>
                                    <th>First Name</th>
                                    <th>Last Name</th>
                                    <th>Email Address</th>
                                    <th>Customer Address</th>
                                    <th>Phone Number</th>
                                    <th>Date Added</th>
                                    <th>Time Added</th>
                                    <th>Accidental Calls</th>
                                </tr>
                            </thead>
                            <tbody>
                            <?php 
                            $query=mysql_query("SELECT * FROM usernumdata")or die(mysql_error());
                            while($row=mysql_fetch_array($query)){
                            $id=$row['id'];
                            ?>

                                        <tr>

                                         <td><?php echo $row['empname'] ?></td>
                                         <td><?php echo $row['firstname'] ?></td>
                                         <td><?php echo $row['lastname'] ?></td>
                                         <td><?php echo $row['email'] ?></td>
                                         <td><?php echo $row['streetadd'], " ", $row['city'], " ", $row['state'], " ", $row['zip'], " ", $row['prov'] ?></td>
                                         <td><?php echo $row['numb'] ?></td>
                                         <td><?php echo $row['date'] ?></td>
                                         <td><?php echo $row['time'] ?></td>
                                         <td><?php echo $row['called'] ?></td>
                                </tr>

                                  <?php }
                                   ?>
                            </tbody>
                        </table>

</form>
<form method="post" action="export.php" >

<div style="width:100%;" class = "export"> 
<div class="alert alert-info">
&nbsp
<?php echo "Export By Date e.g. …
berserk 60 Junior Poster

well u see the problem im having is that if i copied the data into an array with the first call of mysql_fetch_array then how would i access it from my export file, if i include the main file in the export file i get a cannot change header error, is there a way around this?

berserk 60 Junior Poster

ugh my situation really sucks, i cant modify header information when im already echoing from another file on the main screen. So here is the code im using that is causing the issue.

<?php

// Database Connection

$host="localhost";
$uname="root";
$pass="";
$database = "numbers"; 
$filename = "usernumdataexported.csv";

$e = NULL;
$b = NULL;

$con=mysql_connect($host,$uname,$pass); 


// set query

if(isset($_GET['submit']))
{
    $e = $_GET['e'];
    $b = $_GET['b'];
}

//or die("Database Connection Failed");
$selectdb=mysql_select_db($database) or 
die("Database could not be selected");

// Fetch Record from Database

$output = "";

//$table = "usernumdata"; // Enter Your Table Name 
$sql = "SELECT * FROM usernumdata WHERE DATE_FORMAT(NOW(),'%Y-%m-%d') BETWEEN '".$b."' AND '".$e."'";
//$sql = "SELECT * FROM usernumdata WHERE DATE_FORMAT(NOW(),'%Y-%m-%d') >= '".$b."' AND DATE_FORMAT(NOW(),'%Y-%m-%d') <= '".$e."'";
$result = mysql_query($sql, $con) or die($sql . '<br/>' . mysql_error());
$columns_total = mysql_num_fields($result);


// only print the values from the table that align with search query

    // Get The Field Name

    for ($i = 1; $i < $columns_total; $i++) 
    {
        $heading = mysql_field_name($result, $i);
        $output .= '"'.$heading.'",';
    }
    $output .="\n";


    // Get Records from the table


    while ($row = mysql_fetch_array($result)) 
    {
        for ($i = 1; $i < $columns_total; $i++) {
            $output .='"'.$row["$i"].'",';
        }
        $output .="\n";
    }


// Download the file

header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);

echo $output;

exit;

?>

as you can see in my export.php im using a header fucntion to name the file correctly and then tell the browser to download it with the infomation in it.

</thead>
                            <tbody>
                            <?php 
                            $query=mysql_query("SELECT * FROM usernumdata")or die(mysql_error());
                            $counter = 0;
                            while($row=mysql_fetch_array($query)){ …