Jump to content

Vel

Members
  • Posts

    130
  • Joined

  • Last visited

Everything posted by Vel

  1. Your best bet is to use either session, or possibly better, a cookie. If you use a cookie it'll remember the users selection between visits to the site.
  2. Why would you need to SQL selects? You simply encrypt the password before running any query and then compare that with the one in the database. There's no need for any second SQL select.
  3. Not true, you only need to start the session before sending headers. You can set session data after headers have been sent.
  4. If you have your passwords encrypted, sure there is. To compare against the encrypted version of the submitted password. Because we KNOW you're not storing passwords plain text, right? No, that you do in SQL and only in SQL. Muddy is right, don't load passwords from the database.
  5. Should be if($name && $comment) And as others have pointed out, validate/sanitize your code before putting them anywhere near an SQL statement.
  6. Google translate tool is pretty good. http://gtranslate.net/ is a great little tool that uses it. You can see it in action in a site my company built here.
  7. I solved it. Thank you PFMaBiSmAd, you put me in the right frame of mind to solve it. Thinking outside of the box the issue is we use SEO friendly URLs. The form was submitting to booking-form.php?id=15 and the email was sent there, then the SEO URL kicked in redirecting the page to booking-form with no POST data, so no message was displayed. All I had to do was change the form to submit to booking-form so that the SEO URL didn't kick in and redirect the page and the message showed perfectly fine. Thanks for all your help guys. Its always great to be able to bounce problems around on here.
  8. 100% sure, because I have them being stored in the SESSION['msg'] and that IS showing the correct value. I'm setting and unsetting the session variable on the same page right now because it was the only way I could get the message to show. It was to prove the $msg was in fact triggering properly inside the if statement but not accessible outside. I ran your test and the script never hit the die message, which is really confusing because it did send me the e-mail. Now I'm even more confused.
  9. You've left yourself wide open for SQL Injection attacks. Before using anything a user submits in a SQL statement always escape it. Your SQL statement should be: <?php $u = mysql_real_escape_string(trim($_POST['username'])); $p = mysql_real_escape_string(trim($_POST['password'])); $q = "SELECT * FROM `nm_users` WHERE `username`='$u' AND `password`= PASSWORD('$p') LIMIT 1"; Also, just me but I wouldn't use LIMIT 1. I would allow as many results as possible and then use mysql_num_results to see if there are more than 1. If you use unique usernames and more than 1 result comes back you know something isn't right .
  10. Hi guys, I have an interesting situation and I was hoping someone could explain what is going on to me. I have an enquiry form on a site that sends an e-mail. All the code is on one page with the form submitting back to the same page. I have a variable, msg, which at the top of the page is set to nothing and then an if statement to see if the form was submitted. If the form was submitted then msg will have one of three messages in it by the end (regardless of anything else). However when I check the msg variable after the if statement it is empty. To test if it was being affected I changed the initial value from nothing to TEST. After the IF statement the variable still held the value TEST, thus confirming it wasn't being affected by the IF statement. Now onto my code (the whole page is over 600 lines long so I'm only posting the relevant code): <?php session_start(); $msg = ''; $input = array( 24 variables from form here... ); if(isset($_POST['form-submitted'])) { $missing_info = FALSE; $array = array( variables along with their filter validation/sanitize types... ); $input = filter_input_array(INPUT_POST, $array); /* PHP validation code checking appropriate fields were not empty. If they were set $missing_info = TRUE */ if(!$missing_info) { /* Construct e-mail, this sends successfully. */ if(mail($to, $subject, $content, $headers)) { $msg = '<div class="message"><h1>Form Sent</h1><br />Your form has been sent to us. We endevour to respond to all booking requests with 2 working days. If you have not heard from us in that time please contact us on 01462 893620. If you chose to confirm by post please allow 5 working days before contacting us.</div>'; $_SESSION['msg'] = $msg; } else { $msg = '<div class="message"><h1>Technical Issues</h1><br />We appologise but the website is currently experiencing technical difficulties. Please try again later or print this form out and post / fax it to us. Alternatively you can call us on 01462 893620.</div>'; $_SESSION['msg'] = $msg; } } else { $msg = '<div class="message"><h1>Incomplete Form<h1><br />Please make sure to complete all fields of the form before submitting your booking request.</div>'; $_SESSION['msg'] = $msg; } } if(isset($_SESSION['msg'])) { $msg = $_SESSION['msg']; unset($_SESSION['msg']); } ?> If I don't load the message into session and then back out of session after the if statement then $msg will still hold whatever it was initially set to (in this case an empty string). Why isn't it set in the if statement?
  11. I don't think you're using the right function for what you want. When Ajax submits a request like that voting.php is only opened on the server, with the response sent back to your machine. You'll never be able to see what's in voting.php on your machine.
  12. Check out something like this - http://www.kidmoses.com/blog-article.php?bid=56
  13. Don't even need to use ".$name.", can just put $name straight in there.
  14. Please actually read my OP and code before assuming I'm an idiot.
  15. I already tried restarting it with no results and the fact that I can post the variables in the function and everything works fine proves that MySQL is running fine. The only error I'm getting is the MySQL Error: No database selected. I have full error logging turned on and am getting 0 PHP errors. I'm really pulling my hair out over this one, any help is really appreciated.
  16. You haven't told PHP to look for any results. $('.stars').bind('click', function() { var star = this; var data = {'q' : $(star).attr('id') }; $.ajax({ type:'post', url:"voting.php", data:data, dataType:'json', success: function(result){ alert(result); } }); return false; });
  17. Hey guys, I have come across what I think is one of the craziest bugs I have ever seen. I'm developing a site on my local machine using WAMP (version 2.2). I have a pretty standard database connection class but for some reason all of a sudden tonight it's stopped working. The code: if(!defined("IN_PHPBB")) { exit; } require 'config.php'; class db_conn { public $connection = NULL; function db_conn() { global $abchost, $abcname, $abcpasswd, $abcuser; if(!$this->connection = mysql_connect($abchost, $abcuser, $abcpasswd)) { echo "Error connecting to the database. Please check the config file."; if(defined('DEBUG')) { echo "<br />MySQL Error: " . mysql_error(); } exit; } if(!mysql_select_db($abcname, $this->connection)) { echo "Error selecting the database. Please check the config file."; if(defined('DEBUG')) { echo "<br />MySQL Error: " . mysql_error(); } exit; } } } $db_conn = new db_conn; Config.php contains nothing but the four variables for connecting to the db. Nothing has changed across either file but for some reason if I try to echo out the variables in the function they are all empty. Even stranger, the first part of the connection works (with 3 empty variables!), and it's mysql_select_db that's throwing an error. Why, completely out of the blue, with nothing changing, would the function not be able to read the variables any more. If I manually copy and paste the variables from the config file into the class function then it connects fine.
  18. Thank you Kieth. That is exactly what I was after.
  19. AHA! Just googled group by. How the hell have I never come across that before? Thank you, that was exactly what I was after. OK, well, not 100% what I was after but much, much closer. Is there a command I can use to now get it to show the specific poOptionGroup without excluding those that don't match?
  20. Sorry, what do you mean group by p.pID? That's an individual ID for a product and is used in the join to reference to poProdID (they are the same).
  21. Hi Zane, Thanks for the post but this has produced the exact opposite of what I was after. I need to display all rows from table p, regardless of whether they have a corresponding result in po or not, hence the left join. The problem is when they have multiple results in po they output multiple times in the list. I'm trying to limit it so that a product is only listed once in the results and that poOptionGroup returns NULL unless it matches a specified ID. But even if it doesn't have a matching ID under poOptionGroup the product still needs to output. E.G: Dataset (Products) pID pName pc001 PC package #1 portable001 Portable PC #1 scanner001 Scanner #1 Dataset (optiongroup) optGrpID optGrpName 1 Processor 2 Harddrive 3 Network Card 4 Monitor 5 Resolutions Dataset(prodoptions) poID poProdID poOptionGroup 1 pc001 1 2 pc001 2 3 pc001 3 4 pc001 4 5 scanner001 5 The results I get are pc001 1 pc001 2 pc001 3 pc001 4 portable001 NULL scanner001 5 If I select poOptionGroup = 5 I want to get pc001 NULL portable001 NULL scanner001 5 but instead I only get the scanner.
  22. Hi, I'm trying to build a complicated SQL statement and I'm not sure if what I want is even possible. I have a table called products, another called optiongroup and a third called prodoptions. Products contains a list of individual products available for sale. Optiongroup contains a list of options that can be applied to products. A product can have several options and an option can be applied to several products. Prodoptions records what optiongroups are attached to what products. I am trying to run a query on the Products and Prodoptions tables to pull all products matching a set of criteria (name, price, type, etc.) and then I select one optiongroup. I want the query to show all products that match the initial criteria, and then if they have an optiongroup that matches the one selected to retrieve the details from Prodoptions, otherwise have the field be null. So far I have tried this query: SELECT pID, pName, poOptionGroup FROM products LEFT JOIN prodoptions ON products.pID = prodoptions.poProdID ORDER BY pName Which will display every product fine, but returns a product multiple times if it has more than one optiongroup attached to it. E.g.: pc001 #1 PC multimedia package 8 pc001 #1 PC multimedia package 6 pc001 #1 PC multimedia package 7 pc001 #1 PC multimedia package 9 scanner001 Flatbed scanner NULL GlassTopDiningTable Glass Top Dining Table NULL GraniteDiningTable Granite Top Cafe Dining Table NULL lprinter001 Laser Printer NULL palmtop001 Palmtop Computer 6 palmtop001 Palmtop Computer 7 portable001 Portable PC 10 RoundWoodTable Round Wooden Table NULL I also tried: SELECT pID, pName, poOptionGroup FROM products LEFT JOIN prodoptions ON products.pID = prodoptions.poProdID WHERE poOptionGroup = 6 ORDER BY pName However that only displays products that have optiongroup with an ID of 6 attached to them, and not all products even if they don't have optiongroup 6 attached. So can I do this and if so how?
  23. I have a CMS system that uses SuperFish to build the menu on the front end. On the back end one of the most common comments we received was users found it hard to relate the back end menu to the front end menu. Our solution, make an editable copy of the front end menu in the back end. This involved combining the jQuery UI selectable feature with a SuperFish menu. The initial integration works great. I have a menu bar with 2 tiers of drop down menus on them and I can move items around on the menu fine. I can select an item in a child menu and move it to it's parent fine, however I can't move an item to a child menu because whilst the drag feature is functioning hovering over a SuperFish menu doesn't open it. What I need to do is try to find a suitable way to open all the child menus when select is active. I thought something like this would work: start: function(event, ui) { $('ul.main-menu').showSuperfishUl(); }, stop: function(event, ui) { $('ul.main-menu').hideSuperfishUl(); } However that just creates an ever increasing number of white spaces every time I move my mouse whilst dragging an item in a menu. Is there a way to open all of the child menus of the active select menu?
  24. Unless it's a function the Javascript executes with what's already on the page. If you load something new in Javascript doesn't recognise it. What you need to do is include the relevant Javascript at the bottom of your "other file", the one being called by Ajax. Without seeing your code I can't offer any more advice than that.
  25. Saying this is basically the code I'm using isn't much help. Please post the actual code you are using. I'm sure you've made modifications to that code in the tutorial so it fits in with your site, we need to see what they are.
×
×
  • 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.