Reputation Activity
-
Jay Gilford got a reaction from techkid in Wrapping my head around sessions and cookies1. 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)
-
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
-
Jay Gilford reacted to Renaissance-Design in PHP refreshing my pageYou 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.
-
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()
-
Jay Gilford got a reaction from webdeveloper93 in Passing php variables to javascriptNot 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
-
Jay Gilford got a reaction from web-itec in htaccess help neededChange
RewriteRule ^(.*)$ http://www.website.co.uk/$1 [R=301,L]
to
RewriteRule ^(.*)$ index.php?page=$1 [R=301,L]
-
Jay Gilford got a reaction from Neji in MySQL - Querying Multiple TablesYeah, 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%')";
-
Jay Gilford got a reaction from Neji in MySQL - Querying Multiple TablesYou can rename field names using an alias, such as
SELECT `column_name` AS `alias_name` FROM .....
-
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
-
Jay Gilford got a reaction from MWP in Check boxes on contact formYou'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
-
Jay Gilford got a reaction from kensha in A small business question regarding toMVC 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
-
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
-
Jay Gilford got a reaction from Pete Prosper in space after echoYou can use
or wrap the item in a span, and add a margin-right style to it for finer control
-
Jay Gilford got a reaction from jackmcconnell in Problem executing some PHPWhile I'm not sure as to the problem, you should probably have put somewhere that your problem relates to wordpress as well
-
Jay Gilford got a reaction from web-itec in HTaccess help neededRewriteEngine 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
-
Jay Gilford got a reaction from Renaissance-Design in Problem with php product lock codeso 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 . "'"
-
Jay Gilford got a reaction from Renaissance-Design in Problem with php product lock codeIf 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 ... }
-
Jay Gilford got a reaction from roothost in Undoing a 301 redirectSome 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
-
Jay Gilford got a reaction from funsella in A little help setting up 301 redirectsIf 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]
-
Jay Gilford got a reaction from DigitalSquid in A little help setting up 301 redirectsIf 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]
-
Jay Gilford got a reaction from Aled Mann in UK Hosting WantedSeems 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
-
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
-
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?
-
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
-
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?