Jump to content

Love2c0de

Members
  • Posts

    364
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Love2c0de

  1. Good morning, I have a wordpress theme I am using and I thought all was working well. I've noticed that when I'm not logged into admin, it doesn't show any pages for me, only white pages. When I switched back to the default TwentyTwelve theme, it worked all ok for me. Has anyone had this problem before? Thanks for your time. Kind regards, L2c
  2. Good afternoon, How would I handle inserting checkboxes into a mysql database? I have a form which has a list of services in checkbox format as well as other fields and I want to save the values to a database but I want to be able to query the database by service if needs be. How do I deal with multiple services from checkboxes? Would I create another table called 'services' for example with columns - 'service1','service2','service3' etc etc and a unique id relating to my contact table? Thank you for your help. Kind regards, L2c
  3. Good evening, I've just validated a form with jQuery/JavaScript and I'm looking to basically do the same validation with PHP. I'm starting off by trimming all of the fields, then I'm going to check the required fields to see if they are empty or not. If so I want to send them back to the page but I need to display the errors next to the specific input fields and I'm not sure how to do it. I understand im going to have to save the error array into a session and then print the values, but I'm not sure how to map them to the correct input field. Can anyone help me? Here is my JavaScipt: $( "#reg-form" ).submit(function(e) { $('.arrow_box').css("display","none"); //hold required field values var reqFields = new Array(); //holds indexes of empty required fields var emptyInputs = new Array(); //holds form controls and will match up with emptyInputs array to determine which error box to show var formControls = new Array(); //get the value from all required fields $('.required').each(function(){ reqFields.push($(this).val()); }); //trim each required field and push any empty fields into the emptyInputs array $.each(reqFields, function(key,value){ if($.trim(value) == "") { emptyInputs.push(key); } }); //get all error divs $('.arrow_box').each(function(){ formControls.push($(this)); }); if(emptyInputs.length > 0) { e.preventDefault(); //get values from emptyInputs to determine the index of the formControls to show $.each(emptyInputs, function(k,v){ $(formControls[v]).css("display","block").prev('input').focus(); }); $(formControls[emptyInputs[0]]).prev('input').focus(); } else { //continue in-depth validation on each specific field var fname = $('#fname'); var lname = $('#lname'); var email = $('#email'); var dob = $('#dob'); var mphone = $('#mphone'); var wphone = $('#wphone'); var ages = $('#ages'); var nameRegExp = /^[a-zA-Z\s]*$/; var numRegExp = /\d+/g; var emailRegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; if(!nameRegExp.test($(fname).val())) { emptyInputs.push($(fname).next()); } if(!nameRegExp.test($(lname).val())) { emptyInputs.push($(lname).next()); } if(!emailRegExp.test($(email).val())) { emptyInputs.push($(email).next()); } if(!dob.val().match(numRegExp)) { emptyInputs.push($(dob).next()); } if(!mphone.val().match(numRegExp)) { emptyInputs.push($(mphone).next()); } if(!wphone.val().match(numRegExp)) { emptyInputs.push($(wphone).next()); } if(!ages.val().match(numRegExp)) { emptyInputs.push($(ages).next()); } if(emptyInputs.length > 0) { $(emptyInputs).each( function(k,v){ $(this).css("display","block"); }); $(emptyInputs[0]).prev('input').focus(); e.preventDefault(); } else { return true; } } }); Here is my PHP so far: <?php if(isset($_POST['fname'])) { $errors = array(); $required = array($_POST['fname'], $_POST['lname'], $_POST['dob'], $_POST['mphone'], $_POST['wphone'], $_POST['address'], $_POST['city'], $_POST['province'], $_POST['ages']); foreach($required as $k => &$v) { $v = trim($v); if(empty($v)) { array_push($errors, true); } else { array_push($errors, false); } } if(in_array(true, $errors, true)) { $_SESSION['msg'] = $errors; header("Location: Register-Now.php"); die(); } echo "<pre>"; var_dump($errors); echo "</pre>";die(); } else { //someone has tried to directly access the form script without a submit, send them back! header("Location: Register-Now.php"); die(); } ?> Really stuck, can anyone help me with this problem? Thank you for your time. Kind regards, L2c.
  4. Hi Denno, Thanks for the reply and advice. So it wouldn't actually be an <input> with the type of hidden but an <input> with the type of text with a CSS declaration of display:none? I've just used that technique but used an <input> with type hidden. I suppose it would have to be of type text in order for a bot to be able to fill it in? Not sure how bots work! Kind regards, Tom
  5. Good morning, I have a captcha on my website but for some reason within the last day everytime the page loads it automatically focuses on the captcha input field. I've found a couple things on the net of someone with the same issue but I can't seem to resolve it. Captcha is an ugly little thing anyway and wondered if there are any alternatives out there? I've seen forms asking to find the sum of 2 numbers but not sure how secure that is from bots. Thank you very much for your time. Kind regards, L2c
  6. Hi Ch0cu3r, Thank you for the reply and sorry for the late reply. I ended up taking another route. I did look at the link you provided but it was too complicated at the time. Would you be able to help me solve my next problem? I used this code to get what I needed: RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME}.php -fRewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L] I have a 'portfolio.php' page with some project links. When those links are clicked it accepts a GET variable and pulls the relevant information from the database - displaying it on 'project.php'. So project.php acts as a template for different content. How can I modify my .htaccess rules to compensate for when there is a GET variable passed? Thank you for your time. Kind regards, Tom
  7. Good afternoon, I'm having a really weird problem with my attempt at re-writing URL's. I'm trying to remove the .php extension from my filename within the URL. It works fine with pages 'portfolio.php, terms.php and promise.php' but not any of the other pages. The other pages send me to a redirect loop error. Here is my rewrite rules: RewriteEngine OnRewriteBase /RewriteCond %{REQUEST_FILENAME}.php -fRewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L] filenames are as guessed, index.php, services.php, contact.php etc, as you can see only those certain pages listed above work. Does anyone know why? Thank you for your time. Kind regards, L2c
  8. Good evening, I've got a client who wants to add another 'shop' page to their website. Their website is already using OpenCart and they are happy to use the same Cart for both sets of products. so I just need another page with a different set of products - but integrated into OpenCart. If you would like to discuss further about price etc, please contact me here or on Skype: thomas_c0de Regards, Tom
  9. Good morning, I need to validate a US phone number and wanted to know some basic facts such as max/max amount of digits possible etc. I know it can be validated with a regexp but just looking to do some simple tests on the data before inserting to a db. Even if you could link me to a proven, reliable online resource that would be great. Thanks for your time and help. Kind regards, L2c.
  10. Get in there, I've figured it out! Regards, L2c
  11. Ok, so what I've done is wrote the link as such: <a href="./PropertyOwners/owner-specials">Owner Specials</a> With my .htaccess looking like: RewriteEngine on RewriteRule ^/?([a-zA-Z-]+)$ index.php?page=$1 [L,QSA] RewriteRule ^([a-zA-Z-]+)/([a-zA-Z]+)/?$ index.php?page=$1&category=$2 [L] Now, this works perfectly for my links which are top-level links such as: <a href="./contact">Contact</a> but when I try adding the extra $_GET variable, it doesn't work - I get a 404 error. I've tried changing the second RewriteRule in my .htaccess so that the 'page' $_GET variable is at the very end of the URL with 'category' being the first $_GET in the URL - followed by the filename. Really at a loss. Is it because of the QSA - append flag? Thanks for your time. Kind regards, L2c.
  12. Good afternoon, Following on, I've got the site nearly made now. The same as above but I have put all content template files into one main folder. I'm not sure how I am going to target the pages to know which 'directory' to add. For example 'Who We Are' needs to be written as www.mysite.com/About/Who-We-Are but how am I going to target that dynamically for the other pages? I thought about hardcoding it in the anchor tags such as: <ul> <li><a href="#">About Us</a> <ul> <li><a href="./About/Who-We-Are">Who we are</a></li> //etc //etc <ul> </li> </ul> Is this something I can control with .htaccess? If so I still need a way to determine which value to put in place of 'About' as I have 2 other links with a sublevel menu. It's seeming easier to just put the individual related template files into the corresponding directory within my main template directory such as: [content] [about] who-we-are.tpl our history.tpl [activities] nc-culture.tpl nc-entertainment.tpl nc-sports-and-recreation.tpl etc etc That way I just need to control the filename part of the url with .htaccess. What do you guys think? Kind regards, L2c.
  13. I found out a little more about the software the company use, it's called 'Appfolio' - http://www.appfolio.com/ Anyone ever worked with this in a PHP website? Going to speak to the client and find out more about how they transfer the properties into the website. He said they use ASP scripts to do it but this looks more like software where you would literally put the required data into some kind of structure, then upload it to the site somehow. Kind regards, L2c.
  14. Good evening, My client wants sub menus within the navigation like the format below: Home Avaliable Rentals Property Owner Owner Services owner specials Owner FAQ Owner Contact About us Who we are what we do our history Our services Owner Services Tenant Services About Florida Florida NC Florida activites Florida Schools Florida Parks and recreation Florida restraunts Florida Entertainment Florida health care HOA Management Contact US I'm going to do a breadcrumb effect and they also want the URL to look like: www.theirsite.com/About/FloridaHealthCare so I'm going to rewrite the URL. What is the best way to store my HTML template files (the sub level links above)? I've got a main directory where they are called 'content'. Within that should I create the other directories such as 'About', 'PropertyOwner', 'Services' etc and then have my actual template files within the relative directories? Or should I just keep all template files in one main folder and write the sub directory via code? I'm thinking to create the directories within 'content' and put the files in the relevant ones as it would automatically write that part of the URL for me but I want to know what the standard is. Thanks for your time. Kind regards, L2c.
  15. @Ch0c - It's purely because I can't code in ASP. I did a quick static website for someone and they want me to re-do their other website, which is a Real Estate company, so I'm looking to build the site in PHP as it's the only server side language I know. @trq - That's great, I'll look into that! I'm considering a CMS for them to be able to add/delete/edit property details so they don't have to use ASP at all. Kind regards, L2c.
  16. Good afternoon, I've got a client who's current site is coded in ASP. I'm going to re-code it in PHP but he will only agree if his company can still use their ASP scripts - which feeds information to the site from a company developed software program. Is it possible for me to implement their scripts into the PHP site? Thanks for your time. Kind regards, L2c.
  17. Thank you very much. It was $content before but I was using include() instead of printing. Thanks a lot! Kind regards, L2c.
  18. Good afternoon all, I'm trying to setup a website and having a problem loading in dynamic content. I have a main index.php file loading in template files - some which need to be dynamic. I have a value within my template Home file called <__CONTENT__> and I'm trying to replace that with some images which have been retrieved from a database. It does replace the value with my output, but my homepage still displays the <__CONTENT__> value. Here is my main index.php file: <?php session_start(); require("core/setup.php"); ?> <!DOCTYPE> <html lang="en"> <head> <title>Gardenable | <?php print($title); ?></title> <link rel="stylesheet" href="css/font.css" /> <link rel="stylesheet" href="css/main.css" /> <link rel="stylesheet" href="css/respond" /> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> </head> <body> <div id="container"> <div id="header"> <img src="images/logo.png" alt="Gardenable - Making gardening accessible to everyone" id="logo" /> <div id="top_mid"> <p>Already registered? <a href="#">Login</a></p> <p>Need an account? <a href="#">Register</a></p> </div> <ul id="navigation"> <li><a href="?page=Home">home</a></li> <li><a href="?page=Products">products</a></li> <li><a href="?page=Services">services</a></li> <li><a href="?page=About">about</a></li> <li><a href="?page=Contact">get in touch</a></li> </ul> </div> <?php if(isset($left_column)){ print($left_column); } ?> <div id="main_content"> <?php if(isset($content)){ include($filepath); } ?> </div> <hr class="hidden_rule" /> </div> </body> </html> This loads setup.php first: function getDynamic($path,$page) { $path = substr_replace($path, "", strrpos($path, "/")); $path .= "/queries/"; switch($page) { case 'Home': $planters = require($path."getproducts.php"); return $planters; break; case 'Products': break; } } if(!isset($_GET['page'])) { header("Location: ?page=Home"); die(); } $_GET['page'] = "Home"; $page = $_GET['page']; $path = $_SERVER['DOCUMENT_ROOT'] . "clients/Garden/core/content"; $pathinfo = pathinfo($path, PATHINFO_FILENAME); $filepath = $path . "/" . $_GET['page'] . ".htm"; if(file_exists($filepath)) { $planters = getDynamic($path,$page); $content = file_get_contents($filepath); var_dump($planters); var_dump($content); $content = str_replace("<__CONTENT__>", $planters, $content); } else { header("Location: ?page=Home"); die(); } Here is my getproducts.php file: <?php // $dir = substr_replace($_SERVER['SCRIPT_FILENAME'], "", strrpos($_SERVER['SCRIPT_FILENAME'], "/") + 1); $conn = new mysqli("localhost","root","","gardenable") or die("Error creating connection."); $stmt = $conn->prepare("SELECT * FROM planter_images WHERE productID=? LIMIT 10"); //rand = 1,1 because not all images are in db yet, the only ID present is 1. <----modify once table complete. $stmt->bind_param("i",rand(1,1)); $stmt->execute(); $stmt->bind_result($i_id, $p_id, $i_name, $p_price, $p_dims, $p_ref, $p_desc); $stmt->store_result(); $row = $stmt->num_rows; if($row) { $headings = array("Raised Planters","Rounded Planters"); $hcount = 0; //image counter. $x = 1; $planters = "<div id='home_product_main'>"; $planters .= "<h3>".$headings[$hcount]."</h3>"; while($stmt->fetch()) { $num = substr($i_name, strpos($i_name, "{$x}"), 1); $planters .= "<div class='product_holder'>"; $planters .= "<a href='#'>"; $planters .= "<img src='core/content/planter_imgs/{$i_name}' class='home_prods' alt='Image not loading? Contact the administrator at admin@gardenable.co.uk' />"; $planters .= "</a>"; $planters .= "</div>"; if($num === "5") { $planters .= "<hr class='separator' />"; $planters .= "<h3>".$headings[++$hcount]."</h3>"; //reset image counter. $x = 1; } else { $x++; } } $planters .= "</div>"; } return $planters; mysqli_close($conn); ?> Here is my Home.htm file: <p>Gardenable is a garden product and services company based in Clacton on Sea in Essex. We specialize in designing and creating bespoke garden products and also provide local garden services such as decking, jet washing and hedge trimming.</p> <h3>Featured Products</h3> <__CONTENT__> <p>Gardenable is a garden product and services company based in Clacton on Sea in Essex. We specialize in designing and creating bespoke garden products and also provide local garden services such as decking, jet washing and hedge trimming.</p> I've attached an image. As you can see from the var_dump() the replacement has been performed and I later echo the $content variable out AFTER it has been changed. Any ideas? Thank you for your time. Kind regards, L2c.
  19. Good evening, Could you not run some SQL command to convert it to what you need? Regards, L2c.
  20. Good morning, Not really had a great deal of time to research this but will look into the above once I get the chance, probably Sunday now. I'll update the thread with some more questions if needs be. Thanks for the replies so far! Kind regards, L2c
  21. Good morning, One error I initially see is the $_POST['comments'] should be $_POST['message'], although I don't think that will fix your problem. Once you submit the form, is it the script above which runs initially? If so, why not check you are actually receiving the $_POST data by entering the following below (at the very top of your script, before everything else): <?php echo "<pre>"; print_r($_POST); echo "</pre>"; ?> That will tell you whether you are receiving the form data or not. The reason you are not receiving any kind of message is because you don't actually print a message out. You could check to see if the mail() function was successful in an if() statement like so: if(!mail($mail,$subject, $msg, $headers)) { //mail() was not successful } else { //mail() was successful, print a success message! } Hope this helps a little. Kind regards, L2c.
  22. Good evening, I'm looking at allowing them to be as flexible as possible as not everyone has a Paypal account and probably wouldn't set one up just to purchase something through my website so wanted to give them other options. Paypal is something which is definitely going on the site but I wanted to allow them also to use a credit card as well. Is a user login system required if I want to allow them to use a credit card. I really need this to be secure so need to know the 'standard' way to do things. I've seen some sites which allow you to enter a credit card without an account, whereas others you need to register an account. Thanks for the feedback! Kind regards, L2c.
  23. Good afternoon, I am redesigning a site so users can purchase products through the site either via Paypal or credit card. I'm not sure on whether I need to do a user account system or whether I should allow them to pay directly via credit card. I need it to be secure. What are the pros/cons and do's/don'ts of both? Thank you for your time. Kind regards, L2c.
  24. Good morning, It seems using rgba() instead of opacity allows you to decrease the opacity of an element while retaining the other elements opacity value. Try this: .mybox { background: rgba(255,255,255, 0.5); } //background: rgba(red, green, blue, alpha) - alpha = opacity. My values of 255,255,255 assumes the background colour of the .myBox div id white. Change them to suit. Hope this helps. Kind regards, cL.
  25. Need my WAMP Server argggghhh got no server :(

×
×
  • 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.