Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Form submit error message

Form submit error message

Scheduled Pinned Locked Moved Web Development
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tichaona J
    wrote on last edited by
    #1

    I am trying to get my code to check the “username” field and print an error message letting the user know that they left a field blank. Now before all I had was the below code of which it worked in part, in the sense that the below code was executed when the submit button was clicked on and when the page was refreshed.

                   if (isset($\_POST\['username'\])) {
                                        
                               emptyField();
                                    
                                         }                           
                                             
                          
                                 function emptyField()
                                    {
                                      $var1 = "**\*Field missing entry...**";
                                     echo $var1;
                                    }
    

    To fix this I the added the below code, which now meant that the code only worked if the user clicked on the submit button and didn’t work if the page is refreshed. However I’ve also noticed that even when there is text in the “username” field and say the user got there password wrong (not proceeding to the next page), it simply cleared all fields and printed “*Field missing entry...*” Why is this and how do I sort this out…?

    *Field missing entry...";
    echo $var1;
    }

    R 1 Reply Last reply
    0
    • T Tichaona J

      I am trying to get my code to check the “username” field and print an error message letting the user know that they left a field blank. Now before all I had was the below code of which it worked in part, in the sense that the below code was executed when the submit button was clicked on and when the page was refreshed.

                     if (isset($\_POST\['username'\])) {
                                          
                                 emptyField();
                                      
                                           }                           
                                               
                            
                                   function emptyField()
                                      {
                                        $var1 = "**\*Field missing entry...**";
                                       echo $var1;
                                      }
      

      To fix this I the added the below code, which now meant that the code only worked if the user clicked on the submit button and didn’t work if the page is refreshed. However I’ve also noticed that even when there is text in the “username” field and say the user got there password wrong (not proceeding to the next page), it simply cleared all fields and printed “*Field missing entry...*” Why is this and how do I sort this out…?

      *Field missing entry...";
      echo $var1;
      }

      R Offline
      R Offline
      rpprojects
      wrote on last edited by
      #2

      Try..

      if (empty($_POST['username'])) {

      emptyField();
      

      }

      T 1 Reply Last reply
      0
      • R rpprojects

        Try..

        if (empty($_POST['username'])) {

        emptyField();
        

        }

        T Offline
        T Offline
        Tichaona J
        wrote on last edited by
        #3

        Thanks...That worked... :)

        D 1 Reply Last reply
        0
        • T Tichaona J

          Thanks...That worked... :)

          D Offline
          D Offline
          David Kroj
          wrote on last edited by
          #4

          This code will help you please try:

          if (empty($_POST['username'])) {

          emptyField();
          

          }

          Regards, David Kroj

          Website Development Company | Web Development Company

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups