Jump to content

MargateSteve

Members
  • Posts

    240
  • Joined

  • Last visited

Contact Methods

  • Website URL
    http://www.phpfreaks.com/forums/index.php/topic,308119.0.html

Profile Information

  • Gender
    Not Telling

MargateSteve's Achievements

Regular Member

Regular Member (3/5)

3

Reputation

  1. Not sure why but I thought PhpFeaks had shut down! I stumbled across this looking for something else for the same site I am still trying to create! Simply put, every time I get it close to being what I would consider finished, my eyes get attracted to a better way of doing it (MVC instead of a simple php site, discovering bootstrap, learning SASS, moving everything to AJAX then moving 99% of it back to controller queries and so on) plus a change of job that reduced time to play around with this, grandkids etc. I never did as far as I recall. I seem to recall creating the grid as a php array from the db results was looking the best option. As mentioned above, I am still looking into this so will be stumbling across this again soon.
  2. Thanks mxxd. It is working just how I want now. Talking of the prefixes, as I am using less, I was planning to create some mixins to take the pain out of it, but am now considering using -prefix-free, but don't think it works with imported fonts. Thanks again.
  3. I am building an admin area for a site I am working on with a collapsing sidebar. This works fine except that I wanted it to slide in/out smoothly rather than just disappear/reappear. I tried a JS approach by setting it to 'left:-260px' when collapsed and using show/hide but this caused problems with the rest of the layout. I have also tried adding 'transition: all 0.5s ease;' to the sidebar wrapper class but this did nothing either. Can anyone suggest the best way to go for this? I will be setting up a right sidebar (that is hidden by default) at a later date but want to get the concept right before adding that. JsFiddle Regards Steve
  4. Hi all. Can anyone recommend the best forum software to be integrated with an existing site? I have one at the moment on a site that is being developed (margatefans.co.uk) with SMF but it is far from ideal. When showing things like 'Latest Posts' on pages outside the forum (using SSI.php) it is quite difficult to maintain user level rules so people can only see what they are supposed to see. Also, as the navigation will eventually be dynamic, I have not found a way of succesfully querying a database in SSI.php. I have seen plenty of sites in the past where the forum is part of the site but there seems surprisingly few Google results for it so wondered if anyone here has succesfully done this. Regards Steve
  5. I am trying to get to grips with some of the more advanced .less functions but have hit a bit of a stumbling point. I have read about using 'when' and am trying to change the text color based on the darkness level of the @brand color. What I have is very similar to an example I saw but that one was setting the background too, so that part has been removed. @brand-beige: #F5F5DC; @brand-gray: #808080; .textcolor(@txtcolor) when (lightness(@txtcolor) >= 50%) { color: #fff; } .textcolor(@txtcolor) when (lightness(@txtcolor) < 50%) { color: #000; } /** beige**/ @state-beige-text: textcolor(@brand-beige); @state-beige-bg: @brand-beige; @state-beige-border: darken(spin(@brand-beige, 10%), 50%); /** gray**/ @state-gray-text: textcolor(@brand-gray); @state-gray-bg: @brand-gray; @state-gray-border: darken(spin(@brand-gray, 10%), 50%); When I try to compile it I get the following error SyntaxError: error evaluating function `darken`: Object #<Object> has no method 'toHSL' in W:\wamp\www\Bootstrap\less\test.less on line 12, column 2: 11 .alert-aliceblue { 12 .alert-variant(@alert-beige-bg; @alert-beige-border; @alert-beige-text); 13 } if I change each of the '@state-xxx-text' variables to anything else, like the bootstrap defaults below, everything works fine. /** beige**/ @state-beige-text: darken(@brand-beige, 5%); @state-beige-bg: @brand-beige; @state-beige-border: darken(spin(@brand-beige, 10%), 50%); /** gray**/ @state-gray-text: darken(@brand-gray, 5%); @state-gray-bg: @brand-gray; @state-gray-border: darken(spin(@brand-gray, 10%), 50%); I am sure I am doing something obviously wrong as I am just getting to grips with it. I thought it might be the syntax but have tried @state-aliceblue-text: .textcolor(@brand-aliceblue); @state-aliceblue-text: {textcolor(@brand-aliceblue)}; @state-aliceblue-text: {.textcolor(@brand-aliceblue)}; and all give the same result. If anyone could ive any potential pointers, I would be grateful. Regards Steve
  6. I have removed that part but trying to call html.name still gives 'Returned: undefined'.
  7. I have been banging my head against a wall for a few days over this and think that I have read so many alternative ways, I have got myself confused! What I am trying to do is post some information into the database and on success, provide certain variables back to my script (for example last_insert_id) as I would like to show a success message an add an option to a select on that page. I am trying to get this part working without the mysql first just so I understand it. Currently I can post the data, have that received successfully in the processing page (addDetail.php) and send back output from that page........ insert.php $("#sub").click(function() { var name = $("#name").val(); var town = $("#town").val(); jQuery.ajax({ type: "POST", url: "postScripts/addDetail.php", data: 'name='+name+'&town='+town, success: function(html) { $(".modal-body").prepend( "Returned: " +html ); } }); return false }) addDetail.php $name = $_POST['name']; $town = $_POST['town']; //Check $_POST data echo "<pre>"; print_r($_POST) ; echo "</pre>"; $return["name"] = $name; $return["town"] = $town; echo json_encode($return); Result in insert.php Returned: Array ( [name] => The Name [town] => The Town ) {"name":"The Name","town":"The Town"} This works fine to bring back everything on the processing page in one go but I want to bring back separated variables so I can use them individually. I thought that changing "Returned: " +html to "Returned: " +html.name would allow me to bring back just that variable but it comes back undefined. This is the closest I have got as other methods I tried either brought nothing back or just [objectObject]. How would I be able to bring back both 'name' and 'town' as separated values so I can use them individually in my script? Thanks in advance Steve
  8. Is this page in the same folder as the ones that load it correctly? If not, you would need to change the includes to match the path to the header and footer files. Slightly off topic, is your closing body tag included in footer.php as it is not in that page?
  9. I have been toying around with form validation and have got to a sticking point in four areas that I am pretty sure are easier to do than I am finding! What I have so far works fine - once you start typing in a field, if it is invalid, then there is a message and some extra styling that is removed once it is valid. These are the functions for the four fields so far (there will be more, some required, some not). $('#username').on('keyup', function(){ var valid = /^[a-zA-Z0-9_-]{3,16}$/.test(this.value) && this.value.length; $('#regUsername .regAlert').html((valid?'':'Not Valid')); if(!valid){ $("#regUsername").addClass('bg-danger'); }else{ $("#regUsername").removeClass('bg-danger'); } }); $('#email').on('keyup', function(){ var valid = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(this.value) && this.value.length; $('#regEmail .regAlert').html((valid?'':'Not Valid')); if(!valid){ $("#regEmail").addClass('bg-danger'); }else{ $("#regEmail").removeClass('bg-danger'); } }); $('#password').on('keyup', function(){ var valid = (/^(?=.*\d)(?=.*[a-zA-Z])[0-9a-zA-Z]{6,}$/).test(this.value) && this.value.length; $('#regPassword .regAlert').html((valid?'':'Not Valid')); if(!valid){ $("#regPassword").addClass('bg-danger'); }else{ $("#regPassword").removeClass('bg-danger'); } }); $('#password_confirm').on('keyup', function(){ var valid = (/^(?=.*\d)(?=.*[a-zA-Z])[0-9a-zA-Z]{6,}$/).test(this.value) && this.value.length; $('#regPassword2 .regAlert').html((valid?'':'Not Valid')); if(!valid){ $("#regPassword2").addClass('bg-danger'); }else{ $("#regPassword2").removeClass('bg-danger'); } }); What I am trying to do next is, if any of these fields are not valid, for the submit button to be disabled I can do by including if(!valid){ $('#registerSubmit').prop('disabled', true); }else{ $('#registerSubmit').prop('disabled', false); } in each function BUT if one is invalid, but the next is valid, then this overrides it and the button is clickable again. I have also tried setting a variable to true/false and the same happens. Plus, if all are valid, once the button is clicked, it needs to check for empty (required) fields and only submit if all fields have data. I am also guessing that they is a better way of writing this using a single keyup function and then placing each fields rules within that, but I have tried to wrap it all in a single function but got more in a mess. So, what I am looking for help with (bearing in mind there will be more fields, radio's, checkboxes and selects in the full form) is How can I streamline all of the functions into one to save on repeated code and to make it simple to add more fields in future How can I disable the submit button if ANY of the validations have failed How can I check for any empty required fields on submit button click and not process the form if any are found How can I check that #password and #password_confirm match on keyup from #password_confirm Thanks in advance for any advice Steve
  10. I have started playing around with jQuery mainly to allow me to create complicated forms without clicking through several php pages collecting all the data. It's is probably not relevant but I will give the full picture of what i am attempting feel free to ignore this paragraph if it is of no use! I have a table of MySQL rows with checkboxes. There will be 3 different options for bulk processing of the checked rows and on clicking one of the options a hidden div will fade in and the options buttons will disappear (to prevent several options divs being opened at the same same). In the div there will be form elements relevant to the bulk processing option chosen. For the first one it is simply one text input. Upon Submit it will validate that the input is not empty and if so, execute the function that posts the data. The data gets posted, the div gets replaced and a success message is displayed, plus the bulk option buttons return ready to choose another option. This new div gets hidden once a bulk option next gets clicked. This all works correctly but there is an issue with clearing the validation. So the problem I actually have is that after successful validation and script execution the data is still in memory so if I run through the process again with an empty field, you see the validation error message again, briefly, but the script still runs. Is there any way to clear everything still in memory at the end of script execution? I have tried a few suggestions I have seen and a few things I have tried as a complete guess-up but no joy.... $('#bulkMatchActions').valid=false; $('#bulkMatchActions').validate=false; $('#bulkMatchActions').valid=null; $('#bulkMatchActions').validate=null; removeData(validator); removeData($.post); removeData('#bulkMatchActions'); I am sure that there must be a way to do this but I am completely stumped. If anyone can offer any suggestions I would be grateful. Also, although this code is something I am just playing around with and will not be used on a production site, if there is anything in the scripts that could be done better, feel free to say. but don't be too harsh!! Thanks in advance Steve The Validation part //Validate Defaults jQuery.validator.setDefaults({ debug: true, success: "valid" }); //Validate Rules $(function(){ var validator = $('#bulkMatchActions').validate({ rules: { ppReason:{ required: true } }, messages: { ppReason: "Please enter a reason" } }); //On Submit, run the posting script $('#postponeSubmit').click(function(){ if($('#bulkMatchActions').valid()){ postponeSubmit(); //After the above script is run, I want everything set to NOT VALID ready to validate an empty field again }else{ return false; } }); //Empty the form validator.resetForm(); }); The actual posting script //Postpone function postponeSubmit(){ $('#postponeSubmit').click(function() { var ppSubmit = 'ppSubmit'; var ppReason = $('#ppReason').val(); var checkBox = $.map($('input:checkbox:checked'), function(e,i) { return +e.value; }); var checkBox2 = $('#checkbox'); $('#postpone').fadeOut('fast'); $('#postpone2').fadeIn('fast'); $('#postpone2 p').text('Loading....'); $.post('inc/processForm.php', { ppReason : ppReason, ppSubmit : ppSubmit, checkBox : checkBox }, function(data){ $('#postpone2 p').html(data); showBulkControls(); }); }); }
  11. Although fearful that this question might get spiked due to the broadness of it, here goes.... For my next site I want to integrate social log-ins with the member system. The table set-up is not decided yet for the members but as I have done about half a dozen of these I pretty much know what it will be but for now, just knowing there will be Username, First Name, Surname, Date of Birth and Email for the purposes of my question (I do not want to overcomplicate it needlessly). I would want to have social log-ins, definitely Facebook and Twitter but others if possible, interacting with the members table. I have done a lot of reading-up but cannot find if my set-up wish is actually possible..... Someone can register normally, via a form or by clicking the link/button to register via Facebook or Twitter. During registration they can also add their Facebook/Twitter (depending on their chosen registration method) details. At any point after registration, they can add their Facebook/Twitter details by editing their profile. If a non-logged in visitor clicks to sign-in with Facebook or Twitter, it will check the members table to see if that person already has a matching Facebook/Twitter OAuth registered with my site. If so they will be logged in as that user. If an OAuth match is not found, it will check another set of criteria to see if that matches. I assume that this will be done by pulling the email from Facebook/Twitter. If there is a match on this, it will add the relevant OAuth to the users row in the table. If there is still no match it will ask the person if they have already registered manually (as some people have different emails for different uses). If they say yes, then they will be asked to log-in with their registered username and password. The OAuth will then be added to the users details. If they have not already registered, then create a new member in the table with the OAuth details. I am guessing that if they have First Name, Surname and Date of Birth information on Facebook/Twitter, these can then be pulled into the database. The Username I guess would be more difficult unless before registration is complete they are asked to provide one. Anyway, that is how I have it in my head and I know that there is a lot there but I want to make sure that I know exactly what is possible before I start diving in. If anyone can give any advice as to whether any of the above is not possible or more trouble than it is worth then I would be grateful. Also any other pointers would be very much welcomed. I do not mean to write it for me and also not a generic Social OAuth tutorial as I have already been through stacks of those, but if someone can point me in the direction of anything that covers the specifics of the above that will get me started! Thanks in advance Steve
  12. The clue is in the first word of the error message. Deprecated means that it should not be used as support has finished or the function has been removed. In this case, if you are using php 5.4 session_register() has been removed. Depending on how you are setting 'pass' you could probably replace what you have with $_SESSION['pass'].
  13. Not sure if it is the same but I can't use sendmail from my local Wamp server straight out of the box. I seem to recall there was a way to do it but it was a bit of a PITA. Instead, all I do locally is echo out the email query to make sure it looks like it is doing the correct stuff, then test it properly when I push the page to the live server.
  14. With responses like this to someone giving genuine and correct advice, don't expect further help to come flooding in. However, as a fellow novice who had similar issues when first using sessions I will make a few suggestions. 1. Do not use short opening php tags. Always use <?php. 2. Are you 100% certain there is no output before session_start()? This includes whitespace and physical line breaks. All of my session pages start <?php session_start(); on the very first line with no space before the tag. 3. Google the problem first. Issues with session_start() have been ask hundreds of times over various forums. 4. Don't dismiss suggestions before you try them. 99% of the time the guys on here are spot on. If they suggest something that does not work, the chances are that it is the way you have implemented it. I know that was the case with me a few times. 5. You get out what you put in. If you ask a question clearly, in full words not text speak, give clear examples of what is wrong and speak to people with a bit more respect when they are trying to help, then you will get the solution.
  15. Thanks objnoob. I never realised it would be that simple! Steve
×
×
  • 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.