Jump to content

hobbiton73

Members
  • Posts

    78
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

hobbiton73's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi Christian F. thank you for your continued help with this, and my sincere apologies for not providing you with enough details. Please find below the expressions I've tried: I initially started with the more striaght forward combinations: else if(!preg_match('/^[A-Za-z0-9 \']{5,60}$/', $locationname)) else if(!preg_match('/^[A-Za-z0-9 ']{5,60}$/', $locationname)) I then tried the following: else if(!preg_match('/^[A-Za-z0-9 .,;\-\']{5,60}$/', $locationname)) else if(!preg_match('/^[A-Za-z0-9 .,;\'\-]{5,60}$/', $locationname)) else if(!preg_match('/^[-A-Za-z0-9 .,;\']{5,60}$/', $locationname)) else if(!preg_match('/^[-A-Za-z0-9 .,;']{5,60}$/', $locationname)) As I said in my earlier posts, these have been unsuccessful and when the validation fails, I receive this error mesage: $message = "Invalid Location Name, please try again!"; I've looked to see if 'Magic_Quotes' are turned on and they are, but am I correct in thinking that this is a fale safe aginst SQL Injection? My apologiezs if my understanding is incorrect. Many thanks and kind regards Chris
  2. Hi @requinix, thank you also for taking the time to reply to my post. My sincere apologies for being a little inexperienced, but could you possibly what i would need to do to change the 'php.ini' file? Many thanks and kind regards Chris
  3. Hi @Christian F., thank you for taking the time to reply to my post. When a user wants to save a record, there are two validation files which I use. The first is the actual form validation where the relevant jquery success or failure messages are displayed, and for this I use the following regex: "onlyMapmyfinds": { "regex": /^$|^[-A-Za-z0-9 .,;']+$/, "alertText": "* No special characters allowed" }, As you can see this incoporates the apostrophe without any problem. The second file is the PHP script which saves the record to a mySQL database which is where I have the problem. As it currently stand this is the specific line which throws up the error message: else if(!preg_match('/^[A-Za-z0-9 .,;-]{5,60}$/', $locationname)){ //validate email address - check if is a valid email address $status = "error"; $message = "Invalid Location Name, please try again!"; } I hope this helps. Many thanks and kind regards Chris
  4. Hi, I wonder whether someone may be able to help me please. I'm using the regex expression below as part of my form validation. else if(!preg_match('/^[A-Za-z0-9 .,;-]{5,60}$/', $locationname)) As it currently stands the expression works fine, but I'm having great difficulty when tyrying to add the ' (apostrophe). I've been working on this for a couple of days now, escaping the charcater, moving it to different positions within the expression, sadly without any luck. I just wondered whether someone could possibly look at this please and let me know where I'm going wrong and put me out of my misery . Many thanks and kind regards Chris
  5. Hi, I wonder whether someone may be able to help me please. I've put together this page http://www.mapmyfind.../chris/test.php which allows the user to add and remove Google Map markers via a 'Category' check box selection. In addition, as each marker is added or removed from the map, the linked 'Description' is added and removed from the 'Sidebar' (shown in orange). You will see that as a map marker is selected a 'Infowindow' is created above the marker and the linked 'Sidebar Description Item' is highlighted in grey. The problem I'm having is that I cannot find a way to make the 'Sidebar' automatically scroll so the the sidebar item is visible to the user. To illustrate this a little better than I can perhaps explain, I have found an example here http://www.blocsoft....xample12.V3.asp which highlights the behaviour I'm looking for. I've read many a tutorial and tried several plugins, all without success. I just wondered whether someone could perhaps take a look at this please and let me know where I'm going wrong. I really would be most grateful of any help as I've been working on this for several weeks. Many thanks and kind regards
  6. Hi, firstly I am by no means an expert when it comes to this. But I was trying to do something similar for my current project. I, probably like yourself, did a lot of searching and found this http://www.profilepicture.co.uk/sticky-sidebar-jquery-plugin/. I'm not sure whether this is of any use, but I've found it to be a really useful plugin. My apologies If I've misunderstood what you're trying to achieve, but I hope this may help. Many thanks and kind regards
  7. Hi, i'm not sure whether this will help at all, but I've recently dealt with this for my current project and, I too found it difficult to get my head around The following links are what I used as a starting point. They provide fairly simple examples to the more advanced. Anyway this is the link for the front end http://net.tutsplus.com/tutorials/javascript-ajax/building-a-sleek-ajax-signup-form/ and this is source for the back end validation I used http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ I hope it helps. Kind regards
  8. I wonder whether someone may be able to help me please. Firstly, my apologies because I'm not particularly well versed with Javascript, so perhaps this may be a very basic error to some. I've put together this page http://www.mapmyfind.../chris/test.php which allows users to add and remove map markers via 'Marker Category' check box selection. In addition, as the markers are added to the map, an associated 'Sidebar' item is also created (shown in orange text). If a map marker is clicked, a 'Infowindow' appears over the marker and the relevant 'Sidebar' item is highlighted with a grey background. The problem I'm having is that the once the map marker has been selected, I cannot get the 'Sidebar' to automatically scroll, so that the 'Sidebar' item is visible to the user. I appreciate that my description of the problem may not be particularly well detailed, so please find a link to an example page here http://www.blocsoft....xample12.V3.asp which illustrates what I'm trying to achieve. I've been working on this for a while now and read through quite a lot of 'plugins' and tutorials to try and find the solution, unfortunately without any success. I just wondered whether someone may be able to look at this please and offer some guidance on how I may be able to solve this problem. Many thanks and kind regards
  9. Hi @ChristianF, I hope you are well. I wonder whether you may be able to help me please. Following on from your much appreciated advice yesterday, I went away to research 'Server' side validation. I found that the tutorial I was using did cater for this here http://www.position-absolute.com/articles/using-form-ajax-validation-with-the-jquery-validation-engine-plugin/. I've been working through the 'Inline' demo, but I wonder whether you may be able to help me please with a few things I'm not too clear about. The demo deals with 3 PHP files (shown below) in conjunction with main HTML page. jquery.validationEngine-en.js (function($){ $.fn.validationEngineLanguage = function(){ }; $.validationEngineLanguage = { newLang: function(){ $.validationEngineLanguage.allRules = { "required": { // Add your regex rules here, you can take telephone as an example "regex": "none", "alertText": "* This field is required", "alertTextCheckboxMultiple": "* Please select an option", "alertTextCheckboxe": "* This checkbox is required", "alertTextDateRange": "* Both date range fields are required" }, "requiredInFunction": { "func": function(field, rules, i, options){ return (field.val() == "test") ? true : false; }, "alertText": "* Field must equal test" }, "dateRange": { "regex": "none", "alertText": "* Invalid ", "alertText2": "Date Range" }, "dateTimeRange": { "regex": "none", "alertText": "* Invalid ", "alertText2": "Date Time Range" }, "minSize": { "regex": "none", "alertText": "* Minimum ", "alertText2": " characters allowed" }, "maxSize": { "regex": "none", "alertText": "* Maximum ", "alertText2": " characters allowed" }, "groupRequired": { "regex": "none", "alertText": "* You must fill one of the following fields" }, "min": { "regex": "none", "alertText": "* Minimum value is " }, "max": { "regex": "none", "alertText": "* Maximum value is " }, "past": { "regex": "none", "alertText": "* Date prior to " }, "future": { "regex": "none", "alertText": "* Date past " }, "maxCheckbox": { "regex": "none", "alertText": "* Maximum ", "alertText2": " options allowed" }, "minCheckbox": { "regex": "none", "alertText": "* Please select ", "alertText2": " options" }, "equals": { "regex": "none", "alertText": "* Fields do not match" }, "creditCard": { "regex": "none", "alertText": "* Invalid credit card number" }, "phone": { // credit: jquery.h5validate.js / orefalo "regex": /^([\+][0-9]{1,3}[\ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9\ \.\-\/]{3,20})((x|ext|extension)[\ ]?[0-9]{1,4})?$/, "alertText": "* Invalid phone number" }, "email": { // HTML5 compatible email regex ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html# e-mail-state-%28type=email%29 ) "regex": /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/, "alertText": "* Invalid email address" }, "integer": { "regex": /^[\-\+]?\d+$/, "alertText": "* Not a valid integer" }, "number": { // Number, including positive, negative, and floating decimal. credit: orefalo "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/, "alertText": "* Invalid floating decimal number" }, "date": { // Check if date is valid by leap year "func": function (field) { var pattern = new RegExp(/^(\d{4})[\/\-\.](0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])$/); var match = pattern.exec(field.val()); if (match == null) return false; var year = match[1]; var month = match[2]*1; var day = match[3]*1; var date = new Date(year, month - 1, day); // because months starts from 0. return (date.getFullYear() == year && date.getMonth() == (month - 1) && date.getDate() == day); }, "alertText": "* Invalid date, must be in YYYY-MM-DD format" }, "ipv4": { "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/, "alertText": "* Invalid IP address" }, "url": { "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\u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)?$/i, "alertText": "* Invalid URL" }, "onlyNumberSp": { "regex": /^[0-9\ ]+$/, "alertText": "* Numbers only" }, "onlyLetterSp": { "regex": /^[a-zA-Z\ \']+$/, "alertText": "* Letters only" }, "onlyLetterNumber": { "regex": /^[0-9a-zA-Z]+$/, "alertText": "* No special characters allowed" }, // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings "ajaxUserCall": { "url": "ajaxValidateFieldUser", // you may want to pass extra data on the ajax call "extraData": "name=eric", "alertText": "* This user is already taken", "alertTextLoad": "* Validating, please wait" }, "ajaxUserCallPhp": { "url": "phpajax/ajaxValidateFieldUser.php", // you may want to pass extra data on the ajax call "extraData": "name=eric", // if you provide an "alertTextOk", it will show as a green prompt when the field validates "alertTextOk": "* This username is available", "alertText": "* This user is already taken", "alertTextLoad": "* Validating, please wait" }, "ajaxNameCall": { // remote json service location "url": "ajaxValidateFieldName", // error "alertText": "* This name is already taken", // if you provide an "alertTextOk", it will show as a green prompt when the field validates "alertTextOk": "* This name is available", // speaks by itself "alertTextLoad": "* Validating, please wait" }, "ajaxNameCallPhp": { // remote json service location "url": "phpajax/ajaxValidateFieldName.php", // error "alertText": "* This name is already taken", // speaks by itself "alertTextLoad": "* Validating, please wait" }, "validate2fields": { "alertText": "* Please input HELLO" }, //tls warning:homegrown not fielded "dateFormat":{ "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(??:(?:0?[13578]|1[02])(\/|-)31)|(??:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(??:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(??:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/, "alertText": "* Invalid Date" }, //tls warning:homegrown not fielded "dateTimeFormat": { "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(??:(?:0?[13578]|1[02])(\/|-)31)|(??:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/, "alertText": "* Invalid Date or Date Format", "alertText2": "Expected Format: ", "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ", "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM" } }; } }; $.validationEngineLanguage.newLang(); })(jQuery); ajaxValidateFieldName.php <?php /* RECEIVE VALUE */ $validateValue=$_REQUEST['fieldValue']; $validateId=$_REQUEST['fieldId']; $validateError= "This username is already taken"; $validateSuccess= "This username is available"; /* RETURN VALUE */ $arrayToJs = array(); $arrayToJs[0] = $validateId; if($validateValue =="duncan"){ // validate?? $arrayToJs[1] = true; // RETURN TRUE echo json_encode($arrayToJs); // RETURN ARRAY WITH success }else{ for($x=0;$x<1000000;$x++){ if($x == 990000){ $arrayToJs[1] = false; echo json_encode($arrayToJs); // RETURN ARRAY WITH ERROR } } } ?> ajaxValidateFieldUser.php <?php /* RECEIVE VALUE */ $validateValue=$_REQUEST['fieldValue']; $validateId=$_REQUEST['fieldId']; $validateError= "This username is already taken"; $validateSuccess= "This username is available"; /* RETURN VALUE */ $arrayToJs = array(); $arrayToJs[0] = $validateId; if($validateValue =="karnius"){ // validate?? $arrayToJs[1] = true; // RETURN TRUE echo json_encode($arrayToJs); // RETURN ARRAY WITH success }else{ for($x=0;$x<1000000;$x++){ if($x == 990000){ $arrayToJs[1] = false; echo json_encode($arrayToJs); // RETURN ARRAY WITH ERROR } } } ?> What I'm trying to understand is the correlation between the 'validation engine' file and the other two files. In these examples the validation is carried out on the 'User Name' and 'First Name' but would it be possible to actually add the field format criteria to these files i.e. field length etc, rather than having this in the HTML page. My apologies if I've not been particularly clear and fro the lengthy post, but I just wondered whether you may be able to break things down into 'layman's' terms. Many thanks and kind regards
  10. Hi ChristianF, thank you for this, although I have to admit that most of it has gone way over my head. It looks like it's something I need to look at. Many thanks and kind regards
  11. Hi ChristianF, thank you very much for taking the time to reply to my post. I am very new to this, so I've obviously made some errors. Could you perhaps elaborate how I may achieve this on the 'server' rather than the 'client' side. Many thanks and kind regards
  12. I wonder whether someone may be able to help me please. Using this http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ and this http://net.tutsplus.com/tutorials/javascript-ajax/building-a-sleek-ajax-signup-form/ tutorials, I've put together this http://www.mapmyfinds.co.uk/chris/test2.php page which performs 'field' validation, then, upon the 'Save' button being clicked by the user, displays a AJAX status message telling the user whether the record has been saved or not. The problem I'm having is that although the fields are correctly validated i.e. if the fields are blank, the correct validation error messages are displayed on screen, the AJAX message says that the 'Record has been saved' and the record is added to a mySQL database, so in essence creating a blank record. I'm having great difficulty in joining the 'Validation' and the 'Record Saved' message. I've run this through JavaScript Console and unfortunately there are no errors shown, so I have to be honest and say that I'm really not sure where the problem lies. This is the code which activates the AJAX message: <script type="text/javascript"> jQuery(document).ready(function(){ // binds form submission and fields to the validation engine jQuery("#addlocation").validationEngine(); }) </script> <script type="text/javascript"> $(document).ready(function(){ $('#addlocation').submit(function(){ //check the form is not currently submitting if($(this).data('formstatus') !== 'submitting'){ //setup variables var form = $(this), formData = form.serialize(), formUrl = form.attr('action'), formMethod = form.attr('method'), responseMsg = $('#saverecordresponse'); //add status data to form form.data('formstatus','submitting'); //show response message - waiting responseMsg.hide() .addClass('response-waiting') .text('Please Wait...') .fadeIn(200); //send data to server for validation $.ajax({ url: formUrl, type: formMethod, data: formData, success:function(data){ //setup variables var responseData = jQuery.parseJSON(data), klass = ''; //response conditional switch(responseData.status){ case 'error': klass = 'response-error'; break; case 'success': klass = 'response-success'; break; } //show reponse message responseMsg.fadeOut(200,function(){ $(this).removeClass('response-waiting') .addClass(klass) .text(responseData.message) .fadeIn(200,function(){ //set timeout to hide response message setTimeout(function(){ responseMsg.fadeOut(300,function(){ $(this).removeClass(klass); form.data('formstatus','idle'); }); },2000) setTimeout(function() { $('body').fadeOut(400, function(){ location.reload(); setTimeout(function(){ $('body').fadeIn(400); }, 500); window.scrollTo(x-coord, y-coord); }); }, 2000); }); }); } }); } //prevent form from submitting return false; }); }); </script> and the following code is the PHP script which saves the record. <?php $userid = $_POST['userid']; $locationname = $_POST['locationname']; $returnedaddress = $_POST['returnedaddress']; $osgb36lat = $_POST['osgb36lat']; $osgb36lon = $_POST['osgb36lon']; $nameofcontact = $_POST['nameofcontact']; $address1 = $_POST['address1']; $address2 = $_POST['address2']; $address3 = $_POST['address3']; $address4 = $_POST['address4']; $address5 = $_POST['address5']; $telephonenumber = $_POST['telephonenumber']; $query = mysql_query("INSERT INTO `table` (userid, locationname, returnedaddress, osgb36lat, osgb36lon, nameofcontact, address1, address2, address3, address4, address5, telephonenumber) VALUES ('$userid', '$locationname', '$returnedaddress', '$osgb36lat', '$osgb36lon', '$nameofcontact', '$address1', '$address2', '$address3', '$address4', '$address5', '$telephonenumber')"); if($query){ //if insert is successful $status = "success"; $message = "Location Saved!"; } else { //if insert fails $status = "error"; $message = "There was a problem in saving the record. Please try again!"; } //return json response $data = array( 'status' => $status, 'message' => $message ); echo json_encode($data); exit; ?> I just wondered whether someone could have a look at this please and let me know where I'm going wrong? Many thanks and kind regards
  13. Hi @jazzman1, I don't know what to say. This works like a dream. I can't really express how grateful I am. Thank you so much for all your help, time and trouble, it's so greatly appreciated. Many thanks, all the best and kind regards
  14. Hello, I wonder whether someone may be able to help me please with a problem I've been working on for a number of days which I just can't solve. The extract of code below shows part of a script which I use to successfully create a table of 'location' records pertinent to the current user. <form name="delete" id="delete" class="delete"> <input type="hidden" name="lid" id="lid" value="<?php echo $theID ?>" /> <input type="submit" value="Delete Record"/> </form> The problem I'm having is around the `deletion a `location record`. Originating here http://tutorialzine.com/2010/12/better-confirm-box-jquery-css3/, upon clicking the `delete` button, the 'Delete Confirmation' message appears on screen and the user can select `Yes` or `No`. If the user selects `Yes`, the `lid` value should be passed to the jQuery AJAX script below and onto a 'deletion' PHP script. <script type="text/javascript"> $('.delete').submit(function(e){ e.preventDefault(); var elem = $(this).closest('.delete'); console.log($(this).serialize()); $.confirm({ 'title' : 'Delete Confirmation', 'message' : 'You are about to delete this item. <br />It cannot be restored at a later time! Continue?', 'buttons' : { 'Yes' : { 'class' : 'blue', 'action': function(){ //elem.slideUp(); $.ajax({ url: 'deletelocation.php', type: 'POST', data: $(this).serialize(), success: function(response) { console.log('success', response); }, error: function() { console.log('error') } }); } }, 'No' : { 'class' : 'gray', 'action': function(){} // Nothing to do in this case. You can as well omit the action property. } } }); }); </script> and this is my`deletelocation.php` script called in the above code: <?php $lid = $_POST['lid']; $query = mysql_query("DELETE FROM table WHERE locationid='$lid'"); ?> The problem I'm having is that I cannot find a way to pass the value from the form through the AJAX script and delete the record. The 'Delete Confirmation message' correctly appears on screen, but when I select yes the record is not deleted. In JS Console I receive the following message: lid=5 success So I do know that it is picking up the correct 'lid' value but it's just not passing it through to delete script. I just wondered whether someone could possibly take a look at this please and let me know where I'm going wrong. Many thanks and kind regards
  15. Hi, thank your for your continued help with this. I have tried incorporating the js , but unfortunately this doesn't solve my problem. I think the issue lies with the link between the button and the JS function, I just need to try and figure how to link them together. Many thanks and kind regards
×
×
  • 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.