Jump to content

GoodVibe

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

GoodVibe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Do you mind explaining what that one does? How does it sanitize the data?
  2. I have the following code: /Sanitize the username var tagBody = '(?:[^"\'>]|"[^"]*"|\'[^\']*\')*'; var tagOrComment = new RegExp( '<(?:' // Comment body. + '!--(??[^->])*--+|-?)' // Special "raw text" elements whose content should be elided. + '|script\\b' + tagBody + '>[\\s\\S]*?</script\\s*' + '|style\\b' + tagBody + '>[\\s\\S]*?</style\\s*' // Regular name + '|/?[a-z]' + tagBody + ')>', 'gi'); function removeTags(html) { var oldHtml; do { oldHtml = html; html = html.replace(tagOrComment, ''); } while (html !== oldHtml); return html.replace(/</g, '<'); } var userNames = new Array("temp","curseword","Temp"); $('#userid').blur(function(){ var userId = $('#userid').val(); var safeId = removeTags(userId); if (safeId.length < 6){ $('#nameCheck').html('The username must be at least 6 characters'); } else if (safeId.length == userId.legth){ $('#nameCheck').html('Please only use alphanumerical characters'); } else if(userId.length >= 6){ var unique = true; for (i=0; i<userNames.length; i++){ if (userId == userNames[i]){ unique = false; } } if (unique == false){ $('#nameCheck').html('The username ' + safeId + ' is taken, please try another one'); } } else { $('#nameCheck').html('The username is correct and you can use it'); } }); Now, the problem I am having is that what i want it to do is that when someone tries to input something that isnt alphanumerical its supposed to tell them so, but so far it does not change the display. Checking for length and such works fine, its just the sanitation part that is giving me troubles. Any ideas?
  3. Ok, so i narrowed it down to either one of these lines: userId = userId.replace(/<[^>]*>?/g, ''); $(this).attr('value', userId); As to the change: $(this).attr('value', userId); to $(this).val(userId); will that also change the value? I am trying to make it so that when the user types a character that is not valid it removes and keeps the valid username. Thanks for the help so far
  4. Hi, no, I haven't been using the addons, completely forgot about them. As for the file paths, I know that the ../ means to go one folder up in the tree correct? The file paths are correct, and after a little bit more searching I have found out that my problem lies in: var userId = $(this).val(); alert (userId); userId = userId.replace(/<[^>]*>?/g, ''); $(this).attr('value', userId); I was trying to use this to sanitize my input, but it seems to be crashing the program. ANy suggestions on that? Also, I had a quick question. I have seen people add the line <script type='text/javascript' src="js/register.js"></script> In the header of the page. The tutorials I have been following tell me to do so at the end of the body. What is the difference? Thanks
  5. To grab the value of the currently selected item on your dropdown list: var list_value = $('#YourListID').val(); Is that what you are looking for?
  6. I am trying to make a basic form for registering, and trying to validate it. For some reason, it will not call the js at all. I have even reated an alert to popup when the page loads and i am getting nothing. Maybe Im missing something simple, so any help would be appreciated. Here is my main file: <html lang="en"> <head> </head> <body> <form action="#"> <b>User Name</b> <input type="text" id="userid" /> <span id="nameCheck"></span> <br/><br/> <b>Password</b> <input type="password" id="password" /> <span id="passCheck"></span> <br/><br/> <b>Re-enter Password</b><input type="password" id="password2" /> <span id="pass2Check"></span> <br/><br/> <b>E-mail</b><input type="text" id="email" /> <span id="mailCheck"></span> <br/><br/> <b>Re-enter Email</b><input type="text" id="email2" /> <span id="mail2Check"></span> </form> <script type='text/javascript' src="js/jquery.js"></script> <script type='text/javascript' src="js/register.js"></script> </body> </html> And here is my js: $(function(){ alert ('We have JS'); }); var userNames = new Array("temp","curseword","Temp"); $('#userid').blur(function(){ var userId = $(this).val(); alert (userId); userId = userId.replace(/<[^>]*>?/g, ''); $(this).attr('value', userId); if (userId.length < 6){ $('#nameCheck').html('The username must be at least 6 characters'); } else if(userId.length >= 6){ var unique = true; for (i=0; i<userNames.length; i++){ if (userId == userNames[i]){ unique = false; } } if (unique == false){ $('#nameCheck').html('The username is taken, please try another one'); } } else { $('#nameCheck').html('The username is correct and you can use it'); } });
  7. The reason I suggested that is for re usability. He is echoing the variable twice, and in my personal taste, it is easier to define the variables that way any changes in the future are easy to made. As far as wasting processing power I did want to ask what is the difference between storing the variable and calling the htmlentities function twice for every echo?
  8. From what I am seeing, the easiest way to do this is to use double quotes, since it will allow you to echo your php variables. Also, I would suggest that you store the variables before your echo statement Try this: while($row = mysql_fetch_array($result)) { $vendorId = $row['vendor_id']; echo "<option value='$vendorId'>" . $vendorId. '</option>'; }
  9. I do not know enough math or PHP to try to write one myself I did not know of the existence of mt_rand(), but when i was researching random number generators I did notice that the one it uses is one of the faster and more "accurate" methods out there. Thank you for the help.
  10. Hello everybody, I just have a quick question. I am trying to develop a webpage for dice rolling (to use for myself when i play dnd) Now, I know a lot of the random functions is computer languages are not truly random, and thus have some areas that the value will be the result more than others. What would be a good way to try to make it as "random" as possible, or am I just over-thinking it?
  11. Ended up using: $mxr = dns_get_record($sub, DNS_MX); So thank you very much Muddy for the suggestion and everyone for the help.
  12. The thing that confuses me is that i see that mxhosts is the array that will give me the mxhosts, but then the return value says that it only does true/false. So I am a little confused as to how call that array with the values if I am just passing it as a parameter. To Muddy: The list of hosts I have should not have more than one mx record, and if they do, I only care to see the first one, so that method that you posted might work.
  13. I currently have a list of host addresses. I need to get the mx records for them. I was looking at the documentation, and found the getmxrr(). Would that send back the mx record, or just true if it has one?
  14. I found the error, and it ended up being that i had not authorized that user to access the database. Thank you for your help.
  15. Ok. running that gives me the error: No database selected. If I go to my connection file, this is the code: <?php //Connect to DB $con = mysql_connect("localhost","thegoo20_user","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("thegoo20_wordgame", $con); ?> When i run this file by itself, it does not give me any sql errors, so I thought that it was working fine. Maybe I am missing something?
×
×
  • 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.