I am trying to write a php script to access a database a and write user info into a table upon login. Currently I appended the script to the bottom of the profile file in /etc/profile. However, it doesn't appear to be working when I log in. Below is the script that i have.
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|
$1($|
" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# ksh workaround
if [ -z "$EUID" -a -x /usr/bin/id ]; then
EUID=`id -u`
UID=`id -ru`
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
if [ -x /usr/bin/id ]; then
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
CLASSPATH=/usr/lib/jdk1.6.0_07/lib:.
PATH=$PATH:/usr/lib/jdk1.6.0_07/bin:.
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC CLASSPATH
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done
unset i
unset pathmunge
<?
//make connection
$connection = pg_connect("dbname=postgres
user=postgres
host=localhost");
//report status
if(!connection){
print("Connection Failed.");
exit;
}
//insert data into userstats
//insert data into userstats
pg_exec($connection, "INSERT INTO userstats VALUES
('$USER','localhost')");
?>
Can somebody help me find a way to solve this problem?