Check Table Value exists without Javascript, is it possible? - javascript

Is it possible to check if username and email exists in a database using procedural MySQL without using JavaScript?

Yes, it is possible.
This is all that can be answered to your vague and too broad question.
Javascript is totally irrelevant to whatever database stuff. An is not required for the server interaction, you can do anything without it. Just learn basic HTML and PHP. Send a form to server, do whatever you want in PHP, then send the response to the browser.

Related

Saving and retrieving data on server with Javascript & PHP

I have a form on my website that I want to ensure each client only submits once per year.
To do this, I would like to save the client's id # and the current year to a .txt file on my server when they submit the form.
When the form is submitted, I also need to check the current contents of that file to ensure their id has not already been recorded, and display a message if they have already submitted the form that year.
I believe I need to use PHP to do this, but I'm brand new to PHP and I'm also not very experienced with jQuery. Any assistance would be much appreciated!
Using a simple database would be much better, because it will be easier to retrieve the stored data later on. There are more than enough tutorials if youre not familiar with databases (use mysql database if you have few experience with databases).
If you use a database you can also store the submitted data from the form very easy.
As Dan already said, first learn PHP and database connects and querys and then jQuery (which you dont need for putting data from a form into a database, but with ajax its cooler (you dont even need jQuery for ajax, vanilla javascript can also do that for you) ;) ).
Just google everything, there are more than enough tutorials online.
If you don't want to use a database, probably the simplest option will be to rename the received file with clientId-currentYear when you put it on the server.
For example, when a user submits a file for client 12345, you will have to check if a file 12345-2018 already exist. If it doesn't exist, you can create it, if not, you send your message to the user.
This is going to be easier to manage than a text file or a database if your programming level is low.

Sending an email from Create-React-App contact form

I am working on a website that I used create-react-app to create.
I need to make a contact page where the information entered will be sent to a specified email.
After doing some research I discovered this is going to require me to setup some back-end. I am very unfamiliar with back-end programming. I know about nodejs and am somewhat capable of setting up a basic server using that, but I have no clue how to connect it to the react site, or if I even need a node server (just mentioned it because I found Nodemailer).
What's a good back-end setup I should use? All I need to use it for is sending an input field's value to a specific email.
I'm sorry this is such a noob/vague question, I am just looking for some direction on what to start researching and learning. I don't expect a detailed answer on the purpose and precise operations of a back-end server, just some helpful guidance or somewhere to start learning!
Any help is really appreciated!
I can think of two options to connect to the back-end to send an email.
API: You create an endpoint on your backend (i.e. https://yourdomain.com/api/sendemail). Using expressjs, or some other server side library, you create that endpoint to receive a POST request. (https://expressjs.com/en/starter/basic-routing.html) You then use the front-end (fetch: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch) to call the endpoint with the data needed in the email and in turn the endpoint calls your send email function with Nodemailer or whatever.
Form Submit: The other option is similar to the first in that it sends a POST request with the form data to the back-end. This requires that the server send back a new page and your browser will then reload. Where as the first option can be done without a page reload.
Not an expert on this but those are the two options I know of. Good luck!

Is it possible to automatically post a client's form from server side?

I did do some research before asking.
Submit form using only PHP? Without JavaScript?
I understand form submission is a client thing. People who answered the above question all rejected the possibility of automatically posting a form without JS. And they did have their points.
I believed they were right until I came across this article recently:
One who asked the question and the other who answered the question, in the end, they both confirmed that automatically post a form using PHP solely is workable. I tried to play around with their code but got a 408 error. Chrome says :
Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources. SecurityError
This article was pretty old though, so probably this solution used to work but it no longer suits modern browsers? Who was wrong?
If you already have the required data in your script at that point where the form should be submitted, you can use this answer how-do-i-send-a-post-request-with-php#6609181.
Otherwise you have to make you question more certain:
where the data comes from? what type is it?
what is the form
receiver? (for example, there are sometimes CSRF checks)
are you sure
you need to submit a form, not just make a POST request?
When you say "posting a client's form" it does the following things:
Initialize form submission with data in the form fields via browser API.
Send the POST/GET request to the destination server.
The step 1 can only be done in a client side - because the data is in the browser and PHP has no part in handling the browser when the page is fully loaded.
But step 2 can be done using almost any language and make the destination server record the data via TCP sockets. PHP is just a candidate here.
What your second article does is this.

How can I pass data from one page to another in PHP and Javascript without from?

How can I pass data from one page to another page in PHP using Javascript without from?
In my blog have a post comment with email Id
and this is routing using foreach loop
problem occur when get email id and comment
how can i do this? plz help
you can make use of client side cookie for this. one page you create cookie and on second page read that cookie.
I guess that what you dislike with forms is the page reloading on the client side.
If that is the case then you can use ajax requests (maybe with the help of a framework like jQuery, or pure javascript with the xmlHTTPRequest()).
Alternatively you can use cookies, but it's not what they really are for.
If you don't mind the page reloading, you can also use HTTP GET requests with javascript :
location.assign("http://www.my_site.com/index.php?param1=value1&param2=value2");
You can also store data in Web storage if the data doesn't necessarily need to be processed in PHP.
You will need to have a backup system in cookies though for the older browsers that do not support his.

Any way to save HTML Form data to database without webserver/sql?

So currently i'm buidling a local website within work.
one of the feature that needs to be built is a request submission form.
We originally had this email to a central mailbox but we want it to take the form data and save it to a database in this case Access.
Is there any possible way of doing this without using SQL or ASP ? As the website is being build on a local server for all members of staff to access.
In the end all I want to do is create a form the user can submit which is sent to a database. Is it possible or would it be better to stick with the email idea?
It is not possible to save data without a database server. Only thing can be done is cookies in javascript but these will not be available always and will never help you cause..
First of all I would like to say that html/css is client side scripting language, without using server side language you can't save anything. You can use php or javascript(ajax) in order to do that.
Unless you are targeting Safari browsers, you can try using IndexedDB(http://caniuse.com/#feat=indexeddb), a form of local storage supported by major browsers, with no size limit. It can be used carefully to emulate a remote database using a JavaScript object relational mapper.
I strongly suggest you a server :). If you don't want to use sql there are many ways to save data. The simplest would be to write a file on disk with what you need.
Only under Internet Explorer, you can save data into MS Access database for example using ActiveX. But html file must be open locally.
Edit:
If needed I can write you a sample code.

Categories