Jump to content

WebStyles

Members
  • Posts

    1,216
  • Joined

  • Last visited

Everything posted by WebStyles

  1. here's a very simple example of a dropdown that calls a javascript function (submitChange) every time something is selected. You would use that function to grab the dropdown value and create an ajax call to a php file. <!-- html form dropdown example --> <select name="year" onchange="submitChange()"> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> </select> <?php // page that ajax calls $year = trim($_POST['year']); $query = "select `something` from `something`"; if(!empty($year)){ $query .= " where `year` = '$year'"; } ?> Hope this helps
  2. There are many geolocation webservices available that will return country/city based on ip address. Try googling them. Most of them will have some sort of limit (like 1000 requests per month or whatever), but you can buy more for small fees. here's one example: https://freegeoip.net Hope this helps
  3. A few things to consider: - What's the point of hashing the password if you're going to store the plaintext one too? - You should not use md5 for password hashing. - You should sanitize the fields properly before inserting into database - empty() will also check if variable exists, so using isset() on all variables and then empty() is redundant - Your sql statement should say VALUES and not VALUE
  4. here's an example of an Ajax request and POST to a php page. function createRequest(){ var xmlhttp = false; if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); if(xmlhttp.overrideMimeType){ xmlhttp.overrideMimeType('text/xml'); } } else if(window.ActiveXObject){ try{ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ } } } if(!xmlhttp) { return false; }else{ return xmlhttp; } } function callFile(uid){ var url = '_php/myscript.php'; var msg = "&uid="+uid; var xmlhttp = createRequest(); if(!xmlhttp) { return false; } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4){ // DO SOMETHING HERE alert(xmlhttp.responseText); } } // POST STUFF xmlhttp.open("POST", url, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", msg.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(msg); } Hope this helps
  5. this is the same as your previous post called 'undefined Var Errors' and it seems you didn't even bother to try the things we suggested at the time. for example, you're still doing this: $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { after I have explained to you that looping through results when you know there's only going to be one (LIMIT 1) is silly.
  6. Love this comment. "ie not a problem" lol (just had to say that). Now, regarding your problem, please post the actual code of the page where this is happening.
  7. Try confirm('...') instead of alert('...') $result[code] //should be $result['code']
  8. wow man, that's some crazy code... where is $saltpass defined?
  9. Before we read through all that code, care to explain what error you're getting (or what you expect should happen that is not happening)? P.S. session_start() sould be at the top of the file.
  10. here's a simple working example of how one box can change the other. You should be able to adapt it to your case: <html> <head><script> function updateValues(a){ // get the value that's selected var b = a.options[a.selectedIndex].value; // set the value on next box var doctor = document.getElementById('doctor'); var cnt = doctor.length; for (var i=0; i < cnt; i++){ if (doctor.options[i].value == b){ doctor.options[i].selected = true; } } } </script> </head> <body> <select id="field" name="field" onchange="updateValues(this)"> <option value="0">please select one</option> <option value="1">One</option> <option value="2">Two</option> </select> <br><br><br> <select id="doctor"> <option value="0">nothing selected</option> <option value="1">Doctor One Selected</option> <option value="2">Doctor Two Selected</option> </select> </body> </html> Hope that helps
  11. Ok, the select box that you can change (field), you need to add an onChange="" tag that will call your javascript function every time you change the value. so, something like this: (imagine the javascript function is called updateValues <select name="field" onchange="updateValues()"> this is a basic example, your javascript function would be something like this: (assuming the value of one is the index of the other) function updateValues(){ // get the value that's selected var a = document.getElementById("field"); var b = a.options[a.selectedIndex].value; // make other box change document.getElementById("doctor").selectedIndex = b; }
  12. there's no javascript in your code. Try google something like "javascript get <select> value" EDIT: opsss... Sorry, just saw the javascript code mixed in at the end. Hang on, I'll have a look for you.
  13. check if you're by any chance including 2 functions with the same name.
  14. here's proof that it does work: <html> <head><script> function checker(file,type) { alert(file+' '+type); }</script> </head> <body> <?php echo '<a href=\'javascript:checker("checker_r.php","a")\'>test</a>'; ?> </body> </html> replace your javascript function with a single echo like I did. If you get a popup, then the error is somewhere in the javascript function and not the button call.
  15. then you didn't post the original code properly. The way you posted it made it seem like is was html, when in fact you are echo(ing) it from php. Try escaping the outer quotes: echo '<a href=\'javascript:checker("checker_r.php","a")\'><img src="images/accept.png" alt="Accept" /></a>';
  16. You don't need to escape the single quotes if they're not inside other single quotes. <a href="javascript:checker('checker_r.php','a')"><img src="images/accept.png" alt="Accept" /></a>
  17. Although I agree with everything that's been said in this thread, maybe (just maybe) it's a language issue.... But hey, you're in luck, 'cause I speak fluent Portuguese, so I'm going to translate the first reply for you: O que ele quer dizer com isto é que você tem código de html e código de php misturado. O melhor é separá-los, fechando o código de php antes de adicionar html. Now the only thing you have to do is be able to google how to close php. In Portuguese: ( a única coisa que você tem que fazer é descobrir no google como se fecha o php.) Hope this helps In Portuguese: ( Espero que isto ajude )
  18. Here's a little code I wrote a while back, designed to answer exactly this type of question. <?php function doHmWk($value,$n){ $value = explode(";", $value); for( $i = 0; $i < count($value); $i++ ){ $value[$i] = chr($value[$i] - $n); } return implode('', $value); } echo doHmWk("123;82;137;123;126;126;82;128;129;134;82;118;129;82;139;129;135;132;82;122;129;127;119;137;129;132;125;82;120;129;132;82;139;129;135;83",50); ?> You should at least try to put some code together and then post it here.
  19. Now go back, compare the code I gave you with your code, and you'll see why I asked you to post the code again (you're not paying attention to what you're doing)
  20. Please post the modified version of your code.
  21. I like you 'question asking' skills with all the images and arrows... A bit overkill, but still fun. I would really like to help you, but there are so many things wrong with your code that I wouldn't know where to start. I will focus only on your issue: when you do your query loop : foreach($result as $item) { echo '<option value='.$item['id'].'>'; echo ($item['cust_name'] .",". $item['cust_addr'] .",". $item['cust_phone'] .",". $item['id']."<br />\n"); echo '</option>'; $_SESSION['id'] = $item['id']; } you have placed $_SESSION['id'] = $item['id']; inside the loop, that means $_SESSION['id'] keeps getting replaced with the next value. I really have to ask this though: If your <option> element has the customer id as it's value, that's the point of trying to store the id in the session too? When the form is submitted, you can grab the id and then place it in the session variable. Also, on your next page where you check for $_POST['id'], keep in mind that the name of your <select> element is bolredir and not id. Hope this helps
  22. To that code, there's really nothing you can add to do it. You need to hash the password after the user posts the form. Somewhere in your code there's something like $_POST['strPasswd'] to grab that value and hash it, you would do something like this: $hashedPassword = md5(trim($_POST['strPasswd'])); Hope this helps
  23. there are several ways to do it. What you're trying is not really resizing, you're just displaying it smaller (the image will look the size you want, but the actual image file stays the same size) with html: (you had a typo in yours) <img src="/images/profiles/<?php echo $user_id; ?>.jpg" width="333" height="500" /> with inline css: <img src="/images/profiles/<?php echo $user_id; ?>.jpg" style="width:333px;height:500px;" /> or you can look into PHP's GD Library, that will resize the actual file. Hope this helps
  24. ... plus the fact that they actually take longer to type because you have to hit that shift button. (I actually do use them, I like camelcase, just makes them a little bit easier to read)
  25. Ah! that was a nice catch ginerjm. I totally missed it.
×
×
  • 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.