Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Monday, 27 February 2012

PHP Fix: file_get_contents Not Working

If you are try to load contents of a page using the following functions you maybe suprised to find it not working.


$page =urldecode ($_POST["url"]);
$file = file_get_contents($page, true);
echo rawurlencode($file);

I order to make it work you need to add a file within the folder where the php script is sitting. This file is called 'php.ini'.

In this file add the following line to enable you to use the function above:

allow_url_fopen = On

Thats it!


Tuesday, 5 July 2011

PHP creating a session

When creating a session you need to do the following:
session_name ('datebycupid');
session_start();
$_SESSION['user_email'] =  $user_email;

to check a session you need to do the following:

session_name('datebycupid');
 session_start();
 if(isset($_SESSION['user_email']))

Issues

Header already sent: check that the <?php tag has no leading whitespaces.