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.
Related
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.
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.
Im setting up a web form, and I'm trying to have it where visitors can paste their resumes into a text area. Then I want to email the info using php mail().
But the resume info is just stored in the variable as one long string with no formatting.
Is there a way I can send the pasted resume text to the client in the resume format? Maintaining all the line breaks and stuff?
He wants to avoid having people upload resumes.
A tinymce-like editor would be good stuff.
The simplest and fastest, though, would be to use things like http://php.net/manual/en/function.nl2br.php to keep the line breaks. It should do regarding that.
You would need to look at some plugin like CKEditor or TinyMCE. What you will get back will be an HTML representation of what got pasted in. Be warned, though, that this will not be an exact representation (and probably can't be!).
Another way would be to have them save it in a portable format like the new MS XML, or the old RTF. Then you can keep the formatting and use xslt or some other parser(or translator) to build your own version of the resume.
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.
I have a PHP page powered by jQuery. A singel page has four steps, controlled by jQuery.
In diffrent steps, user selects two Images from two galleries (step 1 & 2), fromats a table by arranging divs inbetween (setp 3) then filling a form (step 4).
I want: when user clicks "Finish" on step 4. All the above information be converted to PDF and emailed to the provided email address.
Please suggest me idea, tool, plugin or code to do so!
The last time that I tried to auto-generate PDFs as you mentioned, I used a php library called fpdf. As I recall, it was difficult and cumbersome. My lack of knowledge/experience/patience definetly made me not have much fun working with it. Give it a shot and see if looks like it is feasible for you. The site has some getting started examples, and a quick Google search should yield some examples too. URL: http://www.fpdf.org/
I just stumbled across another library that looks promising: http://code.google.com/p/dompdf/ I have not used it, but, if I need to do this again in the future, I would try this before going back to fpdf.
I don't know of any javascript/jQuery plugins that can generate a PDF, so I think you are stuck with PHP in this scenario.
Hope that helps a bit!
EDIT: The email part is simple, I really like Swift Mailer: http://swiftmailer.org. It is simple to use, lots of examples, and supports a variety of options, like, attachments. Also handles the encoding issues that generally plague emails sent directly from php mail().
One more thing, if you are not too far into development, take a look at using Kohana as a php framework. It's light and easily extensible. They follow decent coding standards, and have an active open source community. Plus, there is a module for SwiftMailer that almost sends the mail for you-Not really...but I think you get the point. ;)
Have a look at http://andreasgal.github.com/pdf.js/