Jump to content

thezeroandone

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by thezeroandone

  1. Hi mac_gyver. Thank you for such a detailed and helpful response. Unfortunately, it is for an assignment and I am not allowed to use php in the same file as the HTML code (not significantly anyway, it has to be very minimal php in the HTML file, such as echo and include). I have to use 2 separate files: application.php (that contains mostly HTML) and processing.php (which has mostly PHP).

    I have tried the "session_start" method, and I can get it to "kind of" work, but I when the page refreshes or the input is filled, the previous error message is still there, persistently, and will not go away. I deleted that method and tried other methods, to no avail.

    Do you know the correct method of how to link 2 pages and get the error message (from processing.php) to appear next to the input field (in application.php), but also be removed upon page refresh or a new application submission?

  2. How is it possible, in PHP, to display an error message next to a form input text field if a user is attempting to submit a form with empty fields? Moreover, how is it possible to remove the same error message when the user fills in the input field with the required data and/or refreshes the page?

    I have 2 files that I am working with: application.php and process.php.

    application.php mainly has the HTML of the form.
    process.php has the PHP for processing and validating the form.

    I am very new to learning PHP (I started learning it last week) and I have been searching for hours for a clear answer. I have already tried different methods for generating the error message including: using empty(), !isset, $_POST["name"] = "", etc, and have tried using session_start();, $row, echo, print, and other variables to try and display error message on the page, and I have tried using unset();, and = null, to try and remove the error message once the input field has been filled but all to no avail. Either the method I try only half works, or nothing works, and I cannot pinpoint which is the part that is not working.

    I only have 2 files to work with, and as an example of what I want to do is:

    1. If the first name field is empty when the user clicks submit, an error message should appear next to the input.
    2. If the user fills in the input and clicks submit, the form should be processed and added to the database.
    3. When the user returns to the application to page to fill in another application form, the error message should not appear.

    Is this possible with PHP?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.