Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- LOGIN CREDENTIALS ARE HERE - REMOVED FOR PRIVACY OF CLIENT
- ?>
- <?
- $picid = $_POST["picid"];
- $action = $_POST["action"];
- if ($action == "add") {
- $depname = $_POST["depname"];
- $deptitle = $_POST["deptitle"];
- $depimage = basename($_FILES['depimage']['name']);
- $picture = $_FILES["depimage"]["name"];
- //Any error except "No File Uploaded (4)" gets handled here:
- if (($_FILES["depimage"]["error"] > 0) && ($_FILES["depimage"]["error"] != 4) )
- {
- echo "Error: " . $_FILES["depimage"]["error"] . "<br />";
- }
- else
- {
- //No File, no name and no title means we just skip it.
- if (($_FILES["depimage"]["error"] == 4) && ($depname == '') && ($deptitle == '')) {
- echo "No information entered.";
- }
- else if (($_FILES["depimage"]["error"] == 4) && ($depname != '') && ($deptitle != ''))
- //Data was entered for title and name but not file.
- {
- $picture = "imagenotfound.jpg";
- $query = "UPDATE deputies SET name='$depname', title='$deptitle', photo='$picture' WHERE id = $picid";
- $result = mysql_query($query);
- mysql_close();
- if ($result) {
- print('Add Officer was successful. Press the "Close Window" button below to close this window and refresh the editor.<br><br>');
- print('<span width="100%" align="center"><a href="javascript:window.close();">Close this Window</span>');
- }
- }
- //All data was entered
- else
- {
- if (file_exists("images/deputies/photos/" . $_FILES["depimage"]["name"]))
- {
- echo $_FILES["depimage"]["name"] . " already exists.<br />";
- }
- else
- {
- $final_file_path = "images/deputies/photos/" . basename($_FILES["depimage"]["name"]);
- move_uploaded_file($_FILES["depimage"]["tmp_name"],$final_file_path);
- chmod($final_file_path,0777);
- $query = "UPDATE deputies SET name='$depname', title='$deptitle', photo='$picture' WHERE id = $picid";
- $result = mysql_query($query);
- mysql_close();
- if ($result) {
- print('Add Officer was successful. Press the "Close Window" button below to close this window and refresh the editor.<br><br>');
- print('<span width="100%" align="center"><a href="javascript:window.close();">Close this Window</span>');
- }
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement