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. Linux, Apache, MySQL, PHP
  4. Positioning errors :S

Positioning errors :S

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
helpphpquestion
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.
  • S Offline
    S Offline
    SRJ92
    wrote on last edited by
    #1

    hello, i hope one of you lot can help me ... i am creating a form for registration to my site... it all works i just need to know how i would position an error from process.php eg//

    echo('The username/email you have entered already exists, please try again');
    include("register.php");

    in the registration document register.php, is there a way to put this certain "echo" into a div ?

    div id = " error " / d i v

    Thanks

    enhzflepE X 2 Replies Last reply
    0
    • S SRJ92

      hello, i hope one of you lot can help me ... i am creating a form for registration to my site... it all works i just need to know how i would position an error from process.php eg//

      echo('The username/email you have entered already exists, please try again');
      include("register.php");

      in the registration document register.php, is there a way to put this certain "echo" into a div ?

      div id = " error " / d i v

      Thanks

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      function byId(el){return document.getElementById(el)} <div id="msgTgt"></div> byId("msgTgt").innerHTML = "The username/email you entered already exists, please try again"

      1 Reply Last reply
      0
      • S SRJ92

        hello, i hope one of you lot can help me ... i am creating a form for registration to my site... it all works i just need to know how i would position an error from process.php eg//

        echo('The username/email you have entered already exists, please try again');
        include("register.php");

        in the registration document register.php, is there a way to put this certain "echo" into a div ?

        div id = " error " / d i v

        Thanks

        X Offline
        X Offline
        xTraCD
        wrote on last edited by
        #3

        I try to write in a way people understand simply, so if its a little "fluffy" then I apologize in advance.

        I'd probably make a function that scans the inputs from the form, and checks them. Then the second part of the function would be to spit out the errors that were made. Kind of like (e.g.) if the username space is blank, then report an error. The div id 'errors' would be where your errors would be spat out. (Registration page)

        <div id="regform">
           <div id="errors">
           <?php
           validateInputs();
           ?>
           </div>
        <?php
        include("register.php");
        ?>
        </div>

        (Function, theory I guess)

        function validateInputs(){
           $username = $__POST["username"]; #name referring to the entities of <input name="nameHere" >
        ...php script that checks the length of the input, and for false positives, like a bunch of spaces,
        or perhaps a name consisting of one character, or patterns like that. Also use it to check if the username
        is being used or not...Then echo out what errors were triggered, on that page, and if you have no errors,
        you could give a check image or something. I'm not too sure.
        }

        hope this helps. I heard you can also do form validation with jQuery http://www.webreference.com/programming/javascript/jquery/form_validation/[^]

        S 1 Reply Last reply
        0
        • X xTraCD

          I try to write in a way people understand simply, so if its a little "fluffy" then I apologize in advance.

          I'd probably make a function that scans the inputs from the form, and checks them. Then the second part of the function would be to spit out the errors that were made. Kind of like (e.g.) if the username space is blank, then report an error. The div id 'errors' would be where your errors would be spat out. (Registration page)

          <div id="regform">
             <div id="errors">
             <?php
             validateInputs();
             ?>
             </div>
          <?php
          include("register.php");
          ?>
          </div>

          (Function, theory I guess)

          function validateInputs(){
             $username = $__POST["username"]; #name referring to the entities of <input name="nameHere" >
          ...php script that checks the length of the input, and for false positives, like a bunch of spaces,
          or perhaps a name consisting of one character, or patterns like that. Also use it to check if the username
          is being used or not...Then echo out what errors were triggered, on that page, and if you have no errors,
          you could give a check image or something. I'm not too sure.
          }

          hope this helps. I heard you can also do form validation with jQuery http://www.webreference.com/programming/javascript/jquery/form_validation/[^]

          S Offline
          S Offline
          SRJ92
          wrote on last edited by
          #4

          Thank you, thats very helpful :P

          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