maintain formatting entered into an html form? - php

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.

Related

how do I find out what php function from Wordpress is generating blocks of HTML using browser inspector?

I'm developing a Wordpress site, which I'm fairly new to. I'm not sure if this is a stupid question or not but I haven't been able to return any decent google results regarding this. Anyway, is there a way to find out what PHP function is generating a piece of HTML code using a browser code inspector like Chrome's? Thanks!
No.
Once the data arrive to the browser, all the PHP code have been processed and you can't know what part of PHP generated which part of the HTML code.
No - not without modifying the php code to enable some kind of debugging. Chrome can only give you information about the received html document on the client side (you). But php code gets parsed server side.
You kind of can:
Download a copy of the theme and plugins folder
Open the page on your site that you want to find the function for.
Find a div/class that is specific to section e.g. <article>
Open a text editor like notepad++ (one that will allow you to search through multiple files at ones)
Use the find feature of chosen text editor and search for the div/class
The result will show you a list of pages where that term is.
Look through those pages for the function you are looking for (it might take a few goes)
The above it is a bit of a roundabout way of doing it, but I think other than looking through each file separately, it is you next best way.

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.

How should I store textual data that won't change very often?

As an exercise in web design and development, I am building my website from the ground up, using PHP, MySQL, JavaScript and no frameworks. So far, I've been following a model-view-controller design. However, there is one hurdle that I am quickly approaching that I'm not sure how I'm going to solve, but I'm sure it's been addressed before with varying degrees of success.
On my website, I'm going to have a resume and an "about me" bio section. These probably won't be changing very often.
For my resume, I think that XML that can be rendered into HTML (or any other format) is the best option, and in that case, I could even build a "resume manager" using PHP that can edit the underlying XML. A resume also seems like it could be built on top of MySQL, as well, and generated into XML or HTML or whatever output format I choose.
However, I'm not sure how to store my about me/bio. My initial idea was a plain text document that can be read it, parsed, and the line breaks converted to paragraphs. However, I'm not sold on that being the best idea. My other idea was using MySQL, but I think that might be overkill for a single page. What I do know, however
What techniques have you used when storing text for a page that will not change very often? How did they work out for you - what problems or successes did you have?
Like McWafflestix said, use HTML, if you want to output HTML. Simplest case within PHP:
<?php
create_header_stuff();
include('static_about.html');
create_footer_stuff();
?>
and in static_about.html something like
<div id="about">
...
</div>
Cheers,
Just use a static page, if the information won't change very often. Just using static HTML gives you more control over the display format.
Generally treating infrequently changing information the same as frequently changing information works well if you add one other component: caching.
Whatever solution you decide on for the back end, store the output in a cache and then check to see if the data has changed. Version numbers or modified dates work well here. If it hasn't changed, just give the cached data. If it has changed then you rebuild the content, cache it and display.
As far as structure goes, I tend to use text blobs in a database if there is any risk that there will be more dynamic databases. XML is a great protocol for communicating between services and as an intermediate step, but I tend to use a database under all my projects because eventually I end up using it for other things anyway.

Categories