Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old May 19, 2011, 01:17 PM   #1
definitive
macrumors 65816
 
Join Date: Aug 2008
Agreement form on a website?

I'm trying to build a page where a person would enter some personal info in order to register for classes. It would contain their name, address, phone, several check boxes with a text entry lines, and at the bottom it would contain a check box for agreement. Then they'd submit the form, and the info would get sent through email.

Is there some kind of a PHP script already available that could do this? I don't know PHP, so coding it from scratch is out of the question at the moment. I've tried the fast secure contact form script, but it didn't exactly look presentable, and I couldn't achieve some of the things that I wanted out of the form. Plus the checkbox kept prompting me for data (which I don't require except that the checkbox be checked).
definitive is offline   0 Reply With Quote
Old May 21, 2011, 07:31 AM   #2
mkmDesign
macrumors newbie
 
Join Date: Feb 2010
Location: Scotland
Hey,

This is pretty straight forward to do. Getting the information from the form and emailing it is easy enough, the more difficult side is validation, ensuring the user enters the correct data etc. You can do validation checks in the PHP script, or you can use Javascript to check the data before passing it to the PHP script. I prefer to use jQuery for validation before actioning the PHP script. I suppose it comes down to personnel preference.

Anyway, here's an example:

HTML Form:

Code:
<form method="POST" action="mail.php">
   <label>Name:</label>
   <input type="text" name="name" />
   <label>Phone:</label>
   <input type="text" name="phone" />
   <label>Address</label>
   <textarea name="address"></textarea>
   <input type="checkbox" name="checkbox" value="checkbox" />
   <input type="submit" value="Submit" />
</form>
PHP File:

PHP Code:
<?php
    
//get details user entered and store them in variables
    
$name $_POST['name'];
    
$phone $_POST['phone'];
    
$address $_POST['address'];
    
$checkbox $_POST['checkbox'];

   
//check that checkbox has been ticked
   
if($checkbox !== '1'){
       echo 
"Please select checkbox";
   }

    
//check that data has been entered
    
if(!isset($name) || !isset($phone) || !isset($address)){
        echo 
"Please enter some data";
    }
    else{
        
//set the required information for the email to be sent 
        
$to "youremail@example.com";
        
$subject "New User";
        
$message $name " has now registered on your site.  Their phone number is " $phone " and their address is " $address;
        
$header "New user registered";

       
//send the email
       
mail($to$subject$message$headers);
    }

?>
I've just written this of the top of my head and not actually tested it (I'm at work at the moment) but this should give you an idea of what you need.

If you can supply the code for the form you are using I would be able to explain exactly what you need in your PHP script.
mkmDesign is offline   0 Reply With Quote
Old May 21, 2011, 07:42 AM   #3
Cromulent
macrumors 603
 
Cromulent's Avatar
 
Join Date: Oct 2006
Location: The Land of Hope and Glory
Quote:
Originally Posted by mkmDesign View Post
I prefer to use jQuery for validation before actioning the PHP script.
You ALWAYS need to do validation on the server side. What happens if someone comes to your website with Javascript turned off and all your validation is done by jQuery? Answer: No validation occurs and you have opened yourself up to numerous bugs and attack vectors.

Sure you can validate on the client side with jQuery but you still need to validate on the server side as well. It is either server only or server and client validation but never client validation only.
__________________
Neural Advance - Mac OS X, UNIX and Windows Development
Last.fm Profile | Extreme Metal Reviews
MP 4x 2.66Ghz Xeons / 6GB RAM / 640GB + 500GB + 750GB + 1TB HDDs / ATI Radeon 4870 / iPad 3
Cromulent is offline   0 Reply With Quote
Old May 21, 2011, 09:06 AM   #4
mkmDesign
macrumors newbie
 
Join Date: Feb 2010
Location: Scotland
Quote:
Originally Posted by Cromulent View Post
You ALWAYS need to do validation on the server side. What happens if someone comes to your website with Javascript turned off and all your validation is done by jQuery? Answer: No validation occurs and you have opened yourself up to numerous bugs and attack vectors.

Sure you can validate on the client side with jQuery but you still need to validate on the server side as well. It is either server only or server and client validation but never client validation only.
Hey Cromulent,

Very well said, silly mistake to make. I always used to do validation solely server side, it's only recently I've starting doing both.
mkmDesign is offline   0 Reply With Quote
Old May 22, 2011, 12:20 AM   #5
IgnatiusTheKing
macrumors 68040
 
IgnatiusTheKing's Avatar
 
Join Date: Nov 2007
Location: das Fort
Send a message via AIM to IgnatiusTheKing Send a message via Skype™ to IgnatiusTheKing
There are lots of services out there, many of them free, that will do that for you.
IgnatiusTheKing is offline   0 Reply With Quote
Old May 23, 2011, 01:05 PM   #6
definitive
Thread Starter
macrumors 65816
 
Join Date: Aug 2008
Quote:
Originally Posted by IgnatiusTheKing View Post
There are lots of services out there, many of them free, that will do that for you.
Do you know of any services that do this for free? I've come across http://www.formsite.com but they charge $10/month for over 100 submissions, and $20/month for branding-free service, so that their ads aren't shown on your site. it's nice, and all, but the client who I'm doing this for does not want to spend the money on it.
definitive is offline   0 Reply With Quote
Old May 24, 2011, 12:18 AM   #7
IgnatiusTheKing
macrumors 68040
 
IgnatiusTheKing's Avatar
 
Join Date: Nov 2007
Location: das Fort
Send a message via AIM to IgnatiusTheKing Send a message via Skype™ to IgnatiusTheKing
Check out jotform and email me form. Both have free versions, neither of which is perfect, but they're a decent place to start.
IgnatiusTheKing is offline   0 Reply With Quote
Old Feb 15, 2012, 04:00 PM   #8
shaneg
macrumors newbie
 
Join Date: Aug 2011
Quote:
Originally Posted by IgnatiusTheKing View Post
Check out jotform and email me form. Both have free versions, neither of which is perfect, but they're a decent place to start.
JotForm's site is down now!
shaneg is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Original software license agreement - Need help. yok1987 OS X Mavericks (10.9) 6 Dec 10, 2013 01:39 PM
iPad: User Agreement Mac... nificent iPad 5 Nov 20, 2012 05:06 PM
Submit form to a website, that is not mine? Thelle93 iPhone/iPad Programming 3 Nov 9, 2012 08:46 AM
iPhone 5 Service Agreement rolshan iPhone Tips, Help and Troubleshooting 2 Sep 14, 2012 07:00 PM

Forum Jump

All times are GMT -5. The time now is 11:50 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC