$server="localhost"; $user="CAS"; $pw="lotuselanK1!"; $cn = mysql_connect ($server,$user,$pw) or die('Database unavailable. Please try again later.'); mysql_select_db("csdb"); $sqlq = "select * from gal_pics where gpic_fname = '".$pic."' and gpic_gall_name = '".$gal."'"; $rs = mysql_query($sqlq); $NumRows = mysql_num_rows($rs); if (!isset($fromform)) { if ($NumRows != 0) { $k = mysql_fetch_row($rs); $title = $k[3]; } else { $title = ''; } echo "\n"; echo "
\n"; echo "Add a comment for this photo...
\n"; echo "\n"; echo "\n"; echo "\n"; } else { $today = getdate(); $tstamp = $today['year']."-".substr($today['mon'],0,3)."-".$today['mday']." ".$today['hours'].":".$today['minutes'].":".$today['seconds']; if (!isset($cancel)) { if ($inp_com != '') { if ($inp_name != '') { if ($NumRows == 0) { $sqlq = "insert gal_pics values (null,'".$pic."','','','".$gal."')"; mysql_query($sqlq); $sqlq = "select * from gal_pics where gpic_fname = '".$pic."' and gpic_gall_name = '".$gal."'"; $rs = mysql_query($sqlq); $k = mysql_fetch_row($rs); } else { $sqlq = "select * from gal_pics where gpic_fname = '".$pic."' and gpic_gall_name = '".$gal."'"; $rs = mysql_query($sqlq); $k = mysql_fetch_row($rs); } } } } $mailstring = "Gallery : ".$gal."\n"; $mailstring .= "Picture : ".$pic."\n"; $mailstring .= "Name : ".$inp_name."\n"; $mailstring .= "Text : ".$inp_com."\n"; $mailstring .= "User Agent : ".$_SERVER['HTTP_USER_AGENT']."\n"; $mailstring .= "Remote Addr: ".$_SERVER['REMOTE_ADDR']."\n"; $mailstring .= "Remote Port: ".$_SERVER['REMOTE_PORT']."\n"; mail("comments@calumscott.me.uk","Picture Comment Request",$mailstring,"From: comments@calumscott.me.uk\r\n"); header("Location: showpic.php?gal=".$gal."&pic=".$pic); exit; } ?>