All you have to do is include code that processes both the database information and that does the validation that you want on the same page (regardless if it is in database.php or to the very same page. So by redirecting the user to the same page, you are giving the browser a chance to reconnect with the server of the website so that It can pass the information you placed in the form. That way, your message is sent to the server, the server can see the input from the form, and process it. When that connection is made, the form tells the browser: "send this information to this page and redirect me there to". Since you no longer have a connection, your browser will have to create another connection when you hit the "submit" button on the form. If you load a page that has a form in it, after the page has loaded, you no longer have a connection with the website (there are exceptions like when using AJAX code). Well that has to do with the passing of information. You might ask yourself "but why does code exist that redirects you to the same page?". That just means that you want to send the form information to the same page and you want to redirect the user to the very same page. If you use the following however: " method="POST"> That just means that you are going to send the values that were inside the form to the page database.php, and at the same time, you will be redirected to that page. If you write the name of a file in your action attribute like so: The action="database.php" or action="" just refers to where you want the form information to be sent, and does not limit you to how much you can do as you are suggesting with your question. Do you have any suggestions please?Īnd this is the code for the validation in PHP: I need a function which can combine both as I need to do both for my website. The form is allowing me to store data in the database whenever I write action="Database.php" and allowing me to validate the user input whenever I write action=. The problem is, that the form is not allowing me to do both functions, as there can only be one "action" in the form tag. Such as checking that characters only are entered in the Name text field, etc.I have also managed to do this correctly. However, I also need to validate the data input by the user. I have created a form, and the data entered into this form is to be stored in a database. I am creating a website, and part of the website should be a Bookings section.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |