Populate sign-up form field with an uneditable/undeletable sentence - php

One field in our website's sign-up form is occasionally left blank yet we need it to include one sentence that for legal reasons must not be editable. This is then later used as part of the user's profile and will sit in the same place if they added content to that field too during the initial sign-up.
How can we populate this single field with an uneditable/undeletable sentence, yet allow text to be added above it if the user chooses to?
Currently the field in question looks like this:
<textarea name="description" id="eBann" rows="2" maxlength="1500" cols="20" onKeyUp="toCount('eBann','sBann','{CHAR} characters left',1500);"><?php echo $description;?></textarea>

Why don't you just use the input for the optional extras and put the uneditable part in the HTML directly below it? For the prompt use something like: "Here's our sentence, if you want to add your own comment, enter it here." In the form processing script, just concatenate it with the static sentence.

Any HTML form can be changed by the user (even if it says readonly). The only way to do this safely is either server-side when they submit the form, or server-side when you get and output the information.
EDIT:
With dual languages (I'm assuming human language, not programming!), you'll definitely want to output the string with the rest of the information, and never store it in a database. That'll help you in case you ever want to change what the string is, and also will allow localisation for different languages.

Related

How to prefill text without user´s possibility of deleting it

is there any way to prefill textarea with link of page that user is trying to share but so that he can´t delete it. I am talking about sharing form via email.
The form is obviously done in php.
Edit:
I used the field Edit Summary but I don´t see it anywhere so it may be here twice I can be blind :D
The onlyread function is not what I´ve wanted. User is allowed to write into textarea but the part of the text hasn´t be touchable. As junkfoodjunkie said it seems like the only way to do it. But still posting some advices if you see the whole code may change it.
most inputs can use readonly="readonly" to prevent predefined values from being edited.
<textarea name="verbage" readonly=readonly cols="5" rows="9">
Can't touch this
</textarea>
<input type="text" name='moreverbage" readonly=readonly value="NO EDITING ALLOWED">
If the mail sending is done via PHP, just have that default text be part of the server-side send-mail script, and put it in if the text in the message / textarea doesn't contain the default text. You cannot trust client side solutions, and all of the solutions mentioned above is removed by a simple code-editor (Firebug, for instance), before clicking submit.
Check the content in the mail-sending script, and if the default text isn't there, either replace or add/prepend the text you want.

Joomla 2.5- MyPHP Admin MySQL- "Special Characters" are not going away when posting to article

I am very new to this. I have a Joomla website and want to do something simple. Using FormMaker and Artetics ArtSQL, I want to have users enter information into a form, then have the information displayed in an article.
HOWEVER... When information is entered into a form, the information that is sent to the MySQL database isn't always correct. For example, I see br instead of multiple choice answers.
When the information is displayed using ArtSQL, the funky letters show up also. I CANNOT figure out how to get rid of these special characters. Can someone please help? Thank you.
Without knowing the extension, this could be achieved by putting the test variable through the strip_tags function in PHP. You'd need to add something like this to the controller file before it gets inserted into your table:
<?php
echo strip_tags($text);
?>
It will remove the tags from the string, like the <br> tags, and other HTML elements.
If you're not sure what you're doing, it may be better contacting the third-party that created the extension, as has already been mentioned.

How to convert <br /> to newline on Pre-populated textarea

I am having issues with <BR /> tags appearing inside of a pre-populated textarea form (with no breaks obviously). So these break tags need to be converted to /n within the textarea. This prepopulated text is being retrieved via the URL which also appears to have the break tags within it as well.
Basically what is going on and what I need:
I am having to get a block of text from the previous page (which was originally pulled from the database) and load that block of text into a textarea field on the form submission page. The user then fills out the rest of the form fields and submits the form, this information is then stored into a specific table in the database.
In order to get the block of text to display properly on the first page, I had to use nl2br to get this section breaking properly on the page. Obviously, now it is outputting that text with breaks instead of new lines.
This means when you click on the link to populate the form on the next page, the link has break tags in it, which in turn gets displayed inside of the textarea field on the next page as well as in the URL.
I am confused on what I need to do to replace those <BR />'s with /n again. It seems like I could use str_replace or preg_replace, but I have yet to find an example of how to use either of those in conjunction with something like:
<textarea rows="10" cols="50"><? if(isset($_GET['text-property'])){ echo $_GET['text-property']; }?></textarea>
Keep in mind that I am still in the process of learning PHP, so I really need specifics and preferably examples if at all possible.
Thanks!
You need to use preg_replace,
<textarea rows="10" cols="50"><? if(isset($_GET['text-property'])){ echo preg_replace('/<br[^>]*?>/si', '\n',$_GET['text-property']); }?></textarea>
Demo

Data is not pulling from mysql db into php app - textarea field issue - maybe?

Think I need to come at this from another angle now - I have an issue that I originally blamed on tinyMCE [and part of it was related to tinyMCE], but now after much research, I 'think' this new issues has something to do with Textarea field limits, db field limits, something...
I have a php web form, in addition to the other fields, there are three text area fields, that allow the user to enter comments that will display at the top of the form, end of form and on thank page. TinyMCE is attached to these fields, so user can format their text. After resolving the funky chars that were appearing in my db because of Word copy/pasting, the issue I now face is that after the text has been submitted to the db, if it is very long amount of text, it will not pull/display on the php page.
For example, I enter a 100 word paragraph, save it to the db, open the web page, I see the text. Now if I add 1K words, 2K words of text, nothing appears on the web page, not even the div border that I have set to encase this text. It's like nothing is in the db field, but if I go to the db, to that field, I see all the text. Then if I remove 90%, 80%, etc of the text, update the db, open the web page, the text is then viewable.
I have changed field type from "text" to "mediumText", increased column in the textarea field to 40 from 16. Nothing is working. What else do I need to consider, do, try, etc?

What is the point of input without name in HTML5?

In HTML5, an input without name is also valid
e.g.
<input type="text" id="user" />
But what is the point if I cannot access the form element in my backend PHP code?
Not all input is used server-side. In many cases it's used for form submission via AJAX. Additionally, a JavaScript app can make use of user input without ever needing to use a form.
Click the "link" button on any question or answer here on Stack Overflow, you will see an example of an <input> without a name or associated form.
Granted, this particular input is created with javascript - but it's pretty common to see an input field or textarea for copy/paste purposes, for one example.
..and it's also useful for basically anything to do with javascript.
One non-AJAX example I am currently using:
I have a spreadsheet for several dollar amounts to be filled in. I use an <input> field with no name to display the total amount of each column with javascript. On the server side, I don't need a "total amount" field coming through, and I sure as hell wouldn't trust it. The real total amount is calculated on the server side based on the other inputs, but we still show it in real time on the front end for the user.

Categories