Search Results

Search found 89 results on 4 pages for 'bradley bauer'.

Page 2/4 | < Previous Page | 1 2 3 4  | Next Page >

  • good __eq__, __lt__, ..., __hash__ methods for image class?

    - by Marten Bauer
    I create the following class: class Image(object): def __init__(self, extension, data, urls=None, user_data=None): self._extension = extension self._data = data self._urls = urls self._user_data = user_data self._hex_digest = hashlib.sha1(self._data).hexDigest() Images should be equal when all values are equal. Therefore I wrote: def __eq__(self, other): if isinstance(other, Image) and self.__dict__ == other.__dict__: return True return False def __ne__(self, other): return not self.__eq__(other) def __lt__(self, other): return self.__dict__ < other.__dict__ ... But how should the __hash__ method look like? Equal Images should return equal hashes... def __hash__(self): # won't work !?! return hash(self.__dict__) Is the way I try to use __eq__, __ne__, __lt__, __hash__, ... recommend?

    Read the article

  • setTimeout in javascript not giving browser 'breathing room'

    - by C Bauer
    Alright, I thought I had this whole setTimeout thing perfect but I seem to be horribly mistaken. I'm using excanvas and javascript to draw a map of my home state, however the drawing procedure chokes the browser. Right now I'm forced to pander to IE6 because I'm in a big organisation, which is probably a large part of the slowness. So what I thought I'd do is build a procedure called distributedDrawPolys (I'm probably using the wrong word there, so don't focus on the word distributed) which basically pops the polygons off of a global array in order to draw 50 of them at a time. This is the method that pushes the polygons on to the global array and runs the setTimeout: for (var x = 0; x < polygon.length; x++) { coordsObject.push(polygon[x]); fifty++; if (fifty > 49) { timeOutID = setTimeout(distributedDrawPolys, 5000); fifty = 0; } } I put an alert at the end of that method, it runs in practically a second. The distributed method looks like: function distributedDrawPolys() { if (coordsObject.length > 0) { for (x = 0; x < 50; x++) { //Only do 50 polygons var polygon = coordsObject.pop(); var coordinate = polygon.selectNodes("Coordinates/point"); var zip = polygon.selectNodes("ZipCode"); var rating = polygon.selectNodes("Score"); if (zip[0].text.indexOf("HH") == -1) { var lastOriginCoord = []; for (var y = 0; y < coordinate.length; y++) { var point = coordinate[y]; latitude = shiftLat(point.getAttribute("lat")); longitude = shiftLong(point.getAttribute("long")); if (y == 0) { lastOriginCoord[0] = point.getAttribute("long"); lastOriginCoord[1] = point.getAttribute("lat"); } if (y == 1) { beginPoly(longitude, latitude); } if (y > 0) { if (translateLongToX(longitude) > 0 && translateLongToX(longitude) < 800 && translateLatToY(latitude) > 0 && translateLatToY(latitude) < 600) { drawPolyPoint(longitude, latitude); } } } y = 0; if (zip[0].text != targetZipCode) { if (rating[0] != null) { if (rating[0].text == "Excellent") { endPoly("rgb(0,153,0)"); } else if (rating[0].text == "Good") { endPoly("rgb(153,204,102)"); } else if (rating[0].text == "Average") { endPoly("rgb(255,255,153)"); } } else { endPoly("rgb(255,255,255)"); } } else { endPoly("rgb(255,0,0)"); } } } } Ugh I don't know if that is properly formatted, I ended up with an extra bracket < So I thought the setTimeout method would allow the site to draw the polygons in groups so the users would be able to interact with the page while it was still drawing. What am I doing wrong here?

    Read the article

  • Mac internet problems

    - by Bradley Herman
    Our office is set up with mostly macs (7 of them) but we do have a windows laptop and a windows desktop on the network as well. The network is configured with a modem going into a switch/router throughout the office to the computers, along with a wireless router. Everything runs fine most of the time, but periodically while using the web, certain sites will stop loading and timeout repeatedly. This usually lasts 20 minutes or so and can be incredibly annoying. Resetting the modem/router and/or rebooting the computer never helps. The weirdest part is that in almost every case, the websites are fine on our Windows machines. I frequently use github, google, Stack Overflow, and jQuery reference and I can count on the sites being unavailable to me at least once a day. While I can't get them to load, I can spin my chair around to the windows server behind me and load the sites just fine. Any idea what the hell could be going on here?

    Read the article

  • Free (as in beer) Reverse Image Search API/Library/Service

    - by Bauer
    TinEye provides a great way to "reverse" search by image (i.e. upload/transload an image and have multiple possible sources of that image returned as results.) Since screen-scraping is messy and unreliable, I'm looking for a free API/library/web-service that could offer the same (or similar) reverse-image search function. At present, TinEye offers a commercial API, but since I'll only be using the service for small personal projects, it's hard to justify the cost of the service (the lowest being 1,000 searches for $70 USD). Is anyone aware of such a free service? Or is there a simpler way to approach this (programmatic solution; any language)? I understand that this is a tall order, and submitting the question is really only a last resort in the hope that there is some solution. Example image search is 99designs' StackOverflow logo competition entry by wolv

    Read the article

  • Multiple Remote Desktop Connection in Windows Server 2003?

    - by Joel Bradley
    My company is transitioning all user PC's to Windows 7 64-Bit in anticipation of the 2014 cutoff for Windows XP support. So far everything has been going great except for one specific piece of software that will not run in Windows 7. The current plan is to give everyone a cheap secondary PC to run this software but I feel that's a little much for software that's not even used all the time, although it is essential. I've suggested we install virtual machines but the company does not want to pay for the XP licences. I have access to a copy of Windows Server 2003 that is no longer being used and I was wondering if it was possible to create a remote desktop server. I know it can be done on a one-to-one basis, but this is a 15 person helpdesk. I'd like to be able to support multiple remote dekstop sessions, each with their own logins and dekstops. Is this possible? Are there any other alternatives to my issue? FYI, I've been told that XP mode is only free for consumers. There are costs when used in a corporate environment.

    Read the article

  • My code doesn't recognize layout-xlarge-land?

    - by Justice Bauer
    I am trying to create a landscape and portrait mode only for tablets. For portrait mode I added the files under layout-xlarge and for landscape in tablets I added files under layout-xlarge-land, but just to test if its working I tried switching the background color under landscape to green, but it didnt seem to work. Is there anything else I need to alter for code to recognize landscape mode for tablets?

    Read the article

  • ArchBeat Link-o-Rama for 11/30/2011

    - by Bob Rhubart
    Coding - the new Latin | @BBCRoryCJ BBC Technology Correspondent Rory Cellan-Jones reports on why "the campaign to boost the teaching of computer skills - particularly coding - in schools is gathering force." BPM Business Value Patterns | SOA Partner Community Blog Juergen Kress shares the presentation he and Matthias Ziegler from Accenture delivered at the SOA & BPM Integration Days event in Germany in October. Coherence 3.7.1 Resources Busy blogger Juergen Kress shares links to screencasts and other resources for those interested in Oracle Coherence 3.7.1. OBIEE 11.1.1 - Introduction to OBIEE 11g Full Sample App "The OBIEE 11g Full Sample App (FSA) is a comprehensive collection of examples designed to demonstrate the latest Oracle BIEE 11g capabilities and design best practices." Solaris 11 Customer Maintenance Lifecycle | Gerry Haskins Gerry Haskins launches a new blog devoted to Solaris "policies, best practices, clarifications, and lots of other stuff." Harnessing Business Events for Predictive Decision Making - part 1 / 3 | Sanjeev Sharma "Data growth is outpacing storage capacity by a factor of two and computing power is still very much bounded by Moore's Law, doubling only every 18 months," says Sanjeev Sharma. The Latest Research from the SEI | Douglas C. SchmidtSchmidt shares information on several recently published Software Engineering Institute (SEI) technical reports that "highlight the latest work of SEI technologists in Agile methods, insider threat,the SMART Grid Maturity Model, acquisition, and CMMI." Tiger/Line Shape Files and Oracle | Bradley D. Brown "Have you ever needed to load an ESRI "shape file" and wondered if that's an easy effort or a difficult effort? I know I have and I assumed that it was a pretty difficult effort. However, I learned today that's actually pretty easy!" -- Oracle ACE Director Bradley Brown of TUSC. Webcast: Enterprise Clouds with Oracle VM Tuesday, December 6, 2011, 9:00 am PT / Noon ET. Featuring Adam Hawley (Senior Director of Product Management, Oracle) and Dan Herrup (Principal Systems Engineer, Oracle Corporate Citizenship). SOA Made Simple; Architects in AZ; Cloud Migration Introduction This week on the Architect Home Page on OTN.

    Read the article

  • Google Map API v3 — set bounds and center

    - by Michael Bradley
    Hi, I've recently switched to Google Maps API V3. I'm working of a simple example which plots markers from an array, however I do not know how to center and zoom automatically with respect to the markers. I've searched the net high and low, including Google's own documentation, but have not found a clear answer. I know I could simply take an average of the co-ordinates, but how would I set the zoom accordingly? Could somebody please point me in the right direction? Perhaps you know of a good tutorial. Many thanks in advance, Michael function initialize() { var myOptions = { zoom: 10, center: new google.maps.LatLng(-33.9, 151.2), mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions); setMarkers(map, beaches); } var beaches = [ ['Bondi Beach', -33.890542, 151.274856, 4], ['Coogee Beach', -33.423036, 151.259052, 5], ['Cronulla Beach', -34.028249, 121.157507, 3], ['Manly Beach', -33.80010128657071, 151.28747820854187, 2], ['Maroubra Beach', -33.450198, 151.259302, 1] ]; function setMarkers(map, locations) { var image = new google.maps.MarkerImage('images/beachflag.png', new google.maps.Size(20, 32), new google.maps.Point(0,0), new google.maps.Point(0, 32)); var shadow = new google.maps.MarkerImage('images/beachflag_shadow.png', new google.maps.Size(37, 32), new google.maps.Point(0,0), new google.maps.Point(0, 32)); var lat = map.getCenter().lat(); var lng = map.getCenter().lng(); var shape = { coord: [1, 1, 1, 20, 18, 20, 18 , 1], type: 'poly' }; for (var i = 0; i < locations.length; i++) { var beach = locations[i]; var myLatLng = new google.maps.LatLng(beach[1], beach[2]); var marker = new google.maps.Marker({ position: myLatLng, map: map, shadow: shadow, icon: image, shape: shape, title: beach[0], zIndex: beach[3] }); } }

    Read the article

  • Magento: Display sub-category list

    - by Neil Bradley
    Hi there, I'm building a Magento store and want to be able to display a list of categories and have each category link to its own page. I have a 'Brands' category with an ID of 42 and I want to display a list of the sub-categories and ensure that each one links to the designated URL key in the CMS. Has anyone had experience of doing this with Magento? Thank you.

    Read the article

  • Need to add hover intent?

    - by Bradley Bell
    Hi all, I'm really stuck. Basically i'm totally new to jquery, but need to add some kind of timer on mousover so that the page doesn't get messed up if the mouse goes all over the page. here's my script.. anyway i can easily implement it? <script> jQuery('cc').mouseover(function () { $("squareleft3").hide(); $("twitter").hide(); $("facebook").hide(); $("squareright").hide(); $("getintouch").hide(); $("getintouch2").hide(); $("getintouch3").hide(); $("vicarimage").hide(); $("squaredown2").hide(); $("squareleft2").hide(); $("one").hide(); $("whatis").hide(); $("squaredown").hide(); $("whoweare").hide(); if ($("whoweare:first").is(":hidden")) if ($("squaredown:first").is(":hidden")) if ($("squareleft3:first").is(":hidden")) { if ($("twitter:first").is(":hidden")) if ($("squareright:first").is(":hidden")) if ($("getintouch:first").is(":hidden")) if ($("getintouch2:first").is(":hidden")) if ($("getintouch3:first").is(":hidden")) if ($("vicarimage:first").is(":hidden")) if ($("squaredown2:first").is(":hidden")) if ($("squareleft2:first").is(":hidden")) if ($("one:first").is(":hidden")) if ($("whatis:first").is(":hidden")) jQuery('getinvolved').fadeIn(); jQuery('squareleft').slideToggleWidth(); } else { $("squareleft").hide(); $("getinvolved").hide(); } } ); </script> Cheers.

    Read the article

  • jQuery ajax in DotNetNuke preserving user authentication

    - by Michael Bradley
    I want to use jQuery's ajax functionality in a DotNetNuke module I'm developing. I want the ajax call to be authenticated via DNN's membership functionality. I want the ajax response as json. How can I do this? I've looked at IWeb and IWebCF -- it's not clear to me from much Googleing and scanning the forums whether these modules would allow me to create a web service that would accept a simple post request and return json (seems like they want to do it the ASP.NET AJAX way with a generated proxy, I'd prefer to just use jQuery's AJAX call functionality). Seems you can't create a simple webmethod in a DNN module (since they are developed as User Controls (.ascx)). I could deploy an .asmx file with module, but that won't leverage DNN's authentication system. Ideas? I'm currently developing against DNN 4.9.5

    Read the article

  • OSCommerce checkout success page tracking

    - by Neil Bradley
    Hi there, I'm installing some tracking code into the checkout_success.php page. I need to be able to grab the coupon code/discount code name from the order, if one was used so that I can echo it out in my tracking script. I was wondering if anyone knows how to do this? I'm using this contribution of discount coupons; ot_discount_coupons.php, August 4, 2006, author: Kristen G. Thorson, ot_discount_coupon_codes version 3.0 It seems that the coupon code is not actually stored in the order_totals, but in a seperate discount_coupons_to_orders table. is there a query i can do on this table to find the matching coupon code used for this order? i tried the following but it return nothing; $coupon_query = tep_db_query("select coupons_id from discount_coupons_to_orders where orders_id = '".(int)$orders['orders_id']."' ORDER BY orders_id DESC LIMIT 1"); $coupon_id = tep_db_fetch_array($coupon_query); $couponid = $coupon_id['coupon_id']; Thank you.

    Read the article

  • How to create a rails habtm that deletes/destroys without error?

    - by Bradley
    I created a simple example as a sanity check and still can not seem to destroy an item on either side of a has_and_belongs_to_many relationship in rails. Whenever I try to delete an object from either table, I get the dreaded NameError / "uninitialized constant" error message. To demonstrate, I created a sample rails app with a Boy class and Dog class. I used the basic scaffold for each and created a linking table called boys_dogs. I then added a simple before_save routine to create a new 'dog' any time a boy was created and establish a relationship, just to get things setup easily. dog.rb class Dog < ActiveRecord::Base has_and_belongs_to_many :Boys end boy.rb class Boy < ActiveRecord::Base has_and_belongs_to_many :Dogs def before_save self.Dogs.build( :name => "Rover" ) end end schema.rb ActiveRecord::Schema.define(:version => 20100118034401) do create_table "boys", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end create_table "boys_dogs", :id => false, :force => true do |t| t.integer "boy_id" t.integer "dog_id" t.datetime "created_at" t.datetime "updated_at" end create_table "dogs", :force => true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" end end I've seen lots of posts here and elsewhere about similar problems, but the solutions are normally using belongs_to and the plural/singular class names being confused. I don't think that is the case here, but I tried switching the habtm statement to use the singular name just to see if it helped (with no luck). I seem to be missing something simple here. The actual error message is: NameError in BoysController#destroy uninitialized constant Boy::Dogs The trace looks like: /Library/Ruby/Gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:105:in const_missing' (eval):3:indestroy_without_callbacks' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/callbacks.rb:337:in destroy_without_transactions' /Library/Ruby/Gems/1.8/gems/activerecord-2.3.4/lib/active_record/transactions.rb:229:insend' ... Thanks.

    Read the article

  • Error when creating ASP.NET website in Visual Studio

    - by Jim Bradley
    I'm trying to learn ASP.NET. I open Visual Studio (this happens in both 2008 and 2010) and creating a new ASP.NET website using .NET 3.5. When I attempt to run the website, a FireFox page opens up and tells me that it can't establish a connection to the server (localhost:####). There's no helpful error message, just "cannot connect." What could be causing this?

    Read the article

  • Explaining the need to avoid horizontal scroll

    - by Bradley Herman
    I need help explaining to my boss why her design is poor on a client's website. She has no knowledge of the web, and it can be difficult as a web developer working with a woman who is a graphic designer (not even a web designer really). On a current site she has designed, an image bar "needs" to be ~1200px according to her, though it isn't necessary with the content. A quick sketch to illustrate what's going on: As you see, the banner spills out past the 960px of the content and as wide as 1200px. This creates a horizontal scroll when all the content is viewable within the 960px wide viewport. I need to make this an <img and not a CSS background because it's a jQuery slideshow that fades from image to image. I think this is a big problem because a lot of people are going to get a horizontal scroll bar imposed in their browser when they're still able to see all the relevant content. She thinks no one will notice and it'll be fine; I think it's very bad practice and confusing to the end user. How do I explain the problem to her?

    Read the article

  • Fancybox force scroll to top

    - by Bradley Herman
    I'm using the jQuery Fancybox plugin to display some content on a website. Unfortunately, when a link is clicked, the lightbox that is loaded starts at the same scroll position as the previous one. I tried using self.scrollTo(0,0) $.scrollTo(0) $('#top').scrollTo(); and a few others methods to push it back to the top, but none have seemed to work. Any help on this?

    Read the article

  • Need help parsing file/writing script

    - by Bradley Herman
    Hey all, I have been doing nothing but web development over the last few years and haven't written any Java or C++ in what feels like forever. I don't necessarily need to use these languages, so I'm entirely open to suggestion. I was given an email list by a client to import into their mailchimp account yesterday and unfortunately, Mailchimp couldn't read the file. It's a text file, but I don't believe it's tab delimited (which would make this much, much easier for me). A small portion of the file (I've changed last names and email addresses) can be viewed here: http://sparktoignite.com/patients.txt If anyone has suggestions on how I can get this into a Mailchimp readable format (csv, tab delimited txt, excel) please let me know. I feel like 3 years ago I would've been able to do this in a matter of minutes, but given that I haven't touched anything other than RoR, PHP, and jQuery for the last few years, I don't know where to start. Thanks!

    Read the article

  • Explaining to boss why we need to avoid horizontal scroll

    - by Bradley Herman
    I need help explaining to my boss why her design is poor on a clients website. She has no knowledge of web and it can be difficult as a web developer working with a woman who is a graphic designer (not even a web designer really). On a current site she has designed, an image bar "needs" to be like 1200px according to her, though it isn't necessary with the content. I'll show a quick sketch to illustrate what's going on: http://imgur.com/MNGOT.jpg As you see, the banner spills out past the 960px of the content and as wide as 1200px. This creates a horizontal scroll when all the content is viewable within the 960px wide viewport. I need to make this an img and not a css background because it's a jquery slideshow that fades from image to image. I think this is a big problem because a lot of people are going to get a horizontal scroll bar imposed in their browser when they're still able to see all the relevant content. How do I help her explain it. She thinks no one will notice and it'll be fine, I think it's very bad practice and confusing to the end user. Any help?

    Read the article

  • Returning unique values of a multi-dimensional array with CodeIgniter PHP

    - by Michael Bradley
    Hi - I'm developing a property rentals website. The search results page will contain a list of property results. It is my intention to redefine the results, say by town, country, property type etc. So let's say for example the user searches 'France'. All of the relative properties will be returned and displayed in a list. However, I also need to reuse this array, to display only unique town names from the search results array. e.g. Montpellier, Lyon, Rennes, Nice etc. The idea is when use user click on 'Nice', only the 'Nice' properties would return. I would also like to display how many properties are in that town. The closest example as to what I want to achieve. http://www.miaandmaggie.com/dog-collars-leashes.html Any ideas how I can use my search array to display the unique towns of the search? Many thanks! M

    Read the article

  • WPD on XP, Vista, and 7 (need to transfer photo and video files)

    - by Bradley Dean
    I need to transfer files (still photos and videos) from any portable device that a user may connect (still camera, video camera, mobile phone, etc.) I don't need to worry about plain storage devices as these have drive letters. And I only care about existing files, I don't care about live video, preview video, taking new pictures, etc. I originally tried WIA, which works great except it can not transfer video files. So then I tried WPD, following along with dimeby8's tutorial: http://blogs.msdn.com/b/dimeby8/archive/2006/09/27/774259.aspx I haven't gotten the transfer working yet (I'm converting it over to C#), but I can at least see the device and enumerate the files in Win7. In XP I get nothing. It's pointed out in this thread that WPD won't enumerate devices on XP (see Lisa O [MSFT]'s post): http://social.msdn.microsoft.com/Forums/en/windowssdk/thread/56459945-b757-45df-8c9f-4ebdbbb18a2c So WIA is out because it won't do video. And WPD is out because it won't do XP. Has anyone gotten this to work? Am I missing something simple here? Thanks.

    Read the article

  • iPhone Accelerometer > csv > email

    - by Bradley Powers
    Hi all, I'm trying to collect data for a machine learning project I'm working on. What I'd like to do is collect accelerometer data from an iPhone, save it to a csv and email it to myself. My app currently is able to acquire data from the accelerometer, but I'm at a bit of a loss as to how to proceed. First of all, I'd like to acquire data for a preset amount of time (after playing a sound to the user) which I don't really know how to do, and I can't find good documentation for. Also, I'd like to save that to a csv, which there is some documentation on (specifically using the NSString writeToFile method). Any recommendations/ ideas? Thanks!

    Read the article

  • Discussion on SEO best-practices for site development involving php...

    - by Bradley Herman
    Recently in our work, I've started getting some experience with SEO (finally). It's something I've put off for a long time because I've always maintained that SEO is a buzz-word b.s. pseudo-science and more about providing quality, relevant content (assuming proper header tags and the basics are covered). However, sometimes a client doesn't have stellar content yet still demands SEO and high rankings. While it's not how I design sites 100% of the time (as design dictates structure), I typically create a basic template from the design my boss gives me, then I optimize it, and then strip the top and bottom and move those to header.php and footer.php, using the following to bring in the header and footer based on AJAX versus HTML requests: <?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''){ include('includes/header.php'); }?> #content here <?php if($_SERVER['HTTP_X_REQUESTED_WITH']==''){ include('includes/footer.php'); }?> Then, I use jQuery to intercept page requests and I use AJAX to fill in, for example, a #copy div with the new content. This avoids unnecessarily loading all the header and footer info everytime, but still allows users without Java to access pages without any problems. (also to think about, depending on size of content, do the extra http requests added using this method render it more of a server strain versus a single, larger file?) I don't have a really solid understanding of the meta keywords and their SEO significance, but as I recall reading, the keywords, title, and description on a page should match up to the pages content--ie. each page should have slightly different keywords/description while retaining some common ground. What I'm getting at here is trying to foster a discussion on whether my approach is flawed to begin with, if there are things I can do (within reason) that keep the site structure simple but allow for better SEO practices, or if my SEO understandings are wrong. This isn't a question, per say, but hopefully a constructive discussion here that more than just I can learn from. I appreciate any responses and hope to hear from you. Thanks!

    Read the article

  • Increased kerning on website text

    - by Bradley Herman
    We're developing a site for a client right now and my boss (designer only) is once again making me increase letter-spacing on the text so that it looks 'prettier'. I am of the firm belief that this often causes eye-strain and hinders readability in body copy, but being the boss, she is of course always 'right' until I can provide her with examples showing why she's wrong (generally pretty easy). In this case, however, I can't find any articles talking about eye-strain and kerning, so I figured I'd ask what you guys think about the issue of increased letter-spacing in web text. Take a look at http://sparktoignite.com/allograft/process.php and tell me how you feel about the body copy. We're using font-embedding, so you'll only see the proper font in FF, Safari, and Chrome. Let me know what you guys think about the readability and eye-strain caused by the font. My boss currently thinks it's 100% perfect (she wanted the kerning increased further, but I talked her down luckily).

    Read the article

  • reCaptcha integration with php

    - by Neil Bradley
    Hi there, I'm building a contact us page that also uses a reCaptcha, but im having a few issues with it. I fill in all of the fields in the contact form and the correct reCaptcha words, but the form does not submit. I'm assuming this is something to do with the validation, but wondered if someone might be able to spot where i'm going wrong? The PHP code at the top of my page looks like this; <?php include('includes/session.php'); $err = ''; $success = ''; if(isset($_POST["docontact"]) && $_POST["docontact"] == "yes") { //get form details $form = new stdClass(); $form->name = sanitizeOne($_POST["name"], "str"); $form->email = sanitizeOne($_POST["email"], "str"); $form->phone = sanitizeOne($_POST["phone"], "str"); $form->mysevenprog = sanitizeOne($_POST["mysevenprog"], "str"); $form->enquiry = sanitizeOne($_POST["enquiry"], "str"); $form->howfindsite = sanitizeOne($_POST["howfindsite"], "str"); //Check for errors (required: name, email, enquiry) if($form->name == "") { $err .= '<p class="warning">Please enter your name!</p>'; } if($form->email == "") { $err .= '<p class="warning">Please enter your email address!</p>'; } if($form->enquiry == "") { $err .= '<p class="warning">Please supply an enquiry message!</p>'; } //Send Email if($err == "") { $mailer = new BlueMailer(); $mailer->AddAddress(Configuration::getVar("developer_email"), Configuration::getVar("admin_email_name")); include('templates/email/contact-us-admin.php'); if(!$mailer->Send()) { $err .= "<p>There was an error sending submitting your request!, Please try again later."; } else { $success = 'thanks'; } } } else { //Initialise empty variables $form = new stdClass(); $form->name = ""; $form->email = ""; $form->phone = ""; $form->mysevenprog = ""; $form->enquiry = ""; $form->howfindsite = ""; } ?> And then in the body of my page I have the form as follows; <?php if($err != "") : ?> <div class="error"> <?php echo $err; ?> </div> <?php endif; ?> <?php if($success == 'thanks') : ?> <h3>Thank you for your enquiry</h3> <p>Your enquiry has been successfully sent. Someone will contact you shortly.</p> <?php else: ?> <h3>If you are looking to advertise with us, have some feedback about some of our programming or want to say 'Hi' please use the fields below</h3> <form name="contactus" id="contactus" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'] ?>"> <ul> <li><label for="name">Your name: *</label> <input name="name" id="name" class="textbox" style="width: 75%;" type="text" value="<?php echo $form->name ?>" /></li> <li><label for="email">Email address: *</label> <input name="email" id="email" class="textbox" style="width: 75%;" type="text" value="<?php echo $form->email ?>" /></li> <li><label for="phone">Telephone:</label> <input name="phone" id="phone" class="textbox" style="width: 75%;" type="text" value="<?php echo $form->phone ?>" /></li> <li><label for="mysevenprog">My Seven programme</label> <input name="mysevenprog" class="textbox" style="width: 75%;" type="text" value="<?php echo $form->mysevenprog ?>" /></li> <li><label for="enquiry">Enquiry/Message: *</label> <textarea name="enquiry" class="textarea" rows="5" cols="30" style="width: 75%;" id="enquiry"><?php echo $form->enquiry ?></textarea></li> <li><label for="howfindsite">How did you find out about our site?</label> <input name="howfindsite" id="howfindsite" class="textbox" style="width: 75%;" type="text" value="<?php echo $form->howfindsite ?>" /></li> <li> <?php require_once('recaptchalib.php'); // Get a key from http://recaptcha.net/api/getkey $publickey = "6LcbbQwAAAAAAPYy2EFx-8lFCws93Ip6Vi5itlpT"; $privatekey = "6LcbbQwAAAAAAPV_nOAEjwya5FP3wzL3oNfBi21C"; # the response from reCAPTCHA $resp = null; # the error code from reCAPTCHA, if any $error = null; # was there a reCAPTCHA response? if ($_POST["recaptcha_response_field"]) { $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if ($resp->is_valid) { echo "You got it!"; } else { # set the error code so that we can display it $error = $resp->error; } } echo recaptcha_get_html($publickey, $error); ?> </li> <li><input type="submit" value="Submit Form" class="button" /></li> </ul> <input type="hidden" name="docontact" value="yes" /> </form> <?php endif; ?>

    Read the article

< Previous Page | 1 2 3 4  | Next Page >