[RESOLVED] Undefined index: submit
Results 1 to 3 of 3

Thread: [RESOLVED] Undefined index: submit

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    2

    resolved [RESOLVED] Undefined index: submit

    PHP Code:
            <div class="form col-lg-5  col-lg-offset-1">
                <form id="from-horizantal" action="" method="post" >
                    
                    <div class="form-group">
                        <div class="col-lg-10 col-md-10 col-sm-10">
                            <input name="name" id="name" type="text" class="form-control"  placeholder="Name">
                        </div>
                    </div>
             
                    <div class="form-group">
                        <div class="col-lg-10 col-md-10 col-sm-10">
                            <input name="email" id="email" type="email" class="form-control requiredField" placeholder="Email" 
                            data-error-empty="Please enter your email" data-error-invalid="Invalid email address">
                        </div>
                    </div>                 

                    <div class="form-group">
                        <div class="col-lg-10 col-md-10 col-sm-10">
                            <textarea name="message" id="message"  type="text" class="form-control" rows="3" placeholder="Your message"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-lg-7 col-md-7 col-sm-7">
                            <div class="captcha">
                            <?php echo $code_1.' + '.$code_2 ?> 
                            </div>
                            <input name="code" id="code" type="text" class="form-control col-lg-3 captcha-answer"  placeholder="Captcha">  
                        </div>
                        <input type="hidden" name="check" value="1" />
                    </div>

                    <div class="form-group">
                        <div class="col-lg-10 col-md-10 col-sm-10">
                        <button name="submit" id="submit" type="submit" class="btn btn-default form-control col-lg-10 col-md-10 col-sm-10" >Send</button> 
                        </div>
                    </div>               
                </form>
            </div>
            <!---End form-->
            
            <?php
            
    if ($_POST['submit'] && (!$_POST['name'] || !$_POST['email'] || !$_POST['message'])) {
                if (!
    $_POST['name']) {
                    echo 
    "Please enter your name";
                }
                else {
                    if (!
    $_POST['email']) {
                        echo 
    "Please enter your email"
                    }
                    else {
                        if (!
    $_POST['message']) {
                            echo 
    "Please enter your message";
                        }                
                    }

                }
            }
            else {
            }
            
    ?>

    This is part of my index file and have Undefined index: submit error,
    i want have a form contact and when the user click on the send btn form check the name & email & msg then if they exist save into my db,if they are not exist show the related error.
    PS:i'm sorry about my english speaking & writing
    Attached Images Attached Images

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,420
    Welcome to PHPBuilder!

    You should check if external variables exist using something like isset() or array_key_exists() before attempting to use them (which is what you're doing when you attempt to evaluate them inside of an if() conditional).

  3. #3
    Junior Member
    Join Date
    Mar 2014
    Posts
    2

    Solved

    Quote Originally Posted by bradgrafelman View Post
    Welcome to PHPBuilder!

    You should check if external variables exist using something like isset() or array_key_exists() before attempting to use them (which is what you're doing when you attempt to evaluate them inside of an if() conditional).

    Thanks dude,
    my problem solved by using isset() and reload the page without any error.

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
  •