Jump to content

jesushax

Members
  • Posts

    498
  • Joined

  • Last visited

    Never

Everything posted by jesushax

  1. hi all below is my add news script, it currently only upolads what ever is in teh picture[0] field anyone have any ideas? Thanks <?php function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){ // SET THE IMAGE COMPRESSION $g_imgcomp=100-$imgcomp; // CHECK TO SEE IF THE IMAGE EXISTS FIRST if(file_exists($sourcefile)){ // FIRST WE GET THE CURRENT IMAGE SIZE $g_is=getimagesize($sourcefile); /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/ // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){ // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE $new_width=$g_is[0]; $new_height=$g_is[1]; } else { // GET VALUE TO CALCULATE WIDTH AND HEIGHT $w_adjust = ($maxsize / $g_is[0]); $h_adjust = ($maxsize / $g_is[1]); // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT if($w_adjust <= $h_adjust){ // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER $new_width=($g_is[0]*$w_adjust); $new_height=($g_is[1]*$w_adjust); } else { // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER $new_width=($g_is[0]*$h_adjust); $new_height=($g_is[1]*$h_adjust); } } //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." ) $image_type = strrchr($sourcefile, "."); //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION switch($image_type) { case '.jpg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.jpeg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.png': $img_src = imagecreatefrompng($sourcefile); break; case '.gif': $img_src = imagecreatefromgif($sourcefile); break; default: echo("Error Invalid Image Type"); die; break; } // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT $img_dst=imagecreatetruecolor($new_width,$new_height); // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]); // OUTPUT THE IMAGE AS A JPEG. // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE. imagejpeg($img_dst, $destination, 100); // DESTROY THE NEW IMAGE imagedestroy($img_dst); return true; } else { return false; } } switch(@$_GET["action"]) { Case "add": session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/editor_level.inc'); $absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/";//Absolute path to where files are uploaded $thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/thumbs/"; //Absolute path to where thumbs are to be stored if you want this $size_limit = "yes"; //do you want a size limit yes or no. $limit_size = "4000000"; //How big do you want size limit to be in bytes $limit_ext = "yes"; //do you want to limit the extensions of files uploaded $ext_count = "4"; //total number of extensions in array below $extensions = array(".jpg", ".jpeg", ".png", ".gif"); //List extensions you want files uploaded to be $extens = ''; if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) { $extens = "any extension"; } else { $ext_count2 = $ext_count+1; for($counter=0; $counter<$ext_count; $counter++) { $extens .= " $extensions[$counter]"; } } if (($limit_size == "") or ($size_limit != "yes")) { $limit_size = "any size"; } else { $limit_size .= " bytes"; $mb_size = ($limit_size/1000000); } $NewsTitle = mysql_escape_string($_POST["NewsTitle"]); $NewsShort = mysql_escape_string($_POST["NewsShort"]); $NewsAttach = $_FILES['NewsAttachment']['name'][0]; $NewsImage1 = $_FILES['pictures']['name'][0]; $NewsImage2 = $_FILES['pictures']['name'][1]; $NewsFull = mysql_escape_string($_POST["NewsFull"]); $NewsDate = date("Y-m-d"); if (($_POST["chkCons"]) == "1") { $Cons = "1"; } else { $Cons = "0"; } if (($_POST["chkCity"]) == "1") { $City = "1"; } else { $City = "0"; } mysql_query("INSERT INTO tblNews ( NewsTitle, NewsShort, NewsImage1, NewsAttachment, NewsFull, NewsImage2, NewsDateAdded, NewsArchive,Cons,City) Values ( '$NewsTitle', '$NewsShort', '$NewsImage1', '$NewsAttach', '$NewsFull', '$NewsImage2', '$NewsDate','0','$Cons','$City') ") or die(mysql_error()); $error=0; foreach ($_FILES["pictures"]["error"] as $key => $error) { $file_name = $_FILES["pictures"]['name'][$error]; // can call this anything you like this will take the original name $file = $_FILES["pictures"]['tmp_name'][$error]; $file_size = $_FILES["pictures"]['size'][$error]; if (($size_limit == "yes") &&($limit_size < $file_size)) { header("Location: /admin/news/edit_news.php?error=filesize"); } else { $ext = strrchr($file_name,'.'); if (($limit_ext == "yes") && (!in_array($ext,$extensions))) { echo $image_type; //header("Location: /admin/news/edit_news.php?error=filetype"); }else{ $j = $error + 1; // first move the file to move_uploaded_file($file, $absolute_path.$file_name); // Save full size image with max width/height resampleimage("175", $absolute_path.$file_name, $absolute_path.$file_name, 0); //resampleimage("125", $absolute_path.$file_name, $thumb_path.$file_name, 0); } } $error++; } $ESQL = mysql_query("SELECT `NewsID`,`City`,`Cons`,`NewsTitle` FROM `tblNews` WHERE `NewsTitle`='$NewsTitle'") or die(mysql_error()); $ER = mysql_fetch_array($ESQL); if ($ER["Cons"] !="1" && $ER["City"] !="1") { header("Location: /admin/news/edit_news.php?ID=".$ER["NewsID"]."&action=error1"); } else{ header("Location: /admin/news/default.php"); } break; default: include($_SERVER['DOCUMENT_ROOT'] . '/includes/staff_header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $size_limit = "yes"; //do you want a size limit yes or no. $limit_size = "4000000"; //How big do you want size limit to be in bytes $limit_ext = "yes"; //do you want to limit the extensions of files uploaded $ext_count = "4"; //total number of extensions in array below $extensions = array(".jpg", ".jpeg", ".png", ".gif"); //List extensions you want files uploaded to be $extens = ''; if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) { $extens = "any extension"; } else { $ext_count2 = $ext_count+1; for($counter=0; $counter<$ext_count; $counter++) { $extens .= " $extensions[$counter]"; } } if (($limit_size == "") or ($size_limit != "yes")) { $limit_size = "any size"; } else { $limit_size .= " bytes"; $mb_size = ($limit_size/1000000); } $pichead = '<ul style="color:#FF0000; font-size:10px; list-style:none;">'; $pichead .='<li>File extension must be '.$extens.'</li>'; $pichead .='<li>Maximum file size is '.$mb_size.' Megabytes</li>'; $pichead .='<li>No spaces in the filename</li>'; $pichead .= '</ul>'; echo"<h2>Add News</h2>\n"; include($_SERVER['DOCUMENT_ROOT'] . '/admin/news/navigation.php'); ?> <form action="<? echo $_SERVER['PHP_SELF'];?>?action=add" method="post" enctype="multipart/form-data"> <table width="100%" cellpadding="0" cellspacing="0"> <tr><td colspan="2">News Images:</td></tr> <tr><td><table cellpadding="0" cellspacing="0"> <?php $files = 2; // Change this line for the number of uploads you want to allow for($i=1; $i<=$files; $i++){ echo "<tr><td>Image $i :</td><td><input type=\"file\" name=\"pictures[]\" size=\"50\" /></td></tr>\n"; } ?> <tr> <td>Attachment : </td> <td><input name="NewsAttachment[]" type="file" id="ufile[]" size="50" /></td> </tr> </table></td> <td><? echo $pichead; ?></td></tr> <tr> <td colspan="2"><hr /></td> </tr> <tr> <td colspan="2" style="width:80%;"><span style="width:20%;">News Title: </span></td> </tr> <tr> <td colspan="2" style="width:80%;"> <input type="text" size="45" name="NewsTitle" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">News Brief :</td> </tr> <tr> <td colspan="2"><textarea name="NewsShort" id="NewsShort" style="width:550px; height:175px;"></textarea></td> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" >News Full :</td> </tr> <tr> <td colspan="2"><textarea name="NewsFull" id="NewsFull" style="width:550px; height:175px;"></textarea></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">Submit News to Websites</td> </tr> <tr> <td colspan="2"> <table width="50%" border="0" cellpadding="0"> <tr> <td><input name="chkCons" type="checkbox" value="1" /></td> <td>Construction Works</td> <td><input name="chkCity" type="checkbox" value="1" /></td> <td>City Works</td> </tr> </table> </td> </tr> <tr> <td colspan="2" style="height:32px;"><div style=" text-align:center"> <input type="submit" name=submit value="Add News" /> <input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/news/default.php'" /> </div></td> </tr> </table> </form> <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/staff_footer.php'); break; } ?>
  2. yeah but then i wont be able to limit to image files, all files will be uploaded i dont want to stop the file check, just make it work cos it isnt at the moment ive tried uploading various types of jpg all of them come back error
  3. hi all, below is my full code for uploading news to my site, however i keep getting the errorfiletype message, ive highlighted in red where its going wrong, i just dont know why it is anyone help? Thanks <?php function resampleimage($maxsize, $sourcefile, $destination, $imgcomp=0){ // SET THE IMAGE COMPRESSION $g_imgcomp=100-$imgcomp; // CHECK TO SEE IF THE IMAGE EXISTS FIRST if(file_exists($sourcefile)){ // FIRST WE GET THE CURRENT IMAGE SIZE $g_is=getimagesize($sourcefile); /********* CALCULATE THE WIDTH AND THE HEIGHT ***************/ // CHECK TO SEE IF THE WIDTH AND HEIGHT ARE ALREADY SMALLER THAN THE MAX SIZE if($g_is[0] <= $maxsize && $g_is[1] <= $maxsize){ // LEAVE WIDTH AND HEIGHT ALONE IF IMAGE IS SMALLER THAN MAXSIZE $new_width=$g_is[0]; $new_height=$g_is[1]; } else { // GET VALUE TO CALCULATE WIDTH AND HEIGHT $w_adjust = ($maxsize / $g_is[0]); $h_adjust = ($maxsize / $g_is[1]); // CHECK TO WHICH DIMENSION REQUIRES THE SMALLER ADJUSTMENT if($w_adjust <= $h_adjust){ // CALCULATE WIDTH AND HEIGHT IF THE WIDTH VALUE IS SMALLER $new_width=($g_is[0]*$w_adjust); $new_height=($g_is[1]*$w_adjust); } else { // CALCULATE WIDTH AND HEIGHT IF THE HEIGHT VALUE IS SMALLER $new_width=($g_is[0]*$h_adjust); $new_height=($g_is[1]*$h_adjust); } } //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER THE LAST "." ) $image_type = strrchr($sourcefile, "."); //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION switch($image_type) { case '.jpg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.jpeg': $img_src = imagecreatefromjpeg($sourcefile); break; case '.png': $img_src = imagecreatefrompng($sourcefile); break; case '.gif': $img_src = imagecreatefromgif($sourcefile); break; default: echo("Error Invalid Image Type"); die; break; } // CREATE THE TRUE COLOR IMAGE WITH NE WIDTH AND HEIGHT $img_dst=imagecreatetruecolor($new_width,$new_height); // RESAMPLE THE IMAGE TO NEW WIDTH AND HEIGHT imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $new_width, $new_height, $g_is[0], $g_is[1]); // OUTPUT THE IMAGE AS A JPEG. // THIS CAN BE CHANGED IF YOU WANT TRANSPARENCY OR PREFER ANOTHER FORMAT. MAKE SURE YOU CHANGE HEADER ABOVE. imagejpeg($img_dst, $destination, 100); // DESTROY THE NEW IMAGE imagedestroy($img_dst); return true; } else { return false; } } switch(@$_GET["action"]) { Case "add": session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/editor_level.inc'); $absolute_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/";//Absolute path to where files are uploaded $thumb_path = $_SERVER['DOCUMENT_ROOT'] . "/news/uploads/thumbs/"; //Absolute path to where thumbs are to be stored if you want this $size_limit = "yes"; //do you want a size limit yes or no. $limit_size = "4000000"; //How big do you want size limit to be in bytes $limit_ext = "yes"; //do you want to limit the extensions of files uploaded $ext_count = "4"; //total number of extensions in array below $extensions = array(".jpg", ".jpeg", ".png", ".gif"); //List extensions you want files uploaded to be $extens = ''; if (($extensions == "") or ($extensions == " ") or ($ext_count == "0") or ($ext_count == "") or ($limit_ext != "yes") or ($limit_ext == "")) { $extens = "any extension"; } else { $ext_count2 = $ext_count+1; for($counter=0; $counter<$ext_count; $counter++) { $extens .= " $extensions[$counter]"; } } if (($limit_size == "") or ($size_limit != "yes")) { $limit_size = "any size"; } else { $limit_size .= " bytes"; $mb_size = ($limit_size/1000000); } $pichead = "<ul style=\"color:#FF0000; font-size:10px;\"><li style=\"display:inline; padding-right:10px;\">File extension must be $extens |</li>"; $pichead .="<li style=\"display:inline; padding-right:10px;\">Maximum file size is $limit_size ($mb_size MB) |</li> <li style=\"display:inline; padding-right:10px;\">No spaces in the filename</li></ul>"; $NewsTitle = mysql_escape_string($_POST["NewsTitle"]); $NewsShort = mysql_escape_string($_POST["NewsShort"]); $NewsAttach = $_FILES['NewsAttachment']['name'][0]; $NewsImage1 = $_FILES['pictures']['name'][0]; $NewsImage2 = $_FILES['pictures']['name'][1]; $NewsFull = mysql_escape_string($_POST["NewsFull"]); $NewsDate = date("Y-m-d"); if (($_POST["chkCons"]) == "1") { $Cons = "1"; } else { $Cons = "0"; } if (($_POST["chkCity"]) == "1") { $City = "1"; } else { $City = "0"; } mysql_query("INSERT INTO tblNews ( NewsTitle, NewsShort, NewsImage1, NewsAttachment, NewsFull, NewsImage2, NewsDateAdded, NewsArchive,Cons,City) Values ( '$NewsTitle', '$NewsShort', '$NewsImage1', '$NewsAttach', '$NewsFull', '$NewsImage2', '$NewsDate','0','$Cons','$City') ") or die(mysql_error()); $error=0; foreach ($_FILES["pictures"]["error"] as $key => $error) { $file_name = $_FILES["pictures"]['name'][$error]; // can call this anything you like this will take the original name $file = $_FILES["pictures"]['tmp_name'][$error]; $file_size = $_FILES["pictures"]['size'][$error]; if (($size_limit == "yes") &&($limit_size < $file_size)) { header("Location: /admin/news/edit_news.php?error=filesize"); } else { $ext = strrchr($file_name,'.'); [color=red]if (($limit_ext == "yes") && (!in_array($ext,$extensions)))[/color] { header("Location: /admin/news/edit_news.php?error=filetype"); }else{ $j = $error + 1; // first move the file to move_uploaded_file($file, $absolute_path.$file_name); // Save full size image with max width/height resampleimage("175", $absolute_path.$file_name, $absolute_path.$file_name, 0); } } $error++; } $ESQL = mysql_query("SELECT `NewsID`,`City`,`Cons`,`NewsTitle` FROM `tblNews` WHERE `NewsTitle`='$NewsTitle'") or die(mysql_error()); $ER = mysql_fetch_array($ESQL); if ($ER["Cons"] !="1" && $ER["City"] !="1") { header("Location: /admin/news/edit_news.php?ID=".$ER["NewsID"]."&action=error1"); } else{ //header("Location: /admin/news/default.php"); echo $absolute_path; echo $thumb_path; } break; default: include($_SERVER['DOCUMENT_ROOT'] . '/includes/staff_header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $size_limit = "yes"; //do you want a size limit yes or no. $limit_size = "4000000"; //How big do you want size limit to be in bytes $limit_ext = "yes"; //do you want to limit the extensions of files uploaded $ext_count = "4"; //total number of extensions in array below $extensions = array(".jpg", ".jpeg", ".png", ".gif"); //List extensions you want files uploaded to be $pichead = "<ul style=\"color:#FF0000; font-size:10px;\"><li style=\"display:inline; padding-right:10px;\">File extension must be $extens |</li>"; $pichead .="<li style=\"display:inline; padding-right:10px;\">Maximum file size is $limit_size ($mb_size MB) |</li> <li style=\"display:inline; padding-right:10px;\">No spaces in the filename</li></ul>"; echo"<h2>Add News</h2>\n"; include($_SERVER['DOCUMENT_ROOT'] . '/admin/news/navigation.php'); ?> <form action="<? echo $_SERVER['PHP_SELF'];?>?action=add" method="post" enctype="multipart/form-data"> <table width="100%"> <tr><td colspan="2">News Images:</td></tr> <tr><td><table> <?php $files = 3; // Change this line for the number of uploads you want to allow for($i=1; $i<=$files; $i++){ echo "<tr><td>Image $i :</td><td><input type=\"file\" name=\"pictures[]\" size=\"50\" /></td></tr>\n"; } ?> <tr> <td>Attachment : </td> <td><input name="NewsAttachment[]" type="file" id="ufile[]" size="50" /></td> </tr> </table></td> <td><? echo $pichead; ?></td></tr> <tr> <td colspan="2"><hr /></td> </tr> <tr> <td colspan="2" style="width:80%;"><span style="width:20%;">News Title: </span></td> </tr> <tr> <td colspan="2" style="width:80%;"> <input type="text" size="45" name="NewsTitle" /></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">News Brief :</td> </tr> <tr> <td colspan="2"><textarea name="NewsShort" id="NewsShort" style="width:550px; height:175px;"></textarea></td> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2" >News Full :</td> </tr> <tr> <td colspan="2"><textarea name="NewsFull" id="NewsFull" style="width:550px; height:175px;"></textarea></td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td colspan="2">Submit News to Websites</td> </tr> <tr> <td colspan="2"> <table width="50%" border="0" cellpadding="0"> <tr> <td><input name="chkCons" type="checkbox" value="1" /></td> <td>Construction Works</td> <td><input name="chkCity" type="checkbox" value="1" /></td> <td>City Works</td> </tr> </table> </td> </tr> <tr> <td colspan="2" style="height:32px;"><div style=" text-align:center"> <input type="submit" name=submit value="Add News" /> <input type="button" name="Reset" value="Cancel" alt="Cancel" onclick="document.location='/admin/news/default.php'" /> </div></td> </tr> </table> </form> <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/staff_footer.php'); break; } ?>
  4. hi all, my database stores dates in the following format YYYY-MM-DD eg 2009-03-09 how can i convert what is displayed on my webpages so it says 9th of march 09 or just 09-03-2009 Thanks
  5. figured it out, was becuase i was doing a mysql_escape_string on it and the doing a str_replace on it i just did the str_replace on the posted data and i works
  6. well the text that shows the \r\n is grabbed from a form so i used <td>".str_replace("\r\n","<br />",$Desc)."</td> this didnt work
  7. Hi, Im sending email in html format but instead of a line break im getting \r\n here are my mail headers $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";// More headers ive tried doing a str_replace but it didnt work. Any ideas? Thankyou
  8. hi below is my code qwhich will hopefully explain the problem a little clearer if you look at the none set error statments, im checking for words in the field then if certain words are met do something, now if there not met its set to do nothing, but i want it to be set to the last else in the statement that its within, without having to repeat this bit if ($error["City"] =="1") {.... at the end of everyone of those anyone understand? if ($error["Cons"] !="1" && $error["City"] !="1") { header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error1"); } elseif (empty($error["Ref"])) { header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error2"); } elseif ($error["City"] =="1") { if ($error["CityCat"] =="None Set") { header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error3"); } } elseif ($error["Cons"] =="1") { if ($error["ConsCat"] =="None Set") { header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error4"); } } else { if ($error["City"] =="1") { header("Location: /admin/vacancies/edit_vac_list.php?CAT=$CityCat"); } elseif ($error["Cons"] =="1") { header("Location: /admin/vacancies/edit_vac_list.php?CAT=$ConsCat"); } }
  9. hey that works thanks so what do the braces do in sql? and when would i use them? Cheers
  10. hi below is my sql $VACSQL = mysql_query("SELECT * FROM tblVacancies WHERE Archive='0' AND CityCat LIKE '$CAT' OR ConsCat LIKE '$CAT' ORDER BY DateAdded DESC") or die(mysql_error()); what im trynig to do is get all records that have Archive 0 and either City Cat or ConsCat is like the variable $Cat at the moment if i click a CityCat link and the above sql is run on the next page it works if i click a Cons Cat Link the sql above shows all the correct ConsCat but it shows all Archive but the archive says only if 0, i dont understand why can anyone help me out? Cheers
  11. hi all below is code which gave me a syntax error but i cant see where the error is i got Parse error: syntax error, unexpected T_IF in C:\admin\vacancies\edit_vacancy.php on line 50 which is somewhere in the below snippet can anyone help me out? Cheers $ESQL = mysql_query("SELECT `ID`,`City`,`Cons`,`Ref` FROM `tblVacancies` WHERE `Ref`='$Ref'") or die(mysql_error()); $error = mysql_fetch_array(ESQL); if ($error["Cons"] !="1" || $error["Cons"] !="1") { header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error1"); } elseif (empty($error["Ref"])) { header("Location: /admin/vacancies/edit_vacancy.php?ID=".$error["ID"]."&action=error2"); } else { header("Location: /admin/vacancies/edit_vac_list.php?CAT=$Cat"); }
  12. Hi all, as the title heopfully explains i have to checkboxes on my form if neither of them are checked id like to display an error message and dont submit until one of them has a tick in it can anyone help me out? Cheers
  13. well this line $clear=mysql_query($delete) or trigger_error("Query: $delete\n<br />MySQL Error: " . mysql_error()); you have declared the $delete query inside a variblae $clear and you havent used that variable anywhere i can see in the page try removing the $clear= part and see if it works
  14. hi below is my code <?php if ($_SESSION["UserLevel"] != "Editor" || $_SESSION["UserLevel"] != "Admin"){ header("Location: /admin/admin.php?action=editorlevel"); } ?> my UserLevel is Admin and it keeps redirecting me it shouldnt be redirecting me, can anyone tell me if therse an error in the statement? Cheers
  15. hi below is my code for adding records to an archive so the user clicks the recorsd to archive, they get archived but they dont get redirected, it just stays on the current page?action=archive the same with delete too, anyone know why? Thanks <?php switch(@$_GET["action"]) { Case "delete": include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $VacID = $_GET["ID"]; mysql_query("DELETE FROM tblVac WHERE VacID='$VacID'") or die(mysql_error()); header("/admin/vacancies/edit_vac_list.asp?CAT=$CAT"); break; Case "archive"; include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); if(is_array($_POST['checkbox'])){ foreach($_POST['checkbox'] as $VacID){ mysql_query("UPDATE tblVac SET VacArchive='1' WHERE VacID='$VacID'") or die(mysql_error()); } } header("/admin/vacancies/edit_vac_list.asp?CAT=".$_SESSION["CAT"].""); break; default: session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $_SESSION["CAT"] = $_GET["CAT"]; $CAT = $_SESSION["CAT"]; echo '<div id="subheader"> <div class="padding"> <table width="100%" border="0"> <tr> <td><h2 class="titles">Vacancies</h2> Please feel free to browse and if you have any questions please use our contact form.</td> <td style="text-align:right;"><img src="/images/layout/puddle.png" alt="logo splash" /></td> </tr> </table> </div> </div> <div id="main"> <div class="right_side">'."\n"; echo '<p>Currently viewing '.$CAT.' Vacancies</p>'."\n"; echo '<form>'."\n"; echo '<select name="url">'."\n"; $SEL = mysql_query("SELECT VacCat FROM tblVac GROUP BY VacCat") or die(mysql_error()); echo'<option value="None">Change category here ---></option>'."\n"; while ($opt = mysql_fetch_array($SEL)) { echo '<option value="'.$_SERVER['PHP_SELF'].'?CAT='.$opt['VacCat'].'">'.$opt['VacCat'].'</option>'."\n"; } echo '</select>'."\n"; echo '<input type="button" value="Go" onClick="JumpToIt(this.form)" />'."\n"; echo '</form>'."\n"; $VACSQL = mysql_query("SELECT * FROM tblVac WHERE VacCat='$CAT' AND VacArchive='0' ORDER BY VacDateAdded DESC") or die(mysql_error()); if (mysql_num_rows($VACSQL) <1) { echo '<p>There currently no vacancies for this category</p>'."\n"; echo '<p><a href="/admin/vacancies/default.php">Back to category select</a></p>'."\n"; } else { echo '<form id="archive" method="post" action="'.$_SERVER['PHP_SELF'].'?action=archive">'."\n"; echo '<table width="100%"><tr style="font-weight:bold;"><td>Vac Title</td><td class="center">Date Added</td><td class="center">Date Modified</td><td class="center">Edit</td><td class="center">Archive</td><td class="center">Delete</td></tr>'."\n"; while ($row = mysql_fetch_array($VACSQL)) { echo "<tr><td>"; echo $row["VacTitle"]."</td><td style=\"text-align:center;\">"."\n"; mydate($row["VacDateAdded"]); echo '</td><td style="text-align:center;">'."\n"; if (empty($row["VacDateModified"])) { echo " "; } else { if ($row["VacDateModified"] != "0000-00-00") { mydate($row["VacDateModified"]); } } echo '</td><td class="center"><a href="/admin/vacancies/edit_vacancy.php?ID='.$row["VacID"].' ">Edit</a></td>'."\n"; echo '<td class="center"><input class="noborder" name="checkbox[]" type="checkbox" value="'.$row['VacID'].'"/></td>'."\n"; echo '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=delete&ID='.$row["VacID"].' ">Delete</a></td>'."\n"; echo "</tr>"."\n"; } echo ' <tr style="height:50px;"><td colspan="6" class="right"><input type="submit" value="Add Records to Archive" /></td></tr> '."\n"; echo "</table></form>"."\n"; } include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); break; } ?>
  16. i do here dont i? $VacAdded = date("Y-d-m");
  17. hi below is my add vacancy form heres the debug: yet checking the mysql database i get this (from phpmyadmin) VacID VacCat VacTitle VacRef VacHrs VacLocation VacWage VacDetails VacTop VacDateAdded VacDateModified VacArchive 397 Administration / Clerical test test test test test test<br /> 0 0000-00-00 NULL 0 field type is date, anyone know why? Thanks <?php switch (@$_GET["action"]) { case "add"; include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); $VacCat = $_POST["txtCat"]; $VacTitle = mysql_escape_string($_POST["txtTitle"]); $VacRef = mysql_escape_string($_POST["txtRef"]); if (($_POST["chkTop"]) == "1") { $VacTop = "1"; } else { $VacTop = "0"; } $VacHrs = mysql_escape_string($_POST["txtHrs"]); $VacWage = mysql_escape_string($_POST["txtWage"]); $VacLocation = mysql_escape_string($_POST["txtLocation"]); $VacDetails = mysql_escape_string($_POST["txtDetails"]); $VacAdded = date("Y-d-m"); mysql_query("INSERT INTO tblVac (VacCat,VacTitle,VacRef,VacTop,VacHrs,VacWage,VacLocation,VacDetails,VacDateAdded,VacArchive) VALUES ('$VacCat', '$VacTitle', '$VacRef', '$VacTop', '$VacHrs', '$VacWage', '$VacLocation', '$VacDetails', '$VacAdded','0')") or die (mysql_error()); header("Location: /admin/vacancies/edit_vac_list.php?CAT=$VacCat"); break; default: session_start(); include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/access.inc'); echo '<div id="subheader"> <div class="padding"> <table width="100%" border="0"> <tr> <td><h2 class="titles">Vacancies</h2> Please feel free to browse and if you have any questions please use our contact form.</td> <td style="text-align:right;"><img src="/images/layout/puddle.png" alt="logo splash" /></td> </tr> </table> </div> </div> <div id="main"> <div class="right_side">'."\n"; ?> <script type="text/javascript"> bkLib.onDomLoaded(function() { new nicEditor({xhtml:true}).panelInstance('txtDetails'); }); </script> <h3 class="titles">Add Vacancy</h3> <form id="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=add"> <table width="100%"> <tr> <td>Category: <br /></td> <td> <select name="txtCat" > <option>Administration / Clerical</option> <option>Care / Health</option> <option>Catering</option> <option>Construction</option> <option>Hospitality</option> <option>Professional / Management</option> <option>Retail</option> <option>Security / Ancillary</option> <option>Voluntary</option> </select></td> </tr> <tr> <td>Title: <br /></td> <td> <input type="text" size="50" name="txtTitle" /></td> </tr> <tr> <td>Ref No:</td> <td><input type="text" size="20" name="txtRef" /></td> </tr> <tr> <td>Top:</td> <td><input name="chkTop" type="checkbox" value="1" class="noborder" /></td> </tr> <tr> <td>Hours:</td> <td><input type="text" size="20" name="txtHrs" /></td> </tr> <tr> <td>Wage:</td> <td><input type="text" size="20" name="txtWage" /></td> </tr> <tr> <td>Location:</td> <td><input type="text" size="40" name="txtLocation" /></td> </tr> <tr> <td colspan="2" class="top"> Details: </td> </tr> <tr> <td colspan="2"><textarea name="txtDetails" style="width:550px; height:175px;"></textarea></td> </tr> <tr> <td class="center" colspan="2"> <input type="submit" name="Submit" value="Submit" /> <input type="reset" name="reset" value="reset" /></td> </tr> </table> </form> <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); break; } ?>
  18. this will work <input type="checkbox" name="chkSubscribeToNewsletter" value="1" <?php if ($_POST["chkSubscribeToNewsletter"] == 1) {echo 'checked="checked"'."\n";} />
  19. what about in the files you gave me a link to, i want to use that counter instead is it the ip.db count.db ? THanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.