Generic form handler script? - php

I've been given the task to turn a couple of forms for a charity into online forms to fill out (stuff to sign up for different programs in the charity). The forms I have been give all just have text input fields and I can make the html version.
I was wondering if someone knows of a PHP script that will handle input from the html forms, and chuck them in a text file or database (maybe not database because the fields may change). It doesn't have to be super feature complete, but the charity does not want to use a service such as wufoo.
If anyone has any suggestions it would be greatly appreciated!

You might want to check out FormMail.
http://www.tectite.com/formmailpage.php
It's a free script that allows you to save your HTML form submissions to a text file (CSV) or have it email the results. There's plenty of documentation/links on the site to help with configuring it.

As over-the-top as this is going to sound, drupal7 has nice form management right out of the box…er, zip file.
If you've already got PHP and MySQL, the setup time is measured in minutes for a basic install. There's also a simple way of creating custom forms and all sorts of configurations to allow you to use the data that's been collected.

Related

How can I use PHP to return database data to an existing HTML page?

I am new to PHP. I know a little JavaScript, HTML, MySQL and lots of non-web computer programming.
I know how to create an HTML page with a form, use a button to call an external PHP file (with $_POST) which sends an email and records that forms data (names and email addresses) into a MySQL database.
Now, I'd like to create a new HTML page that calls an external PHP file (so the code is hidden) that will return the MySQL data (names and email addresses) for display on that existing HTML page (with all its CSS formatting and menus). In otherwise, I'd like to modify an existing HTML page with data (but hide the PHP code in an external file).
If this can be done (I'm new to this), can some please help by giving me at least the general idea so that I can build upon it. The textbooks that I've flipped through simply explain how to "echo" data back to the screen (a blank screen) with a .php extension in the address bar.
Thank you very much for your time and any help. I appreciate it!
Since you already have the html to echo part, you'll just need to plug it into the database.
Using a good ORM can help with this. For PHP, I recommend starting with Propel:
http://propelorm.org/
Once you get a bit more comfortable with that, you might want to try using a PHP framework, like Symfony, to help you structure the project in a more uniform way. However, there are many other PHP frameworks out there, so try to evaluate the top ones before settling on a favorite.
Furthermore, the examples provided in PHP framework documentations will guide you through many of the common solutions (as a framework is just a toolkit built by people who have had to solve such problems over and over).
For example, here is the cookbook for symfony that outlines many solutions to common issues.

Update text on a website by an e-mail

My client is a restaurant that needs to change a paragraph section (<P>) every day for specials.
There are many people that will be handling it so I have to make it as easy a possible.
I don't think teaching the whole staff how to use a CMS is feasible, so I thought it would be a good idea to make something like an email service, that only updates that bit of text.
So in other words the staff would just have to send an email, and the server would somehow change the text on the HTML page for that day.
Can I do this in PHP code maybe?
I am also open to other ideas to something easy, like a simple login system to just change that bit of text.
I wouldn't recommend setting the text by e-mail. E-mail is an ugly, UGLY format to process, especially if it is sent by humans on every type of broken e-mail clients. The half of the e-mails will be invalid HTML, the other half will be tabulated unimaginably, the third half will contain signatures and there are so many more halves :)
And explaining the e-mail format you expect to the staff (utf-8 plain text with no signatures, etc...), and how to set it on their Outlook Expresses, Netscape Mails, and web clients you never even heard of, will be just as difficult as explaining a CMS.
What I would recommend is a simple form instead. If you open the form the current text could show up in a text field, and upon posting back the form you save it's contents on the server.
You would need to store this text somewhere. There is very few servers that host web applications without some form of database backends, so I'm pretty sure you have some kind of database to store your text in.
Also the form would need some kind of password protection. The easiest would be IMHO to password protect the folder where your php is. It's not too hard in Apache.
Check this link: http://www.groovypost.com/howto/htaccess-password-protect-apache-website-security/
I'm not familiar with your experience in PHP, but I hope you can make a form to edit a database record. If not, then please use google, there are tons of tutorials on it.
You could use imap extension http://php.net/manual/en/book.imap.php it allows you to read emails from email box. usualy, programmers create keywords that act like commands to script, for example, if title of email is match pattern UPDATE pageID then it will process email body as content for this page.
This script will be running with crontab, which is scheduler for unix OS. So you can run it every 1 hour for checking new mail.
maybe your client could send an excel sheet and you parse this email attachment on server side with php.
https://code.google.com/p/php-excel/
One option is to use a blogging platform to post the latest specials. You could then use PHP to grab the RSS output (last feed item) and populate the website. This would take care of the form, log in and security part. It also gives the client a running history.
(if you want to go this route I can post an rss reader php script to help you out)
Alternatively, if you decide to go the email route, put the text between something like this:
<!-- PUT PARAGRAPH HERE -->
Here is today's specials.
<!-- /PUT PARAGRAPH HERE -->
Can be anything really, but bookending it with something constant you can search for in the string will help avoid many of the issues mentioned by #SoonDead above. PHP can convert it into something consistent, but you'll need some php knowledge to make it work.

php email edit interface and save method

I've created a simple information system which, among other thins, sends automatic html emails.
The body of this emails is defined by me within the php code, where it is saved, and the automatic routine is done by a cron job.
The problem is that, every time I want to change anything to these standard emails, I have to edit a .php file, since I am the developer and the only one capable of doing it. So, what I want now is to create a simple interface on the front-office of the IS so that the administrators can view and edit themselves these emails.
How can I do this? What is the best save method for the body of this emails (mysql, html file, ...) ? Is there any html editor that I could use in my website?
Thanks in advance for your help.
Regards,
MH
You'd probably be best off saving the data in a database (possibly MySQL), and if you can, build something to edit the content, or use something such as CKEditor or TinyMCE to modify the content.
If you already have a database set up, that would be a good way to do it. For an editor, I have used TinyMCE in the past and it has worked out well.
http://www.tinymce.com/
I would recommend you to store the body on the Database using for example MySQL and then updating it with a form + php.
You can use as Shamil say, some rich text editors such as TinyMCE which will deal with the HTML code to generate the rich text body.

Create form and submit as PDF in dreamweaver

I'm helping my father with some technical stuff for his business and can't seem to find an answer to a seemingly simple task. He has given me several printed forms that he would like to put on his website for clients to fill out, rather than having them do it physically and scanning the form to a PDF each time.
I have figured out how to create the form in Dreamweaver and submit to an email, but I'm trying to figure out a way to submit the form via email as an attached PDF file that shows the contents of the form exactly as it looks on the website (logos, fields, etc.), while saving it with a unique name (such as last name or date on the form).
I have a little experience with PHP but not enough to figure out how to write a script for this purpose or even where to start on a task like this. Any suggestions or advice would be greatly appreciated!
Thank you!
Consider using PDFlib as a PHP library to do this. Refer to This guide to install it. All of the functions I will mention are from php.net
First, you'll need to call PDF_begin_document to begin the document under a specified filename. You may then use PDF_setfont() to set the font to use(Refer to http://www.php.net/manual/en/function.pdf-setfont.php#10254 for the core fonts you don't need to embed, it looks as if they may not support size>12)
Create a page with PDF_begin_page_ext()
You can then use PDF_add_textflow() to add text from strings(Use string manipulation as it is easier then groping 5-subroutine-deep with textflows, I think \n is supported)
End the page after adding your textflows with PDF_end_page_ext()
Be sure to use PDF_end_document() to end the document. When you began the document, it took a filename. You will find the PDF there.

Creating a sticky form in PHP

I am having issues creating a sticky for in PHP. It seems all the samples I can find online are using one pages for both the form and the processor. I have two separate pages. This is going to be a very long form and if a validation fails, and the user has to re-enter everything, they won't, they'll quit. So this is a vital feature for this form. Also, I am very new to PHP and haven't touched ASP for several years.
When all is said and done, this form will probably have over 50 items. It is using POST. What is the easiest way to convert my form to a sticky form?
The current form can be found here: http://family.themajdans.com/new_submission.php. Only the "Your Information" part works right now.
Any help would be appreciated.
I suggest using a framework/library which already has support for this feature to generate the form. There are several. In fact, I think there are several dozen.
Why don't you do it like this (one file PHP)... Make sure everything is well sanitized before doing this. Just filter out invalid inputs, and leave valid ones to be reposted.
<input type="text" name="age" value="'.$post["age"].'"/>

Categories