I am trying to understand if the following scenario is possible:
a .PHP page that has a form and inputs for the user to submit information
The page itself offers several different languages for the user to view it in
The user can change languages but the form and the inputs retain their values (if the user has added information) - so the page cannot be re-loaded (as it would lose the information)
I think this might be achieved using an Ajax solution but I'd appreciate any thoughts or advice.
You actually want to change the page, so reload might still be the best choice. Otherwise you need to change every string on the page with javascript, which can get tedious.
You can do the reload without loosing the data. Just add the language information to the form and send another parameter to avoid the actual action that would normally happen when you send the form on the php side. Render the page in the new language and insert the transmitted data in the form.
Related
I run a website which includes several radio streams. I have set up icecast to request .htaccess account in order to authenticate and start streaming. There is the same account for all streams. I submit the form (it is hidden via css) with jquery once the page loads so the user does not have to know the account nor submit the form.
The problem is that form information are being revealed if user views source. Is there any way to hide these information? Searching the internet what most people say is that this is not possible because browser needs to be able to clearly read these information in order to function properly. Anyone know any way, if it is possible?
I ended up creating the form (document.createElement) on page load with jquery, submitting it (.trigger("click")) and then removing it (.remove()). In addition I obfuscated the jquery code with the tool found here Crazy Obfuscation as #André suggested. That way user cannot see the htaccess username and password in Page Source nor find it using "inspect element" or firebug.
Personally, I need a bit more information to clearly deduct a solution for your issue, I hope you can give me that.
However, have you tried simply .remove()ing the form after submission? That way it gets submitted on page load and then gets removed so by the time the page loads and the user clicks view source, he will not be able to see it. He can, of course, disable JS for example, or any other workaround, but this is a very quick fix with the amount of information we have.
You can not directly hide values in 'view source'. Similarly when the form is being submitted, using tools like 'fiddler' the user could view the values. If you want to really hide them what you can do is never have those values show in the form. You could try techniques like encrypting those values on server or something if it never needs to be displayed to the user in the web page.
I'm trying to make an app on Android that send an URI that auto-populate the "RFC Emisor" and "RFC Receptor" of this web page:
https://verificacfdi.facturaelectronica.sat.gob.mx, if I'm correct those two inputs have the id of:
ctl00_MainContent_TxtRfcEmisor
ctl00_MainContent_TxtRfcReceptor
I already tried this but it didn't work:
https://verificacfdi.facturaelectronica.sat.gob.mx/&ctl00_MainContent_TxtRfcEmisor=123456789&ctl00_MainContent_TxtRfcReceptor=123456789
there is a way to achieve what I want?
The short answer is no. The browser won't automatically detect the URL parameter and pre-populate any form fields. A back-end PHP / ASP.NET page can read the value from the request and generate the HTML fields with the specified values. Alternatively, the page could use JavaScript to set the field values when the document finishes loading.
But all of this depends on changes to the target web page. If you do not have the ability to modify that page, I'm afraid there's very little you could do.
You might be able to duplicate the form on your own page, and send the form data to the target—effectively bypassing the form on the other page and 'faking' your own, but if the target system does some kind of validation to prevent posting forms across domain names, this probably won't work either. You may have create the form and process it yourself, replicating the entire form interaction programmatically when a user submits a form to your server. In any case, none of these options are particularly graceful.
I have a database app written in PHP (jQuery/JS on the front end) that has bilingual labels/text. Currently one can only change one's language on a maintenance page (form submission, then PHP updates a session variable with their new language choice), but the users would like me to add a language pulldown that would appear in the corner of all pages. When the page contains a form, I don't want users to lose their partially entered data if they happen to change the language, so I need to save/restore the form data somehow. Is there an easy way to do that? I know I can use jQuery to serialize the form, but then what? Send that added onto the URL and pick it up in PHP? Then what? Write some routine to loop through the form fields and handle them properly (inputs, selects, radio boxes, etc. are all different)? It seems like there should be an easier way. I don't mind restricting myself to HTML5-supported solutions or adding jQuery plugins.
How about localStorage?
If user has filled any input fields, save them to localStorage and delete the data after user submits the form.
My suggestion is to:
Submit the Language and any wanted user data when changing language to the server using $.ajax or $.post
i am really stuck here i have been trying and i am posting here hope some one will help me.
i have a html form where i enter my data and before submitting i need to view my data in the html form and if i need changes change it rt there and submit .
i am able to enter data and how do i display the data without submitting.
To preview your form data before posting you have two options basically: the first is to preview it by using JavaScript to dynamically open a new window and then show your data formatted as you want, the second is to post your data to your server and return a new page containing the data you posted but not yet being integrate to your database, this is a kind of confirmation page, whatever is the option there should be a confirmation button to accept or reject the submission and integration of the data in your database.
The second option requires you to create a new page on the server side for confirmation (preview), having all the power of your web server language.
In general, you have a Preview button and a Save (or Post) one.
The Preview button submits the data which is processed by the server-side script (interpreting markup language, or filtering HTML or other stuff) and converted to HTML, then sent back to the user along with the text field with the raw data.
Then the Save/Post button does the same, but saves the data to the database, and similarly output the HTML, without the text field.
A quite generic answer to a quite generic question...
The question that comes to my mind is how this preview would look different from the data entry page. I mean, if the user is supposed to enter, say, name, address, and favorite color, presumably that data is visible on the screen as they type it. What would a preview do? If you're talking about some sort of validation, like color must be on your list of approved colors or some such, then you have two basic choices: You could do the vaildation with JavaScript before sending to the server, or you could send to the server and let it do validation. I would point out that if you do client-side validation, you really should still validate on the server, esecially if there are security or hacking issues. You have no assurance that the data stream sent to your server really came from the page that you sent to the user. The user could create his own page to send data to your server.
The only other thing I can think of is a formatting preview, like here on Stack Overflow where what you type in may include codes that control format. In that case you might want to use Javascript to give immediate feedback, again, like is done here.
perhaps you can have two buttons one as a preview and one as submit so when u preview it sends the form value in a different page and displays it in a format you want.
The submit button will just do the submitting etc. what u plan to do .
hope that helps
I am trying to figure out a way that I can populate form fields on webpage for my users much like password managers do. The problem is that I am not the owner of the second webpage. I thought about using javascript with iframes but that doesn't work. I've tried using php to replace the form information adding values saved from my previous form. But I need to add info on a second form after the first one is submitted. After I submit the first page I am off my page and can't change anything else. So I'm kinda out of ideas and my knowledge is limited. Any ideas or input would be greatly appreciated. Thank you for your time and effort.
Cannot be done because of the SOP (same origin policy) enforced on JavaScript code. An alternative would be through XSS, other via a bookmarklet, and as a last choice trough a GreaseMonkey script.
GreaseMonkey may be your best choice, if the data to be filled in is from your website. Best choice because GreaseMonkey scripts can perform cross domain ajax requests.