Jump to content

DataSpy

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

DataSpy's Achievements

Member

Member (2/5)

0

Reputation

  1. echo back birthday to see what you get before you enter it into the database, it looks like it would come out as 0000, 00, 00 instead of 0000-00-00
  2. Here's a revision of the above code for the edit items page, this code lets you know if the update was successful, this will show you how to use one page to display, edit, and then update the data in one page <?php include("../../Connections/db_connection.php"); // if update button has been pressed, this updates the db if(isset($_POST['update'])) { // assign vars $Asset = mysqli_real_escape_string($con, trim($_POST['Asset'])); $Manufacture = mysqli_real_escape_string($con, trim($_POST['Manufacture'])); $query = "UPDATE shop_inventory SET Manufacture='$Manufacture', ect... WHERE Asset = '$Asset'"; $result = mysqli_query($con, $query) or die(mysqli_error($con)); if($result) { ?> <script language = "javascript"> alert('Update Successful'); </script> <?php } else { ?> <script language = "javascript"> alert('Update Failed'); </script> <?php } } //this is the data you got from status page $Asset = mysqli_real_escape_string($con, trim($_GET['Asset'])); $query = "SELECT * from shop_inventory WHERE Asset = '$Asset'"; $result = mysqli_query($con, $query) or die(mysqli_error($con)); if($result) { $row = mysqli_fetch_array($result, MYSQLI_ASSOC); echo" <!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>Add Items</title> </head> <body> <form name=\"myForm\" action=\"$_SERVER[php_SELF]\" method=\"post\"> Asset Number: $row[Asset]<br /> Manufacture: <input type=\"text\" name=\"Manufacture\" value=\"$row[Manufacture]" /><br /> <input type=\"hidden\" name=\"Asset\" value=\"$row[Asset]" /> <input type=\"submit\" name=\"update\" value=\"Update\"> </form> </body> </html> "; } ?>
  3. I wrote a nice long reply but I got distracted so the page timed out and I lost everything I wrote Anyways, you want to pass the data in the URL and then retrieve it on the next page using the GET method Status Page Instead of this echo "<td> <button onClick=../subpages/edititems.php>" . $row['Asset'] . "</button> </td>"; use this, I'm using a link instead of a button but you can change it to meet your needs <a href=\"edititems.php?Asset=$row[Asset]\" target=\"_blank\">Edit</a> Edit Items page //this is the data you got from status page $Asset = mysqli_real_escape_string($con, trim($_GET['Asset'])); $query = "SELECT * from shop_inventory WHERE Asset = '$Asset'"; $result = mysqli_query($con, $query) or die(mysqli_error($con)); if($result) { $row = mysqli_fetch_array($result, MYSQLI_ASSOC); echo" <form name=\"myForm\" action=\"afteredititems.php\" method=\"post\"> Asset Number: <input type=\"tex\t" name=\"Asset\" value=\"$row[Asset]" /> "; }
  4. If you've learned this much in three weeks I'd say you're doing really well, keep up the good work!!! I'm not a good programmer or anything but I know a little and the first thing I would say is learn use mysqli instead of mysql, you can read more about it here. http://www.php.net/manual/en/book.mysqli.php
  5. I'm using system() to run NMAP and then display the output but it's one big string, how can I format it to look like what I see in the command line? web app output: Starting Nmap 5.00 ( http://nmap.org ) at 2012-03-21 18:44 CDT Interesting ports on localhost (127.0.0.1): Not shown: 993 closed ports PORT STATE SERVICE 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 443/tcp open https 445/tcp open microsoft-ds 631/tcp open ipp 3306/tcp open mysql Nmap done: 1 IP address (1 host up) scanned in 0.11 seconds 0 command line output: Starting Nmap 5.00 ( http://nmap.org ) at 2012-03-21 18:48 CDT Interesting ports on localhost (127.0.0.1): Not shown: 993 closed ports PORT STATE SERVICE 80/tcp open http 111/tcp open rpcbind 139/tcp open netbios-ssn 443/tcp open https 445/tcp open microsoft-ds 631/tcp open ipp 3306/tcp open mysql Nmap done: 1 IP address (1 host up) scanned in 0.45 seconds <?php // path to NMAP $Path = '/usr/bin/nmap'; if(isset($_POST['scan'])) { $IP = $_POST['IP']; $ScanType = $_POST['ScanType']; echo "<br /><u>Results for NMAP Scan</u> <br />"; system("$Path $ScanType $IP 2>&1", $Output); echo $Output; } ?> any help would be greatly appreciated, thanks in advance!!
  6. Thanks for all of the replies!!! I used if () instead, sorry about being a dumbass . I was looking at an example of something but I changed a lot of code and in the end didn't need to use preg_match. Thanks!!!!!!!!!
  7. This is my first time using preg_match and I'm a little confuesed I'm trying to match an array against zero but I keep getting the error: Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in $IP = implode('.',$Start); $Command = shell_exec("ping -c 1 -w 1 $IP"); $data = explode(',',$Command); $data = $data[1]; if(preg_match("0", '$data')) { echo "$IP online <br />"; } any help would be greatly apprenticed, thanks in advance!!!
  8. I'm trying to format a date to use in a mysql query and was wondering about the best way to do it. the form returns: mm/dd/yyyy and I need to format it to yyyy-mm-dd, any help would be greatly appretitaed, thanks in advance!
  9. What I want is to have a button and when the button is pressed it creates a drop down menu and if it's pressed again then it creates a second drop down menu. I've been googling but haven't found anything yet if someone has an idea or a tutorial that they could direct me to that would be awesome!!!! Any help is greatly appreciated, thanks in advance!!!
  10. I'm not sure how this would be done with php or something else, what I want is to have a button and when the button is pressed it creates a drop down menu and if it's pressed again then it creates a second drop down menu. I've been googling but haven't found anything yet if someone has an idea or a tutorial that they could direct me to that would be very helpful!!!! Any help is greatly appreciated, thanks in advance!!!
  11. This works $(document).ready(function() { var focusables = $(":input").not('[type="image"]').not('[type="submit"]'); focusables.keydown(function(e) { if (e.keyCode == 13) { e.preventDefault(); var current = focusables.index(this), next = focusables.eq(current + 1).length ? focusables.eq(current + 1) : focusables.eq(0); next.focus(); } }); });
  12. I accidentally posted this in the wrong forum, this is a jquery question not an ajax question.
  13. I have a search form (phone or name), the search form is submitted with an onblur and then processed by php and returned to the same page with ajax. In the original page (index.php) I include a file (add_reservation.php) which holds the Search form, the output of the search for goes to a div with the results from ajax. I'm not even sure if this is possible or if I'm going about this the right way but what I want to happen is when the search form is submitted I want to hide the included file (add_reservation.php) because I don't want two tables to show up with with search form and results. you can see an example of what I'm talking about @ www.data-spy.net/test/ type 000-000-0000 into the phone field or type bank into the name field and tab through both input boxes, the result creates a second table (and an output of my sql query) which is the one I want to keep since the previous table has no data in it, if neither field is filled out it just echos back the sql query. Index.php <!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" xml:lang="en" lang="en"> <head> <title>Reservations</title> <script type="text/javascript" src="jquery-1.6.2.js"></script> <script> function get_customer_info() { $.post('get_customer_info.php', { customer_number: $('form[name=add_reservation_form] input[name=number]').val(), customer_name: $('form[name=add_reservation_form] input[name=name]').val() }, function(output) { $('#number_div').html(output).show(); }); } </script> </head> <body> <?php require("add_reservation.php"); ?> <div id="number_div"></div> </body> </html> add_reservation.php <?php echo' <form name="add_reservation_form"> <table width="50%" border="1" align="center"> <tr> <td colspan="2" align="center"> Search </td> </tr> <tr> <td> Phone </td> <td colspan="2"> <input type="text" name="number" size="22"/> </td> </tr> <tr> <td> Name </td> <td colspan="2"> <input type="text" name="name" onblur="get_customer_info();" size="22"/> <input type="hidden" name="submitted" value="yes"/> </td> </tr> <tr> <td colspan="3" align="center"> Customer Info </td> </tr> <tr> <td> Home </td> <td> </td> </tr> </table> </form>'; ?> get_customer_info.php <?php require("config.php"); require("dbconnect.php"); $customer_number = mysqli_real_escape_string($con, trim($_POST['customer_number'])); $customer_name = mysqli_real_escape_string($con, trim($_POST['customer_name'])); if(!empty($customer_name)) $customer_name = "%$customer_name%"; else $customer_name = $customer_name; $query_get_customer_info = "SELECT customers.customer_homenumber, customers.customer_email, customers.customer_firstname, customers.customer_lastname, customers.customer_address, customers.customer_zipcode, cities.city_name, states.state_name FROM customers LEFT JOIN cities ON customers.customer_city_id = cities.city_id LEFT JOIN states ON customers.customer_state_id = states.state_id WHERE customer_lastname LIKE '$customer_name' OR customer_homenumber = '$customer_number' OR customer_mobilenumber = '$customer_number' OR customer_worknumber = '$customer_number'"; $result_get_customer_info = mysqli_query($con, $query_get_customer_info) or die(mysqli_error($con)); $num_rows = mysqli_num_rows($result_get_customer_info); if($num_rows == 0) { echo $query_get_customer_info; } else { while($row = mysqli_fetch_array($result_get_customer_info)) { echo" <form name=\"add_reservation_form\"> <table width=\"50%\" border=\"1\" align=\"center\"> <tr> <td colspan=\"2\" align=\"center\"> Search </td> </tr> <tr> <td> Phone </td> <td colspan=\"2\"> <input type=\"text\" name=\"number\" size=\"22\"/> </td> </tr> <tr> <td> Name </td> <td colspan=\"2\"> <input type=\"text\" name=\"name\" onblur=\"get_customer_info();\" size=\"22\"/> </td> </tr> <tr> <td colspan=\"3\" align=\"center\"> Customer Info </td> </tr> <tr> <td> Home </td> <td> $row[customer_homenumber] </td> </tr> </table> </form>"; } echo $query_get_customer_info; } ?> Any help greatly appreciated, thanks in advance!!!!!!!!!!!!
×
×
  • 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.