Jump to content

mdmartiny

Members
  • Posts

    188
  • Joined

  • Last visited

Everything posted by mdmartiny

  1. I keep getting the mysql resource id #4 on a query that I am running and I have tried everything that I have read to fix it and nothing is working. I tried using the mysql_fetch_array, mysql_fetch_accoc, and the mysql_fetch_row functions I would appreciate any help that can be given to me. Here is my code as it stands now <?php include('includes/config.php'); $last = $_GET['l_name']; $first = $_GET['f_name']; $sql = 'SELECT * FROM `ttmautos` WHERE `l_name` LIKE \'$last\' AND `f_name` LIKE \'$first\''; $autographs = mysql_query($sql, $connection)or die(mysql_error()); $row = mysql_fetch_array($autographs); echo $sql; echo $autographs; $l_name = $row['l_name']; $f_name = $row['f_name']; $sent = $row['date_sent']; $return = $row['date_return']; $address = $row['address']; $isent = $row['item_sent']; $ireturn = $row['item_return']; $project = $row['project']; $team = $row['team']; $address = stripslashes($address); ?>
  2. It looks like you are only trying to upload an image file. DO you get an error message when you try and open the PDF?
  3. I have a php script that I wrote that enters information into a database and uploads images to the server. What I need to do now is delete the files from the server when the corresponding database records are deleted. How would I go about doing that?
  4. Using the code that you have given me I made some changes to the original code that I wrote. I put comments in to explain some of the things that I am trying to do <?php if (!$_POST['submit']){ header("Location: testmail.php"); //redirect back to form page if they came here by mistake exit; } else { $name = $_POST['name']; $message = $_POST['message']; if (strlen($name) >20 || strlen($message) >300 ){ if ($name == "" || $message == ""){ $msg = " please fill in all required feilds"; //redirects back to form page with error message header("Location: testmail.php?msg=$msg"); exit; } else { ini_set("SMTP", "smtp.greatlakes.net"); $to = "mikedmartiny@gmail.com"; $subject = "Classified Ad Submission"; $headers = "From: autostylersrv@greatlakes.net"; $headers = "MIME-Version: 1.0rn"; $headers = "Content-type: text/html"; $headers = "charset=iso-8859-1rn"; $message = "<html><body>This is a email sent from $name<br /><br />$message</body></html>"; $outcome = mail($to,$subject,$message,$headers); if ($outcome){ $msg = "mail has been sent"; }else{ $msg = "there was an error"; } } } else { $msg = "You have exceded the max length"; //redirects to form page with message header("Location: testmail.php?msg=$msg"); exit; } } echo "$msg"; ?> All I am getting is q blank white page with nothing on it
  5. I added the code and all I still get is the blank page
  6. Hello Everyone, I do not know if I am not doing something right or if I am completely wrong. I am trying to get an error or success message depending on the out come . This is the code that I have written so far <?php if (!$_POST['submit']){ $msg = "you must enter a name and message"; header("Location: {$_SERVER['URL']}testmail.php?msg=$msg"); exit; } else { $name = $_POST['name']; $message = $_POST['message']; if (strlen($name) <= 20 && $message <= 300){ if (($name == "") || ($message == "")){ $msg = " please fill in all required feilds"; header("Location: {$_SERVER['URL']}testmail.php?msg=$msg"); exit; } else { ini_set("SMTP", "smtp.greatlakes.net"); $to = "mikedmartiny@gmail.com"; $subject = "Classified Ad Submission"; $headers = "From: autostylersrv@greatlakes.net"; $headers = "MIME-Version: 1.0rn"; $headers = "Content-type: text/html"; $headers = "charset=iso-8859-1rn"; $message = "<html><body>This is a email sent from $name<br /><br />$message</body></html>"; function mail($to, $subject, $message, $headers) { $msg = "mail has been sent"; } else { $msg = "there was a error"; } } } else { $msg = "You have exceded the max lentgh"; header("Location: {$_SERVER['URL']}testmail.php?msg=$msg"); exit; } } echo "$msg"; ?>
  7. I have tried changing the php.ini file but all I get is access denied
  8. This is the code that I am using to make a page that is kind of like an administration area for a CMS system. When the page is loading all I get is a blank page. When I remove all of the back code before the HTML code is sent. The page shows up fine. I have looked over and over the code trying to see if I missed a colon or something and I see nothing. I hope that this explains everything well enough and I would appreciate any help. <?php $today = date("l, F j, Y"); $host =''; $username = ''; $dbname =''; $dbpassword = ''; $table = ''; $table2 = ''; $connection = mysql_connect($host, $username, $dbpassword) or die (mysql_error()); $db = mysql_select_db ($dbname, $connection) or die (mysql_error()); $sql = "SELECT * FROM $table WHERE username = '$_POST[username]' AND password = password('$_POST[password]')"; $result = mysql_query($sql, $connection) or die(mysql_error()); $num = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $f_name = $row['f_name']; $l_name = $row['l_name']; $username = $row['username']; } if ($num != 0) { $_SESSION[auth] = "yes"; $msg = "Welcome $f_name "; } //else { //header("Location: index.php"); //exit; //} $get_count = "SELECT count(id) FROM $table2"; $get_count_res = mysql_query($get_count, $connection) or die (mysql_error()); $count = mysql_result($get_count_res, 0, "count(id)") or die (mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" /> <link rel="stylesheet" type="text/css" href="css/admin.css" media="screen" /> <title>Administration Area</title> </head> <body> <div id="wrapper"> <?php include('includes/header.php'); ?> <div id="content"> <div class="message"><?php echo "$msg"; ?> <a href="logout.php">Logout</a><span style="float:right; "><?php echo "$today"; ?></span></div> <div class="admin"> <span class="top">Administration</span> <ul> <li><A href="show_add.php">Add a Ad</A></li> <li><a href="pick_modify.php">Modify a Add</a></li> <li>Delete Ad</li> <li><a href="user/index.php">Add a User</a></li> <li><a href="user/pick_user.php">Delete a User</a></li> <li><a href="#">View Database Records</a></li> <li><a href="php_info.php">PHP info</a></li> <li><a href="make_backup.php">Backup Database</a> </li> <li><a href="https://p3nlmysqladm001.secureserver.net/nl50/529/index.php?lang=en-utf-8&token=db052d2ddafce3f6ba841cfe0a6c224a">View Database</a> </li> </ul> </div> <div class="misc"><span class="top">miscellaneous</span>Classified Ads online <?php echo "$count"; ?></div> </div> <!--End #content--> <?php include('includes/footer.php'); ?> </div> <!-- End #wrapper --> </body> </html>
  9. I have been trying to figure out what this error means and I fond nothing Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/m/i/k/mikedmartiny/html/CMS/do_modify.php on line 29 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/content/m/i/k/mikedmartiny/html/CMS/do_modify.php on line 29 Can someone help me understand it?
  10. Hello Everyone, I am trying to use the lightbox script to open a small group of images for a CMS that I am writing. I have been trying to get this to work for the better part of the day without success. I followed what the tutorial at the website told me to do and all i get is a JavaScript error. No images open anywhere. The page that I am trying to get it to work on is. Hopefully this will show you what is not working http://www.michaeldmartiny.com/CMS/classified/webpage.php?id=146 The errors that I am getting 'Builder' is undefined lightbox.js, line 132 character 3 'Builder' is undefined lightbox.js, line 134 character 9 'null' is null or not an object lightbox.js, line 165 character 3 'null' is null or not an object lightbox.js, line 166 character 3 'null' is null or not an object lightbox.js, line 167 character 3 'null' is null or not an object lightbox.js, line 168 character 3 'null' is null or not an object lightbox.js, line 169 character 3 'null' is null or not an object lightbox.js, line 170 character 3 'null' is null or not an object lightbox.js, line 171 character 3 This is the lightbox.js code. I know nothing of JavaScript and I would appreciate any help that I can be given // ----------------------------------------------------------------------------------- // // Lightbox v2.04 // by Lokesh Dhakar - http://www.lokeshdhakar.com // Last Modification: 2/9/08 // // For more information, visit: // http://lokeshdhakar.com/projects/lightbox2/ // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // - Free for use in both personal and commercial projects // - Attribution requires leaving author name, author link, and the license info intact. // // Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. // Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. // // ----------------------------------------------------------------------------------- /* Table of Contents ----------------- Configuration Lightbox Class Declaration - initialize() - updateImageList() - start() - changeImage() - resizeImageContainer() - showImage() - updateDetails() - updateNav() - enableKeyboardNav() - disableKeyboardNav() - keyboardAction() - preloadNeighborImages() - end() Function Calls - document.observe() */ // ----------------------------------------------------------------------------------- // // Configurationl // LightboxOptions = Object.extend({ fileLoadingImage: 'images/loading.gif', fileBottomNavCloseImage: 'images/closelabel.gif', overlayOpacity: 0.8, // controls transparency of shadow overlay animate: true, // toggles resizing animations resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable // When grouping images this is used to write: Image # of #. // Change it for non-english localization labelImage: "Image", labelOf: "of" }, window.LightboxOptions || {}); // ----------------------------------------------------------------------------------- var Lightbox = Class.create(); Lightbox.prototype = { imageArray: [], activeImage: undefined, // initialize() // Constructor runs on completion of the DOM loading. Calls updateImageList and then // the function inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function() { this.updateImageList(); this.keyboardAction = this.keyboardAction.bindAsEventListener(this); if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. // If animations are turned off, it will be hidden as to prevent a flicker of a // white 250 by 250 box. var size = (LightboxOptions.animate ? 250 : 1) + 'px'; // Code inserts html at the bottom of the page that looks similar to this: // // <div id="overlay"></div> // <div id="lightbox"> // <div id="outerImageContainer"> // <div id="imageContainer"> // <img id="lightboxImage"> // <div style="" id="hoverNav"> // <a href="#" id="prevLink"></a> // <a href="#" id="nextLink"></a> // </div> // <div id="loading"> // <a href="#" id="loadingLink"> // <img src="../../../lightbox/js/images/loading.gif"> // </a> // </div> // </div> // </div> // <div id="imageDataContainer"> // <div id="imageData"> // <div id="imageDetails"> // <span id="caption"></span> // <span id="numberDisplay"></span> // </div> // <div id="bottomNav"> // <a href="#" id="bottomNavClose"> // <img src="../../../lightbox/js/images/close.gif"> // </a> // </div> // </div> // </div> // </div> var objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ Builder.node('div',{id:'outerImageContainer'}, Builder.node('div',{id:'imageContainer'}, [ Builder.node('img',{id:'lightboxImage'}), Builder.node('div',{id:'hoverNav'}, [ Builder.node('a',{id:'prevLink', href: '#' }), Builder.node('a',{id:'nextLink', href: '#' }) ]), Builder.node('div',{id:'loading'}, Builder.node('a',{id:'loadingLink', href: '#' }, Builder.node('img', {src: LightboxOptions.fileLoadingImage}) ) ) ]) ), Builder.node('div', {id:'imageDataContainer'}, Builder.node('div',{id:'imageData'}, [ Builder.node('div',{id:'imageDetails'}, [ Builder.node('span',{id:'caption'}), Builder.node('span',{id:'numberDisplay'}) ]), Builder.node('div',{id:'bottomNav'}, Builder.node('a',{id:'bottomNavClose', href: '#' }, Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) ) ) ]) ) ])); $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); $('outerImageContainer').setStyle({ width: size, height: size }); $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); }).defer(); }, // // updateImageList() // Loops through anchor tags looking for 'lightbox' references and applies onclick // events to appropriate links. You can rerun after dynamically adding images w/ajax. // updateImageList: function() { this.updateImageList = Prototype.emptyFunction; document.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target) { event.stop(); this.start(target); } }).bind(this)); }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); // stretch overlay to fill page and fade in var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); this.imageArray = []; var imageNum = 0; if ((imageLink.rel == 'lightbox')){ // if image is NOT part of a set, add single image to imageArray this.imageArray.push([imageLink.href, imageLink.title]); } else { // if image is part of a set.. this.imageArray = $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). collect(function(anchor){ return [anchor.href, anchor.title]; }). uniq(); while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } } // calculate top and left offset for the lightbox var arrayPageScroll = document.viewport.getScrollOffsets(); var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); var lightboxLeft = arrayPageScroll[0]; this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); this.changeImage(imageNum); }, // // changeImage() // Hide most elements and preload image in preparation for resizing image container. // changeImage: function(imageNum) { this.activeImage = imageNum; // update global var // hide elements during transition if (LightboxOptions.animate) this.loading.show(); this.lightboxImage.hide(); this.hoverNav.hide(); this.prevLink.hide(); this.nextLink.hide(); // HACK: Opera9 does not currently support scriptaculous opacity and appear fx this.imageDataContainer.setStyle({opacity: .0001}); this.numberDisplay.hide(); var imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload = (function(){ this.lightboxImage.src = this.imageArray[this.activeImage][0]; this.resizeImageContainer(imgPreloader.width, imgPreloader.height); }).bind(this); imgPreloader.src = this.imageArray[this.activeImage][0]; }, // // resizeImageContainer() // resizeImageContainer: function(imgWidth, imgHeight) { // get current width and height var widthCurrent = this.outerImageContainer.getWidth(); var heightCurrent = this.outerImageContainer.getHeight(); // get new width and height var widthNew = (imgWidth + LightboxOptions.borderSize * 2); var heightNew = (imgHeight + LightboxOptions.borderSize * 2); // scalars based on change from old to new var xScale = (widthNew / widthCurrent) * 100; var yScale = (heightNew / heightCurrent) * 100; // calculate size difference between new and old image, and resize if necessary var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew; if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); // if new and old image are same size and no scaling transition is necessary, // do a quick pause to prevent image flicker. var timeout = 0; if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; } (function(){ this.prevLink.setStyle({ height: imgHeight + 'px' }); this.nextLink.setStyle({ height: imgHeight + 'px' }); this.imageDataContainer.setStyle({ width: widthNew + 'px' }); this.showImage(); }).bind(this).delay(timeout / 1000); }, // // showImage() // Display image and begin preloading neighbors. // showImage: function(){ this.loading.hide(); new Effect.Appear(this.lightboxImage, { duration: this.resizeDuration, queue: 'end', afterFinish: (function(){ this.updateDetails(); }).bind(this) }); this.preloadNeighborImages(); }, // // updateDetails() // Display caption, image number, and bottom nav. // updateDetails: function() { // if caption is not null if (this.imageArray[this.activeImage][1] != ""){ this.caption.update(this.imageArray[this.activeImage][1]).show(); } // if image is part of set display 'Image x of x' if (this.imageArray.length > 1){ this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); } new Effect.Parallel( [ new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) ], { duration: this.resizeDuration, afterFinish: (function() { // update overlay size and update nav var arrayPageSize = this.getPageSize(); this.overlay.setStyle({ height: arrayPageSize[1] + 'px' }); this.updateNav(); }).bind(this) } ); }, // // updateNav() // Display appropriate previous and next hover navigation. // updateNav: function() { this.hoverNav.show(); // if not first image in set, display prev image button if (this.activeImage > 0) this.prevLink.show(); // if not last image in set, display next image button if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); this.enableKeyboardNav(); }, // // enableKeyboardNav() // enableKeyboardNav: function() { document.observe('keydown', this.keyboardAction); }, // // disableKeyboardNav() // disableKeyboardNav: function() { document.stopObserving('keydown', this.keyboardAction); }, // // keyboardAction() // keyboardAction: function(event) { var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE) { // mozilla escapeKey = event.DOM_VK_ESCAPE; } else { // ie escapeKey = 27; } var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox this.end(); } else if ((key == 'p') || (keycode == 37)){ // display previous image if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1); } } else if ((key == 'n') || (keycode == 39)){ // display next image if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1); } } }, // // preloadNeighborImages() // Preload previous and next images. // preloadNeighborImages: function(){ var preloadNextImage, preloadPrevImage; if (this.imageArray.length > this.activeImage + 1){ preloadNextImage = new Image(); preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; } if (this.activeImage > 0){ preloadPrevImage = new Image(); preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; } }, // // end() // end: function() { this.disableKeyboardNav(); this.lightbox.hide(); new Effect.Fade(this.overlay, { duration: this.overlayDuration }); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); }, // // getPageSize() // getPageSize: function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth,pageHeight]; } } document.observe('dom:loaded', function () { new Lightbox(); }); mikedmartiny@gmail.com
  11. I am trying to redirect /show.php?title=Engineering\%20Club&category=Clubs\%20and\%20Organizations to /show.php?title=Alternative\%20Energy\%20and\%20Engineering\%20Club&category=Clubs\%20and\%20Organizations How would I do that. The way that I know is not working
  12. I tried something like that and it did not work. After clicking on the link you are logged out
  13. I was wondering if there is away to set a logout message when you are using sessions this is my code <?php session_start(); if($_SESSION[auth] = "yes") { session_unset(); session_destroy(); header( "Location: index.php" ); exit(); } else { if ($_SESSION[auth] != "yes") { header( "Location: index.php" ); $_SESSION['error'] = "please login!"; exit(); } } ?>
  14. This is a script that someone wrote that used to work were I now work.... I have been trying to figure out how to send it HTML. It currently is sending it as text. Everything that I have tried does not work. I would appreciate any help that can be given to me <?php require_once('../Connections/Local.php'); if ($_SERVER['REQUEST_METHOD']=="POST"){ // we'll begin by assigning the To address and message subject #$to="sholburt@sc4.edu"; #$to="mkewalt@sc4.edu"; $to="patterns@sc4.edu"; $subject="Patterns Writing Entry 2010-11"; // get the sender's name and email address // we'll just plug them a variable to be used later $from = stripslashes($_POST['fromname'])."<".stripslashes($_POST['fromemail']).">"; $title=$_POST['title']; $category=$_POST['category']; $honourific=$_POST['honourific']; $student_name=$_POST['fromname']; $student_number=$_POST['student_number']; $mailing=$_POST['mailing']; $home_address=$_POST['home_address']; $telephone=$_POST['telephone']; $email=$_POST['fromemail']; // generate a random string to be used as the boundary marker $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x"; // now we'll build the message headers $headers = "From: $from\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed;\r\n" . " boundary=\"{$mime_boundary}\""; // here, we'll start the message body. // this is the text that will be displayed // in the e-mail $message="Title: " . $title . "\r\n"; $message.="\r\n"; $message .="Category: " . $category . "\r\n"; $message.="\r\n"; $message .="Name: " . $honourific . " " . $student_name . "\r\n"; $message.="\r\n"; $message .="Student number: " . $student_number . "\r\n"; $message.="\r\n"; $message .="Mailing address: " . $mailing . "\r\n"; $message.="\r\n"; $message .="Home address: " . $home_address . "\r\n"; $message.="\r\n"; $message .="Telephone: " . $telephone . "\r\n"; $message.="\r\n"; $message .="e-mail: " . $email; // next, we'll build the invisible portion of the message body // note that we insert two dashes in front of the MIME boundary // when we use it $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; // now we'll process our uploaded files foreach($_FILES as $userfile){ // store the file information to variables for easier access $tmp_name = $userfile['tmp_name']; $type = $userfile['type']; $name = $userfile['name']; $size = $userfile['size']; // if the upload succeded, the file will exist if (file_exists($tmp_name)){ // check to make sure that it is an uploaded file and not a system file if(is_uploaded_file($tmp_name)){ //Enter all the date into the database for Shawn $title=addslashes($title); $student_name=addslashes($student_name); $query = "INSERT INTO patterns (title, category, honourific, student_name, student_number, mailing, home_address, telephone, email, file_name) VALUES('$title', '$category', '$honourific', '$student_name', '$student_number', '$mailing', '$home_address', '$telephone', '$email', '$name')"; $rs = mysql_query($query) or die(mysql_error()); mysql_close(); // open the file for a binary read $file = fopen($tmp_name,'rb'); // read the file content into a variable $data = fread($file,filesize($tmp_name)); // close the file fclose($file); // now we encode it and split it into acceptable length lines $data = chunk_split(base64_encode($data)); } // now we'll insert a boundary to indicate we're starting the attachment // we have to specify the content type, file name, and disposition as // an attachment, then add the file content. // NOTE: we don't set another boundary to indicate that the end of the // file has been reached here. we only want one boundary between each file // we'll add the final one after the loop finishes. $message .= "--{$mime_boundary}\n" . "Content-Type: {$type};\n" . " name=\"{$name}\"\n" . "Content-Disposition: attachment;\n" . " filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } } // here's our closing mime boundary that indicates the last of the message $message.="--{$mime_boundary}--\n"; // now we just send the message if (@mail($to, $subject, $message, $headers)) echo "<div id='success' align='center'>Your entry has been successfully submitted. <br /><br /><a href='http://www.sc4.edu'>Click here</a> to return to SC4 home page.<br /> <a href='http://www.sc4.edu/patterns/PatternsEntryForm.php'>Click here</a> to submit another entry. </div>"; else echo "Failed to send"; } else { ?>
  15. Hello Everyone I have written a simple mail function to be emailed to a certain person on submission. On submission they would also like to have attachments sent to them. I got the email being sent but I can;t get the attachments to work. I have read several different examples and tutorials and none of them work. This is my code so far without any code for file attachment <?php $project_name = $_POST['project_name']; $needed = $_POST['date_needed']; $submitted = $_POST['date_submitted']; $department = $_POST['department']; $contact = $_POST['contact_person']; $extension = $_POST['extension']; $project_type = $_POST['project_type']; $published = $_POST['date_last_published']; $description = $_POST['description']; $color = $_POST['color']; $pdf = $_POST['pdf_needed']; $web = $_POST['web_needed']; $quanity = $_POST['quanity']; $email = "mdmartiny@sc4.edu"; $subject = "SC4 Graphics Design Service Request Form"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $message = "<html><body> <table width=\"100%\" border=\"0\" cellspacing=\"5px\" > <tr><td></td> <td>Project name: $project_name</td> <td></td> <td>Date needed by: $needed</td> </tr> <tr> <tr> <td></td> <td colspan=\"3\" align=\"left\" valign=\"top\"><strong><font size=\"+1\">Submitted to graphic designer</font></strong></td></tr> <tr><td height=\"25\"></td><td>Date $submitted</td><td>Department $department</td><td></td></tr> <tr><td height=\"25\"></td><td>Contact Person $contact</td><td>Extension $extension</td><td></tr> <tr><td height=\"25\"></td><td>Type of project $project_type</td><td colspan=\"2\">Approximate date of last publication $published</td></tr> <tr><td height=\"25\"></td><td colspan=\"3\">Project description/special instructions</td> <tr><td></td>><td colspan=\"3\">$description</td></tr> <tr><td height=\"25\"></td><td>Color $color</td><td>PDF needed $pdf</td><td>Website update needed $web</td></tr> <tr><td ></td><td>Estimated print quanity $quanity</td><td></td><td></td></tr> <tr> <td colspan=\"4\" align=\"left\" valign=\"top\"><hr height=\"5\"/> <strong><font size=\"+1\">Graphics office use only</font></strong></td> </tr> <tr> <td height=\"25\" width=\"2%\"> </td> <td width=\"34%\">Print Shop Color copier</td> <td colspan=\"2\">Print Vendor_______________________________________</td> </tr> <tr> <td height=\"25\"> </td> <td><strong><font size=\"+1\">Project tracking</font></strong></td> <td> </td> <td> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Received by graphic designer_______________________ Date _______</td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\"> <table width=\"100%\" height=\"35\"> <tr> <td>Approved by executive director__________ Date_________</td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td><tr> </table> </td> </tr> <tr> <td height=\"25\"> </td> <td colspan=\"3\">Completed and spell checked by graphic designer___________________________ Date__________</td> </tr> <tr> <td> </td> <td align=\"center\" colspan=\"3\"> <table cellpadding=\"10px\" cellspacing=\"0\" border=\"1\" width=\"100%\"> <tr bgcolor=\"#CCCCCC\"> <td> <table> <tr> <td> Proofread by marketing coordinator __________ Date__________</td> </tr> <tr> <td> Proofread by secretary __________ Date__________ </td> </tr> </table> </td> <td> <input type=\"checkbox\"> Revisions needed <br> <input type=\"checkbox\"> Revisions made ____ Date_____ </td> </tr> </table></td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td>Proofread by executive director______ Date______ </td><td><input type=\"checkbox\"> Revisions needed<br /> <input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <tr> <td></td> <td colspan=\"3\"> <table width=\"100%\" height=\"75\"> <tr> <td> Approval by requesting department __________ Date_________ <br /> <strong><font size=\"-1\">(Include all paperwork when returning)</font></strong></td><td><input type=\"checkbox\"> Revisions needed<br /><input type=\"checkbox\"> Revisions made ______ Date_______</td> </tr> </table> </td> </tr> <td></td height=\"25\"> <td colspan=\"3\">Final approval by executive director _________________________________________ Date_________ </td> </tr> <tr> <td height=\"75\"></td> <td><input type=\"checkbox\"> Printed ____ Date _____</td> <td colspan=\"2\"><input type=\"checkbox\"> PDF created _____ Date _____<br /> <input type=\"checkbox\"> Website updated _____ Date _____</td> </tr> </table>"; $message .= "</body></html>"; mail($email, $subject, $message, $headers, "From: $email"); echo "The email has been sent."; ?>
  16. OK... I have no idea what is going on. It is back to not working. I will have to play around with it when I get home from work tomorrow and see what is up I also tried running the query in myadmin and it worked.
  17. I tried that and at first it did not work I went back and removed the section of code from the script if ((!$_POST[f_name]) || (!$_POST[l_name])) { header ("LOCATION: show_user_del.php"); exit; } if ($_COOKIE[auth] != "ok") { header("Location: ../login.php"); } it then worked perfectly fine with no problems.
  18. That did not work... The table is defined in the auth_user.php which I require at the beginning
  19. Hello Everyone, I am writing a simple CMS system for someone. I am having trouble getting the delete function to work. I pick the user that I want to remove from the system. I verify that this is the right person to remove. Then the record is deleted from the database. The part that picks the person and verifies that it is the right person to remove from the database work fine. It is the part that actually deletes the record. It takes me back to the pick_user.php. If someone could help me with this I would appreciate it This is the code from the show_user_del.php <?php if (!$_POST[id]) { header ("LOCATION: pick_user.php"); exit; } if ($_COOKIE[auth] != "ok") { header("Location: ../login.php"); } require('../includes/auth_user.php'); //build and issue query $sql = "SELECT * FROM $table WHERE id = '$_POST[id]'"; $result = mysql_query($sql, $connection) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $f_name = $row['f_name']; $l_name = $row['l_name']; $username = $row['username']; $password = $row['password']; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Add Classified Ad</title> </head> <body> <h2><em>Delete user from Database</em></h2> <h3>User being deleted <?php echo "$f_name $l_name"; ?></h3> <form method="POST" action="do_delete_user.php"> <input type="hidden" name="id" value="<?php echo "$_POST[id]"; ?>" /> <input type="hidden" name="f_name" value="<?php echo "$f_name"; ?>" /> <input type="hidden" name="l_name" value="<?php echo "$l_name"; ?>" /> <p> <strong>Name:</strong> <?php echo "$f_name $l_name"; ?> </p> <p> <strong>Username:</strong> <?php echo "$username"; ?> </p> <p> <strong>Password:</strong> <?php echo "$password"; ?> </p> <p> <input type="submit" name="submit" id="name" value="Delete User" /> </p> </form> <p><a href="../admin_menu.php">Return to Administration Menu</a></p> </body> </html> When the submit button is clicked in the above code. It is supposed to bring you to the page below saying that the record was deleted. When the submit button is clicked it sends you back to the pick user page. <?php if ((!$_POST[f_name]) || (!$_POST[l_name])) { header ("LOCATION: show_user_del.php"); exit; } if ($_COOKIE[auth] != "ok") { header("Location: ../login.php"); } require('../includes/auth_user.php'); $sql = "DELETE FROM $table WHERE id = '$_POST[id]'"; $result = mysql_query($sql, $connection) or die(mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <h1>User has been removed</h1> <h2><em>User <?php echo "$_POST[f_name] $_POST[l_name]"; ?> has been deleted from the <?php echo "$table"; ?> table</em></h2> <p><a href="pick_user.php">Delete another person</a></p> <p><a href="../admin_menu.php">Administration Menu</a></p> </body> </html>
  20. All right doing that placed the image in the root directory... How would I go about putting it in /CMS/db_images/? Sorry after I posted this I tried something and I figured it out....Thanks for all of your help. I appreciate it.
  21. Yes I did and I got the same resuly
  22. Everything else in the script works. It is not loading the images into a directory like I want them to.
  23. I have been working on a script for someone and I have hot a road block. Someone was helping me and they rewrote my script and now I am lost. The script is supposed to upload images to a directory that I have set up on my server. After Submission display the images for the user. It does not upload images to the directory I have set up. <?PHP session_start(); if(isset($_POST['title'])) $title = $_POST['title']; else echo "<p>Title was not set...</p>"; if(isset($_POST['year'])) $year = $_POST['year']; else echo "<p>Year was not set...</p>"; if(isset($_POST['make'])) $make = $_POST['make']; else echo "<p>Make was not set...</p>"; if(isset($_POST['model'])) $model = $_POST['model']; else echo "<p>Model was not set...</p>"; if(isset($_POST['model'])) $descript = $_POST['descript']; else echo "<p>Description was not set...</p>"; if(isset($_POST['max_no_img'])) $max_files = $_POST['max_no_img']; else echo "<p>Max Number of Images was not set...</p>"; if($title=="") echo "<p>Title is empty...</p>"; if($year=="") echo "<p>Year is empty...</p>"; if($make=="") echo "<p>Make is empty...</p>"; if($model=="") echo "<p>Model is empty...</p>"; if($descript=="") echo "<p>Description is empty...</p>"; if($max_files=="") echo "<p>Files are empty...</p>"; $valid_types = array ("image/gif", "image/jpg", "image/jpeg", "image/bmp", "image/png"); $max_size = 2000000; $path = "../CMS/db_images/"; ------ This is the database that I have set up. Images do not go here. This displays the images after they have been submitted. $i=0; require('includes/connection.php'); while($i<$max_files) { if ($_FILES['images']['name'][$i] != '') { /* check if file name field empty or not */ if (in_array($_FILES['images']['type'][$i], $valid_types)) { /* check for valid image type */ if($_FILES['images']['size'][$i]<=$max_size) { /* check for allowed size */ $check_name = $_FILES['images']['name'][$i]; $check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name); $good = 0; while($good==0) { if(!file_exists($path . $check_name)) { /* check file that file name already exists */ /* move the file */ -------- This does not move them into the directory at all if (copy($_FILES['images']['tmp_name'][$i], $check_name)) { $all_images = $all_images . $check_name . ","; $good=1; }else{ ?> CHECK WRITE PERMISSIONS OF IMAGE FOLDER!<br> <a href="admin_menu.php">Return to main menu</a> <?PHP exit(); } }else{ /* create new name */ $check_name = date("YmdHis") . $_FILES['images']['name'][$i]; $check_name = preg_replace("/[^a-zA-Z0-9\.]/", "", $check_name); } } }else{ ?> FILE SIZE IS TO LARGE. REZIZE IMAGE!<br> <a href="admin_menu.php">Return to main menu</a> <?PHP exit(); } }else{ ?> FILE SIZE IS TO LARGE. REZIZE IMAGE!<br> <a href="admin_menu.php">Return to main menu</a> <?PHP exit(); } }else{ /* in the event user uses SOME of the image fields and leaves others blank, we should NOT die on this condition */ } $i ++; }$all_images = rtrim($all_images, ","); $sql = "INSERT INTO $table (id, title, year, make, model, descript, image) VALUES (NULL, '$title', '$year', '$make', '$model', '$descript', '$all_images')"; $result = mysql_query($sql) or die ("Could not insert data into DB: " . mysql_error()); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Classified Added</title> </head> <body> <div> <h3>The following information has been added to the <?php echo "$table"; ?></h3> <p> <strong>Title:</strong> <?php echo "$title"; ?> </p> <p> <strong>Year:</strong> <?php echo "$year"; ?> </p> <p> <strong>Make:</strong> <?php echo "$make"; ?> </p> <p> <strong>Model:</strong> <?php echo "$model"; ?> </p> <p> <strong>Description:</strong> <?php echo "$descript"; ?> </p> <?PHP if(substr_count($all_images, ',')>0) { $lines = explode(",", $all_images); $num_images = count($lines); }else{ $lines[0] = $all_images; $num_images = 1;}$i=0;while($i<$num_images) { ?> <p><strong>Image <?PHP echo $i +1; ?>:</strong> <img src="<?PHP echo $path . $lines[$i]; ?>"></p> <?PHP $i ++;}?> <p><a href="show_add.php">Add another classified ad</a></p> <p><a href="admin_menu.php">Return to main menu</a></p> </div> </body> </html>
  24. Oh ok... I see what you are doing.... I think right now I have a script that allows them to go in and make modifications... to any of the records buy using a drop down menu. is that it?
  25. I am sorry for being a terrible pain in your butt. I have never had this much trouble with getting a script to work but then again I have never tried to get more than one image to work. I appreciate all of the help that you are giving me and all of the patience that you are showing me. I am confused about the $wid. What should I put there?
×
×
  • 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.