PHP: Get informed by e-mail when someone visits your site

The code below sends e-mail when someone visits your site (except yourself, assuming that you are testing locally): if(!empty($_REQUEST)){ $theRemoteAddr = $_SERVER['REMOTE_ADDR']; $theRemoteHost = gethostbyaddr($_SERVER['REMOTE_ADDR']); //send mail: $receiver="myself@mymail.com"; $from="info@swkb.net"; $subject="someone…

Continue ReadingPHP: Get informed by e-mail when someone visits your site

PHP: Connect to DB and fetch data

Code from login page: $link=mysql_connect("localhost","dbuser","****");if(!$link){ die("Couln't open database!");}$db="myschema"; mysql_select_db($db) or die("Could not open $db");if(!empty($_REQUEST['user'])){ $theUser=$_REQUEST['user'];}else{ $theUser="";}$result=mysql_query("SELECT * FROM users WHERE UserName='$theUser' ");$num_rows=mysql_num_rows($result);while($a_row=mysql_fetch_row($result)){ if($_REQUEST['pass']==stripslashes($a_row[1])){ $msg=""; $_SESSION['user']=$theUser; $_SESSION['userGroup']="admin";             }}

Continue ReadingPHP: Connect to DB and fetch data