php

Is it safer to transfer previous page location via GET method rather than HTTP_REFERER?

I want to store the page location the user came from (on my site). I want to do that for this example: say someone sent a comment without being logged in. "process_comment.php" will process it and send a header(location:$_GET['prev_page']); Of course I'm gonna filter $_GET before sending it. Should I use a session instead? Thanks! ...

Caching data by using hidden divs

I'm trying to speed up response times in my ajax web application by doing the following: Say the user requests a page whose contents don't change (e.g a web form). When the user makes a different request, I 'cache' the form by putting it in a hidden div. Before displaying the new information. So the form is basically still loaded in th...

Checking a value exists

I have the following checkboxes in my form, id like to know how to check at least one of them are checked without changing the name of them. <label for="branding">Branding <input type="checkbox" name="branding" id="branding" class="checkbox" /></label> <label for="print">Print <input type="checkbox" name="print" id="print" class="checkb...

PHP object Singleton not working

Hi I am programming a website backend in PHP and I need to encapsulate $_SESSION in a class. I've made my Session class a singleton but I am having trouble using it. class Session { private static $instance; public static $sessionID; private function __construct() { session_start(); self::$ses...

PHP date comparison

How would I check if a date in the format "2008-02-16 12:59:57" is less than 24 hours ago? ...

PHP charting library

I'm looking for a PHP chart library, with a few specific criteria: I can't use Google charts because, in at least one case, I need to be able to run on a private network with no internet access (ergo no Google). I need to be able to produce bitmapped images (png, etc). SVG would also be nice, and Flash is acceptable as an extra, but t...

send html link variable to jquery ajax php-file

i want to use jquery to retrieve a variable embedded in a html link, spo i can send it to the php file with jquery ajax. but i dont know how to do this. this is what i have written: <script ...> $("a").click(function(){ $.post("helpers/ajaxcall_country.php", {"HERE I WANT TO SEND THE VARIABLE"}, function(data){...

PHP: transfer a large array between two sites

I'm trying to transfer a large array between two sites in PHP. I'm the admin in both. The array is created on one site, and after its creation I wish to automatically redirect the user to the other site, and pass the processed array along. I cannot use the SESSION superglobal, as it is limited to a specific domain. GET is not suitable...

How does wordpress know about its functions?

Specifically in theme php files, such as say index.php. The very first thing in most theme's index.php file is a call to get_header() which is most certainly not not defined in index.php, so how does it know about that function? I'm not very familiar with php, but from what I've read just now there is an include and require keyword whi...

PHP: Curl can't grab a text-only page on my own site

I'm attempting to use curl inside php to grab a page from my own web server. The page is pretty simple, just has some plain text output. However, it returns 'null'. I can successfully retrieve other pages on other domains and on my own server with it. I can see it in the browser just fine, and I can grab it with command line wget jus...

From a coder's perspective, what kind of project should I choose python over php for where both could do the job?

I've never used python before. I've used php for about 5 years now. I plan to learn python, but I'm not sure what for yet. If I can think of a project that might be better to do in python, I'll use that to learn it. Edit: just to add this as an important note, I do mean strictly for linux, not multi-platform. Edit 2: I'm hoping for obje...

Amazon Product Availability

Many products on amazon are unavailable but a date is given for when they'll be in stock. I've used AWS and got an XML reply but I can't find the date information anywhere. Is it possible to get this information? Thanks. NOTE: This is what i've got as a request, what should I alter? http://ecs.amazonaws.com/onca/xml?AWSAccessKeyId=MYID...

php while array1 is empty iterate

How can iterate with a while loop until array1 is empty. So far based on several conditions I'm pushing elements from array1 to array2. But I want to iterate array1 until everything from array1 is in array2. something like: // or while everything from array1 is on array2 while(array1 is empty){ if(somecondition1) array_push(ar...

Is authentication a concern of my domain or of my application?

I'm trying to design the authentication of my web application in an object oriented manner. Is this a concern of my domain in which case I would have something like this: $user->authenticate($authenticator); $user->login($authenticator); Where $authenticator is an interface to my authentication service. Or would this be a cross cutti...

PHP Regex HTML Assistance

I need to write a regular expression using php which parses the following code block and removes all <font> and </font> tags. <p align="left"><font face="Arial" size="1">February 22, 2007</font></p> <p align="left"><b><font face="Arial" size="4">2K Sports Announces Major League Baseball 2K7 Has Gone Gold </font></b></p> ...

Perl to PHP With s///;

In perl, I can do: 1 while $var =~ s/a/b/;, and it will replace all a with b. In many cases, I would use it more like 1 while $var =~ s/^"(.*)"$/$1/; to remove all pairs of double quotes around a string. Is there a way to do something similar to this in PHP, without having to do while (preg_match('/^"(.*)"$/', $var)) { $var = preg...

Contact form using PHP and jQuery form plugin

I'm using the jQuery Form plugin to submit AJAX requests. It's a simple contact from using this PHP script: http://pastie.org/725652 - the only validation happens inside the PHP. Here's my Javascript code to trigger the whole thing: $('#contactform').ajaxForm({ target: '#error', beforeSubmit: function() { $('#error').a...

PHP get result string from PostgreSQL Query

I'm new to PHP and SQL, but I need a way to store the result of an SQL Query into a variable. The query is like this: $q = "SELECT type FROM users WHERE username='foo user'"; $result = pg_query($q); The query will only return one string; the user's account type, and I just need to store that in a variable so I can check to see if the...

json_encode url fail

Has anyone way around this bug? echo json_encode(array('url'=>'/foo/bar')); {"url":"\/foo\/bar"} I use Zend_Json and Zend_Json_Expr so I can get even callback functions inside my js object -- but I can't get a url to come out in a usable format! echo Zend_Json::encode(array( 'url'=>new Zend_Json_Expr('/foo/ba...

Are sockets so slow in PHP?

I'm using this code for sockets. Console says that the page is processed for a very small amount of time, but Chrome says that page is loading for ~1 second! $this->serv_sock = socket_create(AF_INET, SOCK_STREAM, 0); socket_bind($this->serv_sock, $this->serv, $this->port) or die("Could not bind to address\n"); socket_listen($th...