PHP text box replace with variable - php

I'm creating a small customer database that allows me to send an email.
So what I would like to do is, click a link that opens a page with a big text box.
Within this text box I'd get a preformatted HTML mail, that I can adapt if I want.
When I process the form text box I would like to search for all the variables that have been written in the textbox. (because besides plain HTML I would like to be able to use variables where I want within the email)
I want to be able to write the variable in my text box between << some_variable >>
Then I would like the processing page to search for all text between << ** >>.
And replace it with $some_variable.
(off course we would know the syntax off the variables up front)
So for example in the html form input box I would like to type this:
Hi <<First_Name>>,
You registered for course <<course_number>> <<course_title>>.
Total to pay <<Total_to_pay>>.
Thanks
but I would also want to be able to change the format whenever I want.
So example:
Hi <<First_Name>>,
Your course <course_number>> <<course_title>>, will start tomorrow.
Dont' be late.
Thanks

You can post or get the input value to session and set the session result as a first_name

Related

Adding elements to a table from an input area

I am trying to have something like the image below in my PHP page.
(The links are in the comments. I was unable to post them here properly)
Once I enter the keyword and hit the "plus" it should appear in the table, along with the color to the right. The sequence of colors will be predetermined. If I enter a keyword again and hit the "plus" again, the keyword should appear just below the earlier keyword int the table. For the time being I am assuming the table consists of 5 rows and there are less than or equal to 5 keywords.
Also I want to have a submit button at the bottom that when clicked should send all the keywords now present to a PHP file. I have a form with the action attribute set to a PHP file. The table and the keyword input field are to be a part of a form.
I prefer using javascript and not PHP for many complications. Is there a way I can store all the keywords and then send it to the PHP file once the form is submitted?
Any help would be greatly appreciated.
You could:
Build the html form with five text inputs, all stacked on top of one
another (I think using position: absolute).
Place html table underneath inputs.
Place submit button underneath table.
Use javascript to:
hide the four text inputs that aren't currently being used
display the text input and corresponding color in the table when the user presses the +.
hide the current text input and show the next input when the user presses the +.
When user hits submit button, all five input values will be submitted to action='*.php'

Displaying javascript variables and database values?

Is there a way to display javascript variables and mysql values in a sort of label? As in say you have a letter template and there are spaces in the template where values from a database should be inserted but not in a text box. Here is a screenshot of what i am trying to explain :
The letter on the left is the template and the blue coloured text is where the database values need to be entered but in a format that would suit the letter template which will be printed and mailed out, so it couldn't be a text box, is there a way to display it in this manner?
Here is my current code :
Also is there a way to display that section of javascript in the same manner? Where it says [server date] in the template?

I want to move a value from one text field to another text field in one html page using codeigniter

I want to move a value from one text field to another text field in one html page using codeigniter. here we can write something or fetch something from db into the first text area. i dont understand how to do that ??
While your question is far from clear, this will probably help to get you started.
You can use CodeIgniter sessions, PHP sessions or just post the value using a form if you need it sent from one page to another.
However, if you need to copy values within a single page, something like this will do (and has nothing to do with CodeIgniter).

Save cursor highlight position in text

I need to display a document (like in a Google Docs style view) and provide the ability for a user to make comments on that document.
Here's how it needs to work:
When the user views the document, they can use their mouse to highlight any amount of text they want (as they would within any other webpage)
Upon release of the highlight, some sort of modal dialog box appears asking them what they would like to comment on that portion of the text they selected
After clicking save in the modal box, their comment is saved in a MySQL database along with information about the section of the text they highlighted
Another user can view this document and see their comments on the different parts of the text.
I don't know how to tell the database what section of the text is highlighted so it can reference that and show the comment on that section of the text.
Not sure where you're getting stuck at but the basic idea would be:
Get the selected text using Javascript (see http://www.codetoad.com/javascript_get_selected_text.asp for an example)
Submit that text to a PHP script using either an HTML form or an AJAX approach (AJAX would probably be what you're looking for based on the description of your app).
Take the text passed to the PHP script and insert it into the db.
Party like a rockstar.
In Javascript:
var selectedText;
selectedText = window.getSelection();
I'd suggest some kind of character-index-based approach. I've answered a similar question recently here: execCommand insertHTML breaks stored window.getSelection()

Editing information from a MYSQL database from website frontend.

I wonder is someone can help, I'm building a website, which is driven from a database. It will consist of user submitted information.
Currently all the information is pulled from a record in the database and is being output via a PHP echo, what i would like too do is add a feature that would allow me to edit the information if incorrect from the websites front end.
I have seen many websites have some form of edit icon next to information in there databases, when clicking this icon the echoed text changes from text to a text field and you are able to update the field being echoed from the database.
Im a designer so have limited knowledge of how functionality for this kinda feature might work.
please could anyone let me know how something like this might be achieved.
many thanks.
You would need to build some kind of javascript functionality to allow the in-place editing of those data bits. One possible solution is a jQuery plugin like jEditable.
Then you need to build a server-side script in something like PHP or ruby where it would take the submitted information and update the database.
well the process is the same for the front-end and back-end. it depends whether you want you build a password protected editable forms or just editable for everyone.
One way you can do this is
echo your information into text inputs
give them a css class that removes the border and makes it transparent
make it readonly(so someone couldnt tab into it and change it)
add a javascript onclick event that changes the class to a normal
text box that is not readonly
add a javascript onchange event that uses ajax to save the new
information into the database when they are done typing, or press enter
after the ajax is done turn the text box back to the first css class
EDIT also add a onblur event that changes it back as well
you could even change the cursor for the text input to a pointer instead of the default (text) cursor so that is looks like you can click on it.
.
now html5 has contenteditable attribute which you can set for elements
simple example:
www.hongkiat.com/blog/html5-editable-content/
simpler demo:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_global_contenteditable

Categories