How to switch on PHP magic quotes gpc and magic quotes runtime on Hostgator reseller hosting

There are two steps involved in it.

First, under public_html folder, in .htaccess file write the following code.

<IfModule mod_suphp.c>
suPHP_ConfigPath /home/username
<Files php.ini>
order allow,deny
deny from all

*Replace username with your hosting account’s username (NOT the main reseller username).

Then under /home/username folder, create a php.ini file and write the below mentioned code in it.

magic_quotes_gpc = On
magic_quotes_runtime = On

Please make sure there are no empty spaces at the end of .htaccess and php.ini files.

How to prevent ENTER keypress to submit a web form

Place the following code in head.

<script type=”text/javascript”>
function searchItem(e){
e = e? e : window.event;
var k = e.keyCode? e.keyCode : e.which? e.which : null;
if (k == 13){

if (e.preventDefault)
//Your action here
return false;


return true;

Call in form like this.

<form id=”form1″ name=”form1″ method=”post” action=”">
<input type=”text” name=”textfield” onkeypress=”return searchItem(event)” />
<input type=”submit” name=”Submit” value=”Submit” />


How do I detect mobile browser in PHP?

// Create the function, so you can use it 
function isMobile() { 
 return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]); 
// If the user is on a mobile device, redirect them 
if(isMobile()) header("Location:");

Can you recommend some post upload checks?

  1. Delete unwanted files, like ‘test’, ‘copy of’, etc.
  2. Give write permission (777) to the required folders.
  3. If .htaccess file has been uploaded, make sure it runs according the the server settings. Sometimes .htaccess files run on local but not on server.
  4. Make configuration settings according to server where required, like database connections, file paths, etc.
  5. Do not upload folders required for local copy of the web site like ‘backup’,'db’, etc – if you maintain them.
  6. In folders where there are no index/default files, place a blank index/default file to avoid directory listing. If this is not done, a site visitor can type in the folder path in browser URL and see all files in that folder which is not a good idea. This can also be done using .htaccess file with the following code. Options -Indexes