www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 30

Thread: Error Error .... Please help me i am stuck!!!1

  1. #1
    Join Date
    Mar 2014
    Posts
    70

    Error Error .... Please help me i am stuck!!!1

    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <label for="name">Your name:</label>
    <input type="text" name="name" class="form-control" id="userName" value="<?php echo htmlspecialchars($name);?>" />
    <br /><?php echo $RegObject->ErrMsg['name']; ?>

    <label for="email">Your email:</label>
    <input type="text" name ="email" id="userEmail" class="form-control" value="<?php echo htmlspecialchars($email);?>" />
    <br /><?php echo $Object->ErrMsg['email']; ?>
    <form>


    public function ValidationCheck($input){

    if (!preg_match("/^([a-zA-Z ]{3,30})*$/",$input["name"])){
    $this->ErrMsg['name'] = '<div class="error">Please Give your Real Name</div>';
    $this->ErrMsg['alert'] = 'Invalid Name';
    $this->ErrorLog = True;
    }
    }

    public function error(){
    return $this->ErrorLog ;
    }
    here is my call

    $Object->ValidationCheck($input)
    if(!($Object->error()))
    {
    $Success="SuccessFul";
    }

    Notice: Undefined index: name in ..... on line 175
    Notice: Undefined index: email in ..... on line 179

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    856
    1 - It is usually recommended to make your subject a bit more informative of your needs. Most forums explicitly tell you to NOT use a subject of "Urgent", or "Help!" or all CAPS. Afterall - everybody who writes to a forum needs help, no?

    2 - you provided a properly tagged section of code so at least you know enough to do that but where is your question? You say nothing about your problem which is even more of an affront than your topic's header.

    3 - Great! You have an error. Wonderful. Now tell us which line has that error. I could guess what the problem is, but I really want to see if you know where it is first. Sure I'm a pia but so are posts like this.

  3. #3
    Join Date
    Mar 2014
    Posts
    70
    <?php echo $Object->ErrMsg['name']; ?> Undefined index: name in ..... on line 175
    <?php echo $Object->ErrMsg['email']; ?> Undefined index: email in ..... on line 179

  4. #4
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    856
    Great! We agree on that.

    So - what's the problem? You're using an index of your object's property (ErrMsg) that does not exist. Apparently you have no error message for the input element yet so it doesn't exist.

    I'd guess that you should change that whole reference to call a method in your object that returns the error message or a null value. That method could then check if the property has an index of that name and if not, return null instead of an error. Of course I don't do stuff like this so I could be way off base. To me writing code that requires the use of <? and ?> over and over in code is a terrible way to develop. Absolutely terrible. Hard to read. Easy to type wrong. And the use of mixed case for php vars is a nightmare waiting to haunt you.

    Enjoy!

  5. #5
    Join Date
    Mar 2014
    Posts
    70
    public function ValidationCheck($input){

    if (!preg_match("/^([a-zA-Z ]{3,30})*$/",$input["name"])){
    $this->ErrMsg['name'] = '<div class="error">Please Give your Real Name</div>';
    $this->ErrMsg['alert'] = 'Invalid Name';
    $this->ErrorLog = True;
    }
    }


    here i have ErrMsg['name'] so why its undefined ?

  6. #6
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    856
    I could be having a bad day but your code doesn't make sense to me.

    Of course I don't know how you call this function so I can't be sure. Can you show a real call to this function with a specific value being used?

  7. #7
    Join Date
    Mar 2014
    Posts
    70
    i am passing the post values as arrays to this function ValidationCheck($input) and after that i am trying to get errors if any at the front of input fields as above mentioned... thats it!!!

  8. #8
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    856
    You can't show me the code for one of these?

  9. #9
    Join Date
    Mar 2014
    Posts
    70
    <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <label for="name">Your name:</label>
    <input type="text" name="name" class="form-control" id="userName" value="<?php echo htmlspecialchars($name);?>" />
    <br /><?php echo $RegObject->ErrMsg['name']; ?>

    <label for="email">Your email:</label>
    <input type="text" name ="email" id="userEmail" class="form-control" value="<?php echo htmlspecialchars($email);?>" />
    <br /><?php echo $Object->ErrMsg['email']; ?>
    <form>


    public function ValidationCheck($input){

    if (!preg_match("/^([a-zA-Z ]{3,30})*$/",$input["name"])){
    $this->ErrMsg['name'] = '<div class="error">Please Give your Real Name</div>';
    $this->ErrMsg['alert'] = 'Invalid Name';
    $this->ErrorLog = True;
    }
    }

    public function error(){
    return $this->ErrorLog ;
    }


    //call
    $RequiredFields = array('name' => $name,'email' => $email );
    $Object->ValidationCheck($RequiredFields);

    if(!($RegObject->error()))
    {
    $Success="SuccessFul";
    }

  10. #10
    Join Date
    Mar 2014
    Posts
    70
    f(!($Object->error()))
    {
    $Success="SuccessFul";
    }

  11. #11
    Join Date
    Mar 2014
    Posts
    70
    so what anything else?

  12. #12
    Join Date
    Mar 2014
    Posts
    70
    anyone will help.....?

  13. #13
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    856
    You validate an obj call $object but then you check for a different objects error.
    OOPS - JUST SAW YOUR SECOND POST.

    And - your method has an array for input ($input), but you only check the first element ('name') and never set in index called 'email'. Could both of your error messages be related to the use of 'email' and not the use of 'name' at all?

  14. #14
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    856
    Aha!

    in what you say is line 175 you are checking an obj called regobject. And in what you say is line 179 you are checking for an index named 'email' which I've already conveyed you never set.

  15. #15
    Join Date
    Mar 2014
    Posts
    70
    i am doing also for email but i just here only for name.. more i have only one object that is $object.. but still getting the problem..

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles