PHP/HTML5 : How to Retrieve User submitted form? - javascript

i'm a beginner programmer who have to provide huge project very soon ..
i have a dynamic website
The problem is that there is an html form on it as the page which allowing the user to making his post "create.html" : write a text in the Textarea and upload an images or video too
well, i'm sure this request sounds very stupid but i'm really so confused ..
i have my own database, and what i want to do is when the user submit his form, all of that inputs should be published on the Index page "index.html" also the " comment, like ..etc." buttons should appears bellow the post
here is a pic for the index page and how the post should be:
index.html
i need an explanation to do that more than a real codes i think, and sorry for my bad grammar i tried my best
hope you could help me :( i'm ready to pay $$

Related

Wordpress: Querying a database from within javascipt / jquery

I have a simple postcode search in my wordpress site. The user enters a postcode, clicks search and the browser directs to a new URL based on the postcode entered.
Presently, I have a large switch statement in the onclick handler of the button, which parses the postcode input in a text box and generates some display text and a URL which I then launch using window.open.
It works OK, but as I add more and more postcodes its bloating the code loaded into the browser and it's all visible in dev console. I'm also limited when it comes to making changes as I'm having to go in and modify the code to implement logic directly in my onclick handler. It's a bit of a mess!
What I would like to achieve is to store all of the relevant information in a mysql database, query the DB when the form button is clicked, and then launch the URL which will be returned by the db query (well, there'll be a bit more logic in the server script than that but ultimately I'll just be returning a URL and some text).
I'm struggling to get my head around how to implement this. It appears the DB queries need to be in PHP on the server and has to be queried asynchronously? I'm getting lost down a rabbit hole of AJAX which I'm struggling to understand!
I'm not looking to asynchronously update content on my page - at the point that we're running code in the onclick handler, we're ready to launch a new page based on the postcode entered. It appears the required solution is a little more complex than I hoped it might be.
Can anybody suggest how I might implement this? Do I have to use PHP & AJAX?
Thanks

Custom email validation Firebase Action code

I am working on a Application with firebase. I want to validat a users email, but since Firebase doesn't allow to change the verification message (To help prevent spam, the message can't be edited on this email template), i can't use this. I don't want to serve English text to my users.
Is there a way to get/generate a custom ActionCode? I used this tut https://firebase.google.com/docs/auth/custom-email-handler it might solve the problem is i can get the temp actioncode somewhere.
I found applyActionCode and checkActionCode (seems the same) but not something like createActionCode
Ask for it...
Nowadays the best procedure (with just 1 step) was for us to develop an HTML file with the exact content for each of your templates (Email-Verification and Email-Change, including even the snippets %...% in the right place) and send them as attachment in the Troubleshoot form as mentioned by Alfonso in the comments of this question.
If you send the exact email HTML template file, you leave Google's people with no questions for spamming purposes other than quickly validating your HTML content and approve.
you can change the language for all the templates, at the bottom...
also you can edit manually the body and the subject for the forgot password template
You can customize the email validation template text as you wish? Right?

Qualtrics and Auto authentication

So, I feel like I'm really close to a breakthrough here but moving forward is going to require some help.
I have a survey, we will call it "test".
To get to the survey, you click a link that has your email included as a jscript passthrough (e.g., https://osu.az1.qualtrics.com/SE/?SID=SV_abcdefg&ID=john.doe#emailtest.com)
I want to autoauthenticate john doe against a panel.
What I mean by that is that I want to use an authenticator that doesn't require a person to enter any data, but uses the data in the URL as an authenticator. You would think this can't be done, but I've also learned that you can run javascript in the description field by looking at:
https://sites.google.com/a/cognitivescience.co/research-using-qualtrics/home/functions-capacities-in-qualtrics/using-qualtrics-as-a-personalized-web-service-with-the-authenticator
However, all that does is change the label for the field and doesn't actually authenticate. It does, however, process the next button. This suggests that if I can fill in the authenticator with the embedded data passed through the URL using JavaScript, I should be able to autoauthenicate.
Any ideas?
Strange example; I don't see how it ever would have worked. Anyway, if you add the embedded data field ID to your survey flow before the Authenticator, then you could put a script like the following in label field:
<script>Qualtrics.SurveyEngine.addOnload(function(){$$('.InputText').first().value="${e://Field/ID}";$('NextButton').click();});</script>

Simple HTML form into SQL DB using PHP, getting hammered by bots

I have a very simple HTML form which is for pre-registering for my car show. Unfortunately it has attracted the attention of spammers because there's an "address" field which they use to inject their spam URLs into.
I've added javascript form validation which says if the address field contains any slashes (like "http://") then it pops up a box telling spammers to go away.
I've added htaccess that I thought was supposed to stop users from being able to hit the PHP file which is used to submit the form into the DB without coming from my domain first.
I had recaptcha, but they were able to get around that as well so I removed it since it wasn't effective.
I know one flaw is that I can browse directly to my PHP file and it will insert a blank row into the database - how can I prevent this as well?
Does anyone have a good site or steps to take to stop these bots from hitting my form?
ReCaptcha, if well configured, should have solved your problem. There's no easy way to "go around that".
I've added htaccess that I thought was supposed to stop users from
being able to hit the PHP file which is used to submit the form into
the DB without coming from my domain first.
That's probably your problem. The bots are problem just calling the registration page with the right parameters. One way to get around it would be to display a hidden input field on your form, populate it with some random value, and check that you get the same value when the form is submitted.
But again ReCaptcha should work... if it doesn't you should ask a specific question about that.
first of all, validate the data that are send from the Form, check them if are valid, not empty. etc. If you are using a framework those have validation classes(use it), else create some,
second put back the captcha and don't send any data to the server if this isn't valid

Display form result in same page with only client-side script possible?

I have a bit of a tricky work problem I hope to get some help with.
To handle various forms and storing entries, we use an in-house tool which I cannot modify. Basically what happens is:
I enter he URL the original page, and the URL of the destination page after successful submission.
The tool spits out some HTML and Javascript code, the most important of which is a unique URL, let's call it (redactedURL), that goes after the action attribute.
When the form is submitted, the page will refresh to one of two possible destination URLs: the one I inputted if success, or (redactedURL) if error.
I can download all the entries from the tool afterward.
The HTML is quite simple. checkform() is a simple validation script.
<form action="(redactedURL)" name="enenForm" method="POST" onSubmit="return checkForm()">
The issue with this is that I can't style the (redactedURL) error page, which is quite ugly. I am wondering if there is anyway I could
Suspend automatic display results of form submission
Determine the destination URL, and based on that, write out a custom thank you/error message (since I cannot access the server-side script, this seems to be the only solution to determine if the submission is successful or not).
Make sure that tool still properly stores all the entries.
Any help would be much appreciated. Thanks!
Don't use a form. Instead use AJAX. I think this SO Question will provide a start. Basically you use JavaScript to submit data to a server using XMLHttpRequest. The returned HTML is a string which you could either modify or (better yet) normalize and add to the DOM.
For an advanced example jQuery-Mobile does this concept when you click a link instead it gets the HTML from the server as an AJAX request copies the HTML inside the <body> and inserts it into the DOM.
Search for tutorials about AJAX and jQuery (or your prefered JS library). Like this one.

Categories