Creating Multiple Ajax / Jquery inline form validations in one .php - php

Ok, I am still pretty new to the whole Jquery, Ajax, and PHP side of web design. To be more specific - I am attempting to learn everything all over again after not doing any type of web design for over 10 years lol. I am not looking to have someone write the code for me, all I need is a little push in the right direction. Because I have been searching all over the web to no avail.
What I am attempting to do is create a registration form for my site with multiple inline validations that will validate onBlur. So far I have been able to get two validations to work correctly (checking if the user name already exists in the MySql DB and the password strength) And I am banging my head against the wall at the moment trying to figure out the most efficient way to create multiple validations in one file. My idea is to check if the user name already exists, if the e-mail already exists - and if it is a valid e-mail, check to see if an account exists with a concatenated string of first name and last name, and if the password and retype password fields match. I would like the validation results to display to the right of the text box with either a red x or green check.
Thank you for taking the time to read this, I appreciate any type of guidance
Respectfully,
Paul J. Wesselkamper

I feel like it's to simple because it's so easy but I will give it a try:
You could create the ajax requests in your script posting the user input to an PHP-script every time you recognize an user input.
This PHP-script will check the posted data and send back some information, maybe a code.
In JavaScript you receive this code an show the user what's wrong or right.
Note to check all inputs again when you are inserting them into your database.

Related

I want to set up a form that will send its input data to a database. But I have no idea where to start

This is for a school project.
I have a website. I want this form to send its data into a database, but I have no idea where to start.
I want each field (Title, Name, Email, Inquiry) to be sent to an accessible database where the data is stored.
This is the code I have for the form. As you can see I have a "demo.php" page its linked to but that is empty. It's from a YouTube tutorial that I struggled to follow.
I understand that some level of PHP is involved to achieve this, so I have left it in. Is there anybody that could provide me with a basic guide on how to get around this? Treat me like a 5 year old, as this stuff really confuses me.
Please follow the link.It will explain the whole process of form submission & save in database:
http://www.tutorialspoint.com/php/mysql_insert_php.htm
I would suggest to continue watching videos if that is how you learn best, thenewboston has pretty good videos for beginners. To do what you want you will need to create a database and a file that handles the data before completing a database query which would insert the data.
https://www.youtube.com/playlist?list=PL442FA2C127377F07

Getting info from a random previously submitted php form, after submitting the same php form

I think im kind of a noob here, so im sorry if the question sounds stupid...
I need to create a php form with different fields (eg. name, email, city, etc.), which(the form) after submitting will result in showing the random name, email, city, etc. info with "YES" or "NO" buttons, and if the answer is no, it gets another random info.
The trick is that the info shown after submitting has to be the info, that another person has previously submitted using the first form.
Also, after clicking "YES" the info has to be sent to the e-mail, which was submitted in the first form.
Tried to search for something similar, no result.
Any help is appreciated, if you know a good solution, i am waiting for you reply!
Thanks
You are asking a lot. Show some effort so we can help you instead of making it for you.
You need to try and make the following using tutorials etc before proceeding.
1) Save the info in a file, maybe more then one or a database when a user submits.
2) Get a saved form at random when a user navigates to the form
3) Put info into form
4) Send email

What do I do after the user registers in PHP form?

I'm building my first PHP site, and I've got the registration process working even using the new PDO API, however I don't know what to do when I'm done successfully registering the user?
So, in other words, the register.php page doesn't have any markup, I just used it to POST to so I could build the record.
I'm sorry guys, I just don't yet understand how most people use PHP.
You could handle it in many different ways.
Have one page with markup and one page for handling post. (which is how you have it now). Your register.php page can pickup $_POST variables from your form, validate them and if ok then show quick message showing ("Well done!") echo "Well done";
You can also instead of showing echo "Well done", redirect to another page something like thank-you.php that will just show you have registered message. This is good because if your user tries to refresh the page it will not attempt to generate new registration. (See http://php.net/manual/en/function.header.php)
Handle everything in one php file. eg. If $_POST is empty then show registration form. If $_POST has items, check and validate and show message (either success or please fix following data and show form. (Example here: http://www.html-form-guide.com/php-form/php-form-tutorial.html)
Obviously there is a lot more to sending forms - validation/sanitizing being the major part of it, but since you are just learning basics I think you can forget about it for now. Just always remember to research first and try not to invent the wheel (See example http://php.net/manual/en/function.htmlspecialchars.php to help you with sanitizing)
That's up to you. Generally, you will display a registration confirmation page to let the user know that their registration worked. If you are sending an activation email, now would be a good time to do so, and to let them know as well. Also, a link to the members area from that page is helpful. You can also log the user in directly from the registration confirmation page.

Is there a way to get form requests from a html form post from the past?

So this is a pretty weird topic, but lets just say I made a big mistake while building a site. There is an application form on my website and people basically fill up the form and their entry gets saved in the database. Now how it is supposed to work is that the form is supposed to post to a page that catches the form fields and stores it in the database. However, I forgot to put the file under action. So basically the form has been posting to itself. Bummer. So based on analytics there were about 100 applicants on my site on that day which means that about 100 applicants are lost as the form was posted to just the page itself and not to the page that was supposed to catch form fields.
So is there a way, any way to get those applicants back?
Thanks
The only book I can think of that could possibly help is this: http://www.amazon.com/Build-Time-Machine-Paul-Davies/dp/0142001864
I hate to have to say it, but NO.
Unless you had the form input being recorded in a database, logfile, or other persistent storage, it's lost.
No.
You did not store the data, so it is gone.
Depending on what you are using I would check the logs. I'm not 100% on this but you maybe able to see some errors in there.
If not I think you are out of luck.
In some pretty weird cases you can find some data in your server access log file.
It doesnt hurt to check.

Need a general idea for how to communicate with server PHP script and return error information to client

I have a form that the user needs to populate and then the form will be sent to a server.
After the user submits the form, if the server script found that the form is not correctly populated (i.e. the uploading file is too big), it should return error to the client side.
Now, my question is as follows:
How do I keep the user seeing the same page without transferring to a different page?
Because I don't want the user to waste time to reenter everything again. I just want the user to correct the wrong part.
Because I don't want the user to waste
time to reenter everything again. I
just want the user to correct the
wrong part.
This is a good intention, but the wrong solution.
To stay on the same page would mean you have to submit the form using javascript. While possible, why make things more complicated than they have to be?
Instead, submit the form to the server and when you write out the form again to the user with the error message, set what the user entered as the default value on the form. Then it will be there for them and they won't have to type it again.
Note: Don't do this for passwords tho; the page may be cached and then the users password is saved in a plain file on the hard disk. This is why most sites make users retype passwords each time.
You need to show form again and fill previously entered data in input's "value" fields. Of course, don't forget to replace special characters with html entities with htmlentities();
I also found one tutorial for you: http://evolt.org/node/60144

Categories