PHP Form Generator? Such a thing?
Moderator: General Moderators
PHP Form Generator? Such a thing?
Hello,
I am trying to write a PHP script that will take fields and insert them into a database, then send off an email depending on what boxes are checked. Pretty standard stuff. Nothing particularly extraordinary.
Problem is, I dont know PHP very well at all. I can kind of sort of read it, but I cant write it by hand. The other problem is, I need to write several of these very soon and have no resources. We are a small nonprofit, and I am the tech department... more or less.
I have seen several PHP form generators on sourceforge, but the ones I downloaded did not work.
The idea of a PHP form generator is very appealing to me right now.
If anyone knows of one that works and can do what I need it to, or knows another way I can attack this head-on, I would be very appreciative if you would let me know. I am usually on ICQ, and I am happy to get your emails. I am also planning on being around here quite a bit more now that I am in this position and need to learn.
Thank you for taking the time to consider my request.
Take care.
J
I am trying to write a PHP script that will take fields and insert them into a database, then send off an email depending on what boxes are checked. Pretty standard stuff. Nothing particularly extraordinary.
Problem is, I dont know PHP very well at all. I can kind of sort of read it, but I cant write it by hand. The other problem is, I need to write several of these very soon and have no resources. We are a small nonprofit, and I am the tech department... more or less.
I have seen several PHP form generators on sourceforge, but the ones I downloaded did not work.
The idea of a PHP form generator is very appealing to me right now.
If anyone knows of one that works and can do what I need it to, or knows another way I can attack this head-on, I would be very appreciative if you would let me know. I am usually on ICQ, and I am happy to get your emails. I am also planning on being around here quite a bit more now that I am in this position and need to learn.
Thank you for taking the time to consider my request.
Take care.
J
Never used it... but I've been recommended this a few times: http://pear.php.net/package/HTML_QuickForm/
I only need one form to start.hawleyjr wrote:How many forms are you needing? How large are the forms?
It is a registration form that collects peoples' address, phone number, age, etc. I guess there are about 15 fields in total, and they all need to be validated. Only about two are not required.
It also asks what programs they are interested in and depending on which are checked off, sends off an email to the corresponding staff member.
I actually completed a form that does this with the aid of FacileForms for Mambo, but now this is going to have to be free-floating, called from a Mambo page but updating a seperate database.
J
Sounds like a fairly small project. I’m sure there are many member here who could do it for a small fee.jmilane wrote:I only need one form to start.hawleyjr wrote:How many forms are you needing? How large are the forms?
It is a registration form that collects peoples' address, phone number, age, etc. I guess there are about 15 fields in total, and they all need to be validated. Only about two are not required.
It also asks what programs they are interested in and depending on which are checked off, sends off an email to the corresponding staff member.
I actually completed a form that does this with the aid of FacileForms for Mambo, but now this is going to have to be free-floating, called from a Mambo page but updating a seperate database.
J
Like I said, I want to do it myself... I work for a nonprofit... ie - we dont have no money.hawleyjr wrote:Sounds like a fairly small project. I’m sure there are many member here who could do it for a small fee.jmilane wrote:I only need one form to start.hawleyjr wrote:How many forms are you needing? How large are the forms?
It is a registration form that collects peoples' address, phone number, age, etc. I guess there are about 15 fields in total, and they all need to be validated. Only about two are not required.
It also asks what programs they are interested in and depending on which are checked off, sends off an email to the corresponding staff member.
I actually completed a form that does this with the aid of FacileForms for Mambo, but now this is going to have to be free-floating, called from a Mambo page but updating a seperate database.
J
Not looking for a handout... just a tool I can use to make life easier.
J
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
jmilane - So you're talking about making an HTML form that sends data to a PHP page? And that PHP page inserts data into a database and emails someone based in what was selected in the form? Please confirm that this is what you are looking to do. If this is what you want, that is rather simple. If you are looking for an app that makes your forms, and does what you want it to do, that is quite a bit more involved.
Yes, all I want is a registration form. People will click "Register Now!" and be presented with a simple form.Everah wrote:jmilane - So you're talking about making an HTML form that sends data to a PHP page? And that PHP page inserts data into a database and emails someone based in what was selected in the form? Please confirm that this is what you are looking to do. If this is what you want, that is rather simple. If you are looking for an app that makes your forms, and does what you want it to do, that is quite a bit more involved.
They will then register for one or more programs. They will enter their name and all their personal information and pick any combination of program A, B, C, or D.
They will hit, "Submit"
Their personal info will go to the database.
The fields will also be parsed into the $body (just concatenating a long string) of an email and sent to whomever is the head of the program(s) they selected. The email will be very basic:
Bob Jones has registered.
He was born in 12/12/1994
He was referred by John Smith
He is male.
Etc...
I dont think it is complicated. For me, sure... I cant do it at all. But I dont think in the scope of PHP that it is a big deal.
Id appreciate it if anyone could tell me about a PHP Form Generator that works. I have downloaded a few, but they are broken and dont work properly.
Or, maybe I am silly to expect to be able to do this without more knowledge of programming. I used to code in VB and PowerBuilder (and SQL) but that was 10 years ago. I was overseas for several years, and am getting back into technology. Sorry if my questions are dumb. I just dont like to have people do stuff for me without learning what it is that they are doing... so I dont have to ask next time.
Besides, I like this stuff so far. Just cant deliver what Boss wants with my current knowledge base.
J
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Honestly, based on what you just posted, you don't need a form generator. You need to develop a simple HTML form on your own, then develop the PHP script to handle the passed information. It is really not that difficult (if you want to do it on your own) but it may take a little bit of refresher training for you.
I would recommend picking up a couple of books/tutorials on beginning PHP. Most everything you will need (save for data validation) will be in a beginners guide to PHP. Or, you can try some things on your own, post here with challenges/problems, and together we can help solve your issues.
I would recommend picking up a couple of books/tutorials on beginning PHP. Most everything you will need (save for data validation) will be in a beginners guide to PHP. Or, you can try some things on your own, post here with challenges/problems, and together we can help solve your issues.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Forms processing is just complex enough that it is difficult for beginners to do, and difficult for experienced programmers to generalize (or at least agree on how to do it).milane wrote:Like I said, I want to do it myself... I work for a nonprofit... ie - we dont have no money.
Not looking for a handout... just a tool I can use to make life easier.
That said the basics are pretty simple. First you need a HTML form, which starts with a form tag that specifies the page that the form will be submitted to and the method (GET or POST). It looks like this:
Code: Select all
<form action="myformpage.php" method="post">Code: Select all
<input type="text" name="first_name" value=""/>Code: Select all
<input type="submit" name="submit" value="Go"/>Code: Select all
</form>Code: Select all
<span style="color:red"><?php echo implode('', $errors); ?></span>
<form action="myformpage.php" method="post">
<input type="text" name="first_name" value=""/>
<input type="submit" name="submit" value="Go"/>
</form>1. Get the values from the $_POST superglobal array.
2. Filter the values to make sure there are no unwanted characters
3. Check that required values exist and are valid
4. If there are errors then display the form
5. If there are no errors then redirect to the next page (this prevents resubmits).
So the PHP code would looks something like this (put this code in the file myform.php):
Code: Select all
// filter the value from the form to only all letters and space
$first_name = preg_replace('/[^a-zA-Z\ ]/', '', $_POST['last_name']);
// check the name based on some rules and set errors if there are problems
$errors = array();
if ($first_name == '') {
$errors[] = 'Please enter a first name. ';
} elseif (strlen($first_name) < 3) {
$errors[] = 'The first name must be at least three letters long. ';
}
// check if the form is valid
if ($errors) {
// show the form if there are errors
include 'myformtemplate.php';
} else {
// do and other processing here, such as saving to a database or emailing
mail('me@mysite.com', 'Form Message', "A message from $first_name");
// redirect to another page if all required fields are acceptable
header('Location: http://www.mysite.com/mynextpage.php');
}There are some other things to add like checking for submit and not showing error messages the first time the page is displayed ... but that's the basics.
EDIT - fixed (strlen($first_name) < 3) per Everah
Last edited by Christopher on Tue Aug 08, 2006 2:40 am, edited 2 times in total.
(#10850)
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Don't you want the name check to be at least three chars long? This
should be
Code: Select all
strlen($first_name) >= 3Code: Select all
strlen($first_name) < 3Just tried this out... it's very nice. You need a little OOP experience though. It pretty simple and well documented, so really it should not be that hard to learn though. I recommend it.The Ninja Space Goat wrote:Never used it... but I've been recommended this a few times: http://pear.php.net/package/HTML_QuickForm/
Yep...very very basic...but it sufficed for my needs at the timed11wtq wrote:Not a small project at all. These things are mammoth in complexity. I think Mark (Pimptastic) once wrote a basic form2sql2form class in Code Snippets on the forum.
It can be found here - viewtopic.php?t=30683&highlight=
Burrito also did something similar which can be found here - viewtopic.php?t=40588&highlight=