$realname = basename($_SERVER['HTTP_REFERER'], ".php");
Friday, 25 October 2013
Multiple submit button in a single form in PHP
<form method="post">
<input type="submit" name="save" value="Submit 1">
<input type="submit" name="cancel" value="Submit 2">
</form>
<?php
if (isset($_POST['save'])) {
// code
}
else if (isset($_POST['cancel'])) {
// code
}
?>
<input type="submit" name="save" value="Submit 1">
<input type="submit" name="cancel" value="Submit 2">
</form>
<?php
if (isset($_POST['save'])) {
// code
}
else if (isset($_POST['cancel'])) {
// code
}
?>
Thursday, 24 October 2013
Installing the Java Plugin for Firefox on CentOS
The OpenJDK bundled with CentOS is missing a java plugin for Firefox. A simple method of getting Java to run inside the webbrowser and to run java applications is to install icedtea-web
Open a terminal and type the below command
yum install icedtea-web
Then restart your browser
Click Tools- >Add-ons
The Add-ons Manager tab will open.
In the Add-ons Manager tab, select Plugins
Click icedtea-web plugin to select it and click on the Enable button
The java verification applet (http://www.javatester.org/version.html) works fine.
Open a terminal and type the below command
yum install icedtea-web
Then restart your browser
Click Tools- >Add-ons
The Add-ons Manager tab will open.
In the Add-ons Manager tab, select Plugins
Click icedtea-web plugin to select it and click on the Enable button
The java verification applet (http://www.javatester.org/version.html) works fine.
Installing and configuring Java in cent OS
Most of the Linux operating systems comes with pre-installed OpenJDK package to run java-based applications and plugins.But in certain cases we need Sun/Oracle Java program to compile and run
particular development applications.
1. Download java from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. install java using rpm -uvh
## Install Java on 32-Bit OS ##
# rpm -Uvh jdk-7u45-linux-i586.rpm
# rpm -Uvh jdk-7u45-linux-i586.rpm
## Install Java on 64-Bit OS ##
# rpm -Uvh jdk-7u45-linux-x64.rpm
# rpm -Uvh jdk-7u45-linux-x64.rpm
3. check java installed
# java -version
output should be
java version "1.7.0_45"
4. Setting up java environment variables
The easiest way to set an environment variable in CentOS is to use export as in
$> export JAVA_HOME=/usr/java/jdk.1.7.0_45
$> export PATH=$PATH:$JAVA_HOME
However, variables will disappear the moment you exit the shell. Obviously this is not helpful when setting environment variables that need to persist even when the system reboots.In such cases, you need to set the variables within the system wide profile. In CentOS , the folder /etc/profile.d/ is the recommended place to add customizations to the system profile.
5. Create a new file called java.sh
vim /etc/profile.d/java.sh
6. Copy paste the below content in java.sh
export JRE_HOME=/usr/java/jdk.1.7.0_45/jre
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/usr/java/jdk.1.7.0_45
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
7. If you want to load the environment variables within java.sh without having to restart the machine, you can use the source command as in:
$> source java.sh
particular development applications.
1. Download java from
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. install java using rpm -uvh
## Install Java on 32-Bit OS ##
# rpm -Uvh jdk-7u45-linux-i586.rpm
# rpm -Uvh jdk-7u45-linux-i586.rpm
## Install Java on 64-Bit OS ##
# rpm -Uvh jdk-7u45-linux-x64.rpm
# rpm -Uvh jdk-7u45-linux-x64.rpm
3. check java installed
# java -version
output should be
java version "1.7.0_45"
4. Setting up java environment variables
The easiest way to set an environment variable in CentOS is to use export as in
$> export JAVA_HOME=/usr/java/jdk.1.7.0_45
$> export PATH=$PATH:$JAVA_HOME
However, variables will disappear the moment you exit the shell. Obviously this is not helpful when setting environment variables that need to persist even when the system reboots.In such cases, you need to set the variables within the system wide profile. In CentOS , the folder /etc/profile.d/ is the recommended place to add customizations to the system profile.
5. Create a new file called java.sh
vim /etc/profile.d/java.sh
6. Copy paste the below content in java.sh
export JRE_HOME=/usr/java/jdk.1.7.0_45/jre
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/usr/java/jdk.1.7.0_45
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
7. If you want to load the environment variables within java.sh without having to restart the machine, you can use the source command as in:
$> source java.sh
Wednesday, 23 October 2013
Add horizontal scrollbar to html table
Inorder to add a horizontal scroll bar on html table automatically as the table grows, we need to wrap the table inside a div and add overflow:auto css property
For eg:
<div style="white-space:pre; overflow:auto;width:500px; padding:10px;">
<table style="width:900px;">
<tr>
<td>text1</td>
<td>text2</td>
<td>text3</td>
</tr>
</table>
</div>
Friday, 4 October 2013
Fatal error: Call to undefined function http_redirect() : Fixed
Issue: When I was trying to call the PHP
Fatal error: Call to undefined function http_redirect() in location.
Add the below function in your php page
/**
* redirect to a specific URL
* @param $url
*/
function redirect($url)
{
if (!headers_sent())
{
//If headers not sent yet... then do php redirect
header('Location: '.$url); exit;
}
else
{
//If headers are sent... do javascript redirect...
//if javascript disabled, do html redirect.
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>'; exit;
}
}
then call the above function to the page you wish the redirect to happen on
eg: redirect("redirect.php");
http_redirect()
function, below error came up:Fatal error: Call to undefined function http_redirect() in location.
Add the below function in your php page
/**
* redirect to a specific URL
* @param $url
*/
function redirect($url)
{
if (!headers_sent())
{
//If headers not sent yet... then do php redirect
header('Location: '.$url); exit;
}
else
{
//If headers are sent... do javascript redirect...
//if javascript disabled, do html redirect.
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>'; exit;
}
}
then call the above function to the page you wish the redirect to happen on
eg: redirect("redirect.php");
Friday, 12 July 2013
Cannot access xampp from internet in Cent OS
Issue
I have xampp installed on Cent OS. I started the xampp server and tried to access it with localhost, it is working. But i cant access it using the system IP. I can ping the server.But I can't access the server from any other computer on the network.
Solution
The default firewall of CentOS permits ssh input(tcp 22) and icmp(ping). Open a terminal and type
Go to File System -> etc - >sysconfig
Open iptables. Remove the below line
Now your iptables looks like
Start your firewall issuing the following command:
I have xampp installed on Cent OS. I started the xampp server and tried to access it with localhost, it is working. But i cant access it using the system IP. I can ping the server.But I can't access the server from any other computer on the network.
Solution
The default firewall of CentOS permits ssh input(tcp 22) and icmp(ping). Open a terminal and type
[root@ ~]# cat /etc/sysconfig/iptables
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
Try at first stopping your firewall issuing the following command: [root@ ~]# /etc/init.d/iptables stop
Now, test if you can access your XAMPP server.Go to File System -> etc - >sysconfig
Open iptables. Remove the below line
-A INPUT -j REJECT --reject-with icmp-host-prohibited
Add the below new lineiptables -A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 80,443 -j ACCEPT
It enables the ports you need to access(80 , 443).Now your iptables looks like
Save the file and close it.# Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp -m multiport --dports 80,443 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
Start your firewall issuing the following command:
[root@ ~]# /etc/init.d/iptables start
Now you can access your XAMPP server using your macine ip address
Subscribe to:
Posts (Atom)