Jump to content

at0mic

Members
  • Posts

    26
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

at0mic's Achievements

Member

Member (2/5)

0

Reputation

  1. I've created a website where people register/login and have a profile which people can search and there's different levels of security etc. However, the login process is very basic because I dont know enough about secure authentication etc. Therefore, I've decided it would be best to use an authentication library that's designed by expets and will get updates when holes and found etc. I've looked at uLogin but it seams a little bloated with 43 files totaling 141Kb. I've looked at other libraries but they're no longer being maintained. What do you guys use for authentication? Or do you create your own?
  2. Yes you're right, I cant believe I forgot the echo. It works now thanks. I'm mostly using IE7 and IE8. I haven't tested it with IE6 yet.
  3. I'm accessing the GET data using: echo $_GET['data']; If I use plain text in the URL like in the following example, I can echo the GET data from the target php page. var url = 'get_results.php?data=phpfreaks&search='+v; However, if use a php variable, I cant access it from the target php page. Also, I've noticed that even with the original code, I get an error in Internet Explorer which appears at the bottom left of the window next to "Done" but the live search still works ok. Message: 'document.getElementById(...)' is null or not an object Line: 32 Char: 4 Code: 0 Line 32 contains the following: document.getElementById("input_value").innerHTML = v;
  4. One more question, I've got the search field in a php file with GET data in the URL. How can I access the GET data from the get_results.php page? I've tried adding it to the URL in the javascript as PHP variables like the following: var url = 'get_results.php?data=<?php $_GET['data'] ?>&search='+v; But it doesn't seem to work. Any ideas?
  5. I just tried that out and it still works ok. I always like it when code can be shortened so thanks again.
  6. Here's a simple Ajax Live Search which works perfectly. When the page loads, the results are empty. As you type in the text field, the results start to appear and they decrease and you type in more text. If you delete the text from the text field, all the results are shown. How can I change it so that all the database results are shown when the page is loaded and then start to disappear as you type? index.htm <html> <head> <title></title> <script> function open_xmlhttp_stream() { var xmlhttp = false; try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}catch(e){xmlhttp = false;}} if(!xmlhttp && typeof XMLHttpRequest!='undefined'){try{xmlhttp = new XMLHttpRequest();}catch(e){xmlhttp=false;}} if(!xmlhttp && window.createRequest){try{xmlhttp = window.createRequest();}catch(e){xmlhttp=false;}} return xmlhttp; } function get_results(v) { var my_request = open_xmlhttp_stream(); var url = 'get_results.php?search='+v; my_request.open("GET",url,true); my_request.onreadystatechange=function() { if(my_request.readyState==4 && my_request.status==200) { document.getElementById("query_results").style.visibility="visible"; document.getElementById("query_results").innerHTML = my_request.responseText; if(!document.getElementById("query_results").innerHTML) { document.getElementById("query_results").style.visibility="hidden"; } document.getElementById("input_value").innerHTML = v; } } my_request.send(null); } </script> </head> <body> <form method="POST"> <input id="search" type="text" name="search" onkeyup="get_results(this.value);"> <div id="input_value"></div> <div id="query_results"></div> </form> </body> </html> get_results.php <?php include ('../includes/config.php'); $search = $_GET["search"]; $query = "SELECT name FROM staff WHERE name LIKE '%{$search}%'"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { echo $row['name']. "<br />"; } ?>
  7. I’m trying to get the output of a dropdown menu into a php variable so I can use it to do queries etc. The following code does work, but the div tags are also saved in the variable. Is there another way of doing it without the div tags? Maybe by adding it to _GET in the onchange command. <select name='trade' onchange="document.getElementById('extra').innerHTML = this.value;"> <option value='item1'>item1</option> <option value='item2'>item2</option> <option value='item3'>item3</option> <option value='item4'>item4</option> </select> <?php $extra = '<div id="extra"></div>'; echo $extra ?>
  8. Of course yes you're right. I just changed it to time() and it worked perfectly. So thanks cbolson for your query and thanks PFMaBiSmAd for the date info.
  9. pf_date is the number of seconds that have passed since Jan 1 1970
  10. Here is the code I'm using: $query = "SELECT pf_type, MIN(pf_date) FROM paignton_fixtures WHERE pf_date > curdate() GROUP BY pf_type"; $result = mysql_query($query) or die(mysql_error()); while( $row = mysql_fetch_array( $result ) ) { $pf_date = date('d M y', $row['MIN(pf_date)']); echo "<tr><td>{$row['pf_type']}</td><td>$pf_date</td></tr>"; } This retrieves the following from MySQL TypeDate Colts22 Aug 09 Development22 Aug 09 First08 Aug 09 Ladies03 Oct 09 Vets12 Sep 09 The pf_type part is working ok because it correctly retrieves one of each. However the date part isn't working because 08 Aug 09 is in the past. I want it to retrieve the next dates in the future for each type. Not an apparently random date.
  11. Thanks for your post but your code gave the error: I added the GROUP BY clause but some of the dates were in the past. Any other ideas? Here's the actual code I used $query = "SELECT DISTINCT(pf_type), MAX(pf_date), pf_date FROM paignton_fixtures WHERE pf_date > curdate() GROUP BY pf_type ORDER BY pf_date DESC";
  12. With reference to the tizag article "MySQL GROUP BY - Aggregate Functions" here http://www.tizag.com/mysqlTutorial/mysqlgroupby.php I've got something similar with an additional date collumn. I want to show one of each type where the date is most recent (but not past). I've tried the following but it doesn't work: $today = getdate(); $query = "SELECT type, date FROM products WHERE date > '$today' GROUP BY type"; I could do a seperate query for each type but it would be nice if there's a way to do it with one query.
  13. Hey that works! So I was using single quotes instead of double quotes (I didn't think it would make a difference). Anyway it works so thank you so much
  14. Instead of: $_POST['value1'] $_POST['value2'] $_POST['value3'] $_POST['value4'] $_POST['value5'] How can I auto increment them? I've tried using a while array but I cant get a variable to work inside the field. I've tried these: $_POST['value$number'] or $_POST['value{$number}'] or $_POST['value"$number"'] but none of them work. Is it possible to do?
×
×
  • 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.