Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Jay Gilford

Privileged
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Jay Gilford got a reaction from techkid in Wrapping my head around sessions and cookies   
    1. You need to start a session on EVERY page you want to use a session. Without doing so the session data can't be accessed
    2. You will need to validate on each page that the user can access the page (ie has a valid session login) before executing code
     
    Using the approach you have, the easiest thing would be to create a new php file - we'll call it bootstrap.php for arguments sake. Now in there you put the session start code and some code to validate the current user session is valid, and if not redirecting to the login page. Then on every page you would add an include to bootstrap.php
     
    The one exception to this would be the login page which you would add the session start to on its own (otherwise you'll end up in an infinite loop)
  2. Like
    Jay Gilford got a reaction from Lovelock in Best way to go about user comments when storing in database.   
    You create a table called comments with the necessary comment fields, then use a 'user_id' field where you assign the users id to the comment. This process is called normalization
  3. Like
    Jay Gilford reacted to Renaissance-Design in PHP refreshing my page   
    You need to submit the forms with AJAX. You'll still need PHP (or whatever you use) server-side to process and sanitize the form submission.
  4. Like
    Jay Gilford got a reaction from Codiacz.com in wamp function GETDATE()   
    getdate isn't a mysql function. I think the one you need is curdate()
  5. Like
    Jay Gilford got a reaction from webdeveloper93 in Passing php variables to javascript   
    Not really sure why you have duplicated the script or indeed the JS code... You would be better using

    <script> var pid = <?php echo $pid ? $pid : "''"; ?> </script>
     
    That said, personally I would put any js variables into an array in php, then use json_encode() and set one variable to have all the array values in, such as
    <?php $vars = array( 'pid' => $pid ); ?> <script> var v = <?php echo json_encode($vars); ?>; </script>
     
    Then to call the variable for $pid in JS, you could just use

    v.pid
    This is a more convoluted method for the single variable, but if you're passing multiple, this becomes far more convenient and means you don't have to assign loads of variables in JS
  6. Like
    Jay Gilford got a reaction from web-itec in htaccess help needed   
    Change
     
    RewriteRule ^(.*)$ http://www.website.co.uk/$1 [R=301,L]
    to
     
    RewriteRule ^(.*)$ index.php?page=$1 [R=301,L]
  7. Like
    Jay Gilford got a reaction from Neji in MySQL - Querying Multiple Tables   
    Yeah, you're going to need to give the join definition as well. You also only seem to be running the search on one table column (title). You should have
     
    WHERE (title LIKE '%$search_term%' OR newsTitle LIKE '%$search_term%')";
  8. Like
    Jay Gilford got a reaction from Neji in MySQL - Querying Multiple Tables   
    You can rename field names using an alias, such as
    SELECT `column_name` AS `alias_name` FROM .....
  9. Like
    Jay Gilford got a reaction from Bravo81 in Little help on While Loops with an Array.   
    do a var_dump on $sth and see what it outputs. You seem to be using an object and a standard function for databases simultaneously which shouldn't be done. I would imagine the values in $sth are an array of results, and that you just need to use a foreach for those
  10. Like
    Jay Gilford got a reaction from MWP in Check boxes on contact form   
    You're definitely going to need JS to get the effect you want for the checkboxes and also to make the single text box editable for certain values. It's worth noting that you are going to need to validate it regardless once the form is submitted, as JScan be bypassed/disabled pretty easily and while a majority of people do use JS, not all do. As for where to learn - I see you're using jQuery which is a great library and the one I use for everything. I'd recommend using this site
    http://www.learningjquery.com/
    or getting the sitepoint jQuery novice to ninja eBook
  11. Like
    Jay Gilford got a reaction from kensha in A small business question regarding to   
    MVC isn't a language, nor does it only work with ASP. MVC is a way for you to set up your web application to keep various parts separate
    Take a look at the wikipedia webpage
    http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
    for more info
     
    In terms of MVC for PHP, take a look at CakePHP, Zend framework and Code igniter. All of those are good frameworks
  12. Like
    Jay Gilford got a reaction from Sogo7 in Is my form being spammed?   
    hehe well client side you should have to change very little, but you'll need to basically replicate your checking php side and add errors client side accordingly. As for the cleaning data - well that can also apply to your contact form depending on how it's set up. For example, check this out
    http://www.tonyspencer.com/2005/12/15/email-injection-exploit-through-a-php-contact-form/
     
    It may not apply to your form, but it's worth a read for any future contact forms
  13. Like
    Jay Gilford got a reaction from Pete Prosper in space after echo   
    You can use
     
    or wrap the item in a span, and add a margin-right style to it for finer control
  14. Like
    Jay Gilford got a reaction from jackmcconnell in Problem executing some PHP   
    While I'm not sure as to the problem, you should probably have put somewhere that your problem relates to wordpress as well
  15. Like
    Jay Gilford got a reaction from web-itec in HTaccess help needed   
    RewriteEngine On RewriteBase / RewriteRule ^/website/$ /website/home/ [R=301,L]
     
    Something like that should do it
     
    Note that the / after the ^ might not be required, so if it doesn't work, remove that
  16. Like
    Jay Gilford got a reaction from Renaissance-Design in Problem with php product lock code   
    so the first code line I gave you above gives you the current product ID in the variable...now you add that to your query string, so you'd use

    "SELECT `status` FROM `product_lock_sold` WHERE `product_id` = '" . $product_id . "'"
  17. Like
    Jay Gilford got a reaction from Renaissance-Design in Problem with php product lock code   
    If you're on the product page, you need to get the product ID from there. It's pretty easy to do

    $product_id = (int) $this->request->get['product_id'];
     
    While I appreciate you're learning php/mysql, you should really be adhering to Opencart standards, and using the right tools. For example, instead of what you have above for the querying, it should be
     

    $result = $this->db->query("Query here"); if($result->num_rows) { ... Code here if there's matches ... }
  18. Like
    Jay Gilford got a reaction from roothost in Undoing a 301 redirect   
    Some browsers cache the 301, so you may need to clear your browser's cache for that page. I'm not sure exactly how long they cache it for
  19. Like
    Jay Gilford got a reaction from funsella in A little help setting up 301 redirects   
    If you've deleted all of the old htm files, you could just use a simple file exists to work out if you need to rewrite it

    RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)\.htm$ $1.html [R=301,L]
  20. Like
    Jay Gilford got a reaction from DigitalSquid in A little help setting up 301 redirects   
    If you've deleted all of the old htm files, you could just use a simple file exists to work out if you need to rewrite it

    RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)\.htm$ $1.html [R=301,L]
  21. Like
    Jay Gilford got a reaction from Aled Mann in UK Hosting Wanted   
    Seems a bit bad you are posting an affiliate link jamesosix, considering you weren't even the original person to suggest it, though I have a feeling this thread will no doubt attract a few such links
  22. Like
    Jay Gilford got a reaction from garym in What does .= mean in PHP?   
    The assignment operator is a shorthand for
    $a .= 'some string';
     
    is the equivalent of
    $a = $a . 'somestring';
     
    See here for more information
  23. Like
    Jay Gilford got a reaction from garym in What's wrong with this PHP code?   
    That should work perfectly. My guess is you don't have php parsing on when it's run. Do you have the .html extension instead of .php?
  24. Like
    Jay Gilford got a reaction from garym in What's wrong with this PHP code?   
    Have you set a webserver up on your local machine? or are you using hosting to test this?
    If you haven't set up a webserver, I'd recommend WAMP or XAMPP for windows. html is not parsed as PHP. to parse php, you need to use the .php extension, and access the file using your browser's localhost
  25. Like
    Jay Gilford got a reaction from garym in What's wrong with this PHP code?   
    And you're getting no output whatseover? Is the title showing in the browser at least?

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.