1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need php script for my contact form

Discussion in 'HTML & Website Design' started by undertaker1, Jan 8, 2013.

Thread Status:
Not open for further replies.
  1. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #21
    Good point -- some time ago another developer and I came up with this over on another forums:
    
    function isValidEmail($address) {
    	if (filter_var($address,FILTER_VALIDATE_EMAIL)==FALSE) return false;
    	
    	/* explode out local and domain */
    	list($local,$domain)=explode('@',$address);
    	
    	$localLength=strlen($local);
    	$domainLength=strlen($domain);
    	
    	return (
    		/* check for proper lengths */
    		($localLength>0 && $localLength<65) &&
    		($domainLength>3 && $domainLength<256) &&
    		(
    			checkdnsrr($domain,'MX') ||
    			checkdnsrr($domain,'A')
    		)
    	);
    }
    
    Code (markup):
    In PHP there's no need for a regex as there is a perfectly good filter_var to check for if it's RFC 5322 valid -- apart from it failing to check lengths properly... and yeah, passing through checkdnsrr to make sure the domain has a valid MX or A record is a really good idea... that's why we did it, and it's why my contact forms all do that.

    I may have given myself too much time to work on my form generator here -- I was going to simply rip out the contact form from my pages and post it up here, but it uses my form generator that uses an array to both build the form and handle validation... but I started moving it over to object based and am adding in all sorts of extra bits of functionality now -- including transparent scripted validation. Apart from the page-load you'd never know the difference between scripting on and scripting off, apart from the input[reset] being more powerful with scripting enabled... I'm probably gonna make a page for it on my site, when I do I'll post a link to it in this thread.
     
    deathshadow, Jan 28, 2013 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #22
    DS, you're ASS U ME ng that everyone who develops websites is a developer. Totally unwarranted. (Referring to post #20, not #21.)
     
    Rukbat, Jan 28, 2013 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #23
    Ok, I was able to gut down my approach to something digestible/usable outside the CMS I'm slowly developing.

    Live demo here, shows what would be sent to the mail function, has a scripted assist for validation, validation still works when scripting disabled.

    http://www.cutcodedown.com/for_others/formHandlerDemo/simpleMailTest.php

    To make grabbing it simple I put it all in a rar file.
    http://www.cutcodedown.com/for_others/formHandlerDemo/formHandlerDemo.rar

    I'll work up some documentation for it over the next day or so... The basic concept is to have a 'formHandler' class you extend for each form... the extend defines an array that the parent can turn into a form, or use to validate the form. Since it's an array one could also make it so that you can define the form elements from a database if desired. You then just overload it's submit method with what you want the form to do when a valid submit is finally achieved.

    It's still semi-incomplete -- no radio button fieldsets, multi-fieldsets and not all the scripting validations are complete... but it's good enough for a contact form right now.

    Of course the semantic markup and media queries means it's fully responsive -- so it should be pretty easy to drop into almost any layout.
     
    deathshadow, Jan 28, 2013 IP
  4. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #24
    Nice speech, it was if we were in a cult meeting preparing for the lynching of Tables! The fervent crowd started to Sieg Heil in a crowd roar to your ambitious motivate hate speech at tables.

    ..so anyways, many people still use tables. I sometimes use tables. I use notepad basic to code all my programs and sites. I dislike 'editors' but as stated editors use tables like crazy and you'd think your speech could be better directed at DreamWeaver makers etc. There's really nothing special at all about HTML design anyway and its considered the kindergarten level of programming. All my programs work great, even my custom designed printing websites for printers etc. The artificial intelligence works good and it doesn't complain about tables. But ya know I understand your attempt to try to make better HTML designers out of peoples even if your preaching from the pulpit IS a little over the top. At first I was wondering if you were one of those types that comes forward aggressive verbally and uses that persona as a defensive. I see it in the music industry a lot where sometimes people that lack knowledge or have no formal high-level credentials come across as verbally aggressive hoping to leave no time for anyone to question their credentials in industry. We're used to seeing it there the tap dance with shoes lit on fire.but there, we allow them to run full course ..and then ask them so that it becomes the build-up to the punchline. Here that's not necessary as you have me convinced that you're a God on Mars when it comes to HTML WITHOUT TABLES for god sakes. awesome. Continue the good work killing off the 1997 tables across the land. My favorite part was usage of etymology. I was presuming your facilitation to quantize methodology algorithmic linear for cognitive crapology skit.
     
    ezprint2008, Jan 29, 2013 IP
  5. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #25
    Is that for a multi-form bulk sale? Since mail-forms are easily created in 30 seconds or less in PHP. Yours is decorative though, quite large in the textarea. There are quite a bit of free CSS-Styles out there with wrappers, corners if that's what you're looking for.

    Also Ajax mail-forms are awesome, so when user submits the last var (forced by validation script)
    It sends all vars through AJAX engine and makes the email form disappear/replaced from the <DIV> table with a Confirmation message or a'next-process'. Those email forms are scale-able or selected size choices. The one in your explanation seems to have a bad color-wheel and is extra-huge for an email form in my opinion.
     
    ezprint2008, Jan 29, 2013 IP
  6. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #26
    It's meant to allow the quick creation of semantic forms WITH validation WITHOUT the headaches of THINKING about validation, hence the extensible object. The mail form is an example of using the formHandler.php module with it's matching (still very much WIP) javascript.

    Placeholder style in terms of FaC. Since it's all in the CSS, style away without having to dive into the markup.

    If you mean the width, it's meant to be dynamic which is why it's in a placeholder div#pageWrapper. Try resizing, particularly notice how in MODERN browsers it drops down to one column below a certain width. It's called responsive layout, and being fully fluid with responsive layout means you can drop it in anyplace you want on a page, and it will auto-fit whatever it's inside... again prompting the silly question: "Have you even HEARD of responsive layout? Accessibility norms?"

    Even when some idiot 'demands' a fixed width layout I design fluid first because it's EASIER than sitting there micromanaging the sizes of everything -- then just fix the outer container.

    Though personally these crappy little narrow forms people seem to have a raging chodo for these days where you can't even see 20 characters across, with the absurdly short and useless textareas that barely show four rows... Well, there's a reason I'm a fan of browsers like Opera and FF giving us the ability to resize textarea's regardless of what some 'designer' thought was nice; I'm not even bothering adding resize scripting anymore -- though before browsers added it that was a stellar example of USEFUL enhancement using javascript.

    For me that depends on the context -- on things like a forums quick reply or inline-edit, yeah... that's pretty awesome... So long as it has scripting off graceful degradation and doesn't take more than a couple k of scripting. Really though with accessible and responsive development and design, one should build it to work WITHOUT all the fancy extras, then progressively enhance it with CSS and scripting so that should CSS and scripting be unavailable/inapplicable, the page still works. A concept lost on the people who crap together off the shelf garbage like jQuery, YUI or Mootools.

    Something like a contact form? Waste of code... only justification for that is the noodle-doodle idiotic nonsense like "pageloads are evil"... maybe if people stopped blowing hundreds of K of markup doing tens of K's job and practiced separation of presentation from content, they wouldn't 'need' to throw more code at a non-issue...

    Though no clue what you mean by "bad color wheel" -- since it's blue and grey... with the blues within 10% of each-other on the hue... DEF, CDE, ACE, 8AC, 248... and it adheres to the WCAG contrast minimums. (or more specifically the IBM/Microsoft/Apple joint accessible color guide from the late '80's when they actually worked together -- using the formula from the EGA and VGA specifications for emissive luminance).

    Also funny your thinking I'm a Nazi when it comes to tables, since I actually DEFEND their use for *SHOCK* tabular data... like say a forum index where you have obviously related rows and columns and where things like TH with SCOPE provides better accessibility on screen readers than say... the endless annoying and pointless garbage the default skins programs like Xenforo and vBulletin have switched to. You seem to be thinking I'm saying "never use tables" -- not the case... A LOT of people out there right now are under the delusion tables are deprecated (they are not), and go to absurd lengths to not use them like endless nested LI with headings inside them. (which IMHO is redundant markup since LI divides things into sections, headings divide things into sections) -- but that on the whole going back to most people crapping out markup don't take the time to learn what the tags are actually for, and just copypasta everyone else's bad practices.

    You are right on one thing -- HTML is kindergarten level coding; which is why it's mind-blowing so many people writing HTML don't seem to understand what it's for, how to use it, or what the purpose of any of the tags are.
     
    deathshadow, Jan 30, 2013 IP
  7. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #27
    ohh... do you program anything else?
     
    ezprint2008, Feb 12, 2013 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #28
    NOT to go way OT with my whole life's story...

    I started programming some 35 or so years ago hand compiling my own RCA 1802 machine language and entering it 8 bits at a time on toggle switches. (see Cosmac Elf). Since that time I've done machine language on everything from the Z80 to ARM... I spent a good decade creating double entry accounting systems in Clipper, DiBol and Borland Paradox, been part of game development groups... (ever heard of Pie in the Sky software? That's ok, nobody else has either) much less my command of C, C++ and Pascal/Oberon/Delphi which I've used over the years on various projects. At least a quarter of the 'in counter' scale/barcode scanner combo's used in grocery stores in New England (and probably the rest of the country) are driven by microcontroller code I wrote back when I worked for Marstek.

    Though I'm retired now, have been for a few years, preferring to work on my own projects or help people for free online since due to failing health I don't want to start a project then leave anyone else hanging just because I'm bedridden or in supervised care for a week or two -- particularly if money has changed hands. TECHNICALLY I'm on doctors orders not to work (even this stuff), but I'm just not one to sit around with my thumb up my arse.

    Though I've been having fun goofing around doing some retrocomputing programming -- like my crappy little pacman ripoff for PC/PCJr/Tandy or Commodore 64 -- the PC version being a mix of Pascal and Assembly and running on as little as an original '82 IBM 5150, the latter being a mix of C and 6502 Assembly -- which I JUST taught myself to do 6502 code back in November for fun. (since back in the day I never had a Commodore or an Apple). I really feel that going back and doing old-school coding from time to time teaches better decision making in the here and now... if you understand the under the hood functionality, you're more likely to produce better high level code since you are always thinking "what's this going to do to my memory footprint" or "What does the compiler or interpreter have to do to accomplish this"

    So to me, PHP and MySQL is the same dance, just a different tune. It's C in drag with a frilly maid outfit... and as you said, HTML and CSS are kindergarten.

    Hey, you asked...
     
    deathshadow, Feb 13, 2013 IP
  9. ezprint2008

    ezprint2008 Well-Known Member

    Messages:
    611
    Likes Received:
    15
    Best Answers:
    2
    Trophy Points:
    140
    Digital Goods:
    1
    #29
    If you've done all that , great .. I had you assumed as a young 20's in his first 3 years of HTML and CSS and practicing your drill sargent coding practices on others. I'm not as experienced as you in coding so I'll rightfully yeild to that. PHP in drag.. that's a strange example. I wont ask about that one.
     
    ezprint2008, Feb 14, 2013 IP
Thread Status:
Not open for further replies.