0

So my PHP Form doesn't sends any information to the database though there is a connection to the database!I checked everything couple of times but it still doesn't work.

Any Ideas where i have a problem in my code? Would be very appreciative for any help!

 <!DOCTYPE html>
    <!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
    <!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
    <!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
        <head>                
            <meta charset="utf-8">        
            <title></title>
            <meta name="description" content="">
            <meta name="viewport" content="width=device-width, initial-scale=1">

            <meta name="description" content="Add your business website description here">
            <meta name="keywords" content="Add your, business, website, keywords, here">
            <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

            <!-- favicon -->  
            <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
            <link rel="icon" href="favicon.ico" type="image/x-icon">

            <!-- google fonts -->
            <link href='http://fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,900%7CMerriweather:400,400italic,300,300italic,700,700italic' rel='stylesheet' type='text/css'>
            <!-- Font icons -->
            <link rel="stylesheet" href="css/vendor/elegant-font-icon.css">

            <!-- stylesheet -->
            <link rel="stylesheet" href="css/vendor/bootstrap.css">        
            <link rel="stylesheet" href="css/style.css">
            <link rel="stylesheet" href="css/custom.css">
            <link rel="stylesheet" href="css/vendor/animate.css">
            <link rel="stylesheet" href="css/vendor/owl.carousel.css">


            <!-- style switcher -->
            <link rel="stylesheet" href="css/vendor/style-switcher.css">
            <!-- Custom styles for this template -->        
            <link rel="stylesheet" type="text/css" href="css/colors/blue.css" title="blue" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/blue-2.css" title="blue-2" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/purple.css" title="purple" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/green.css" title="green" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/green-2.css" title="green-2" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/yellow.css" title="yellow" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/orange.css" title="orange" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/red.css" title="red" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/red-2.css" title="red-2" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/red-3.css" title="red-3" media="screen"/>        
            <link rel="stylesheet" type="text/css" href="css/colors/pink.css" title="pink" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/pink-2.css" title="pink-2" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/beige.css" title="beige" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/midnight.css" title="midnight" media="screen"/>
            <link rel="stylesheet" type="text/css" href="css/colors/black.css" title="black" media="screen"/>


            <script type="text/javascript" src="js/vendor/jquery-1.11.0.min.js"></script>        
            <script type="text/javascript" src="js/vendor/modernizr.custom.js"></script>
            <!--[if lt IE 9]>
                <script type="text/javascript" src="js/vendor/html5-3.6-respond-1.1.0.min.js"></script>
            <![endif]-->
        </head>    
      <body>


    <div class="row">            
                  <fieldset id="contactform" class="wow bounce" data-wow-duration="2s" data-wow-delay="0.5s"> 
                 <form action="http://xxxxx.com/forma.php " method="POST">            
                    <div id="form_result"></div>
                    <div class="row">
                      <div class="col-md-6 col-md-offset-3">
                        <input name="name" type="text" id="name" class="form-control" placeholder="Your Name">
                      </div>
                    </div>
                    <div class="row">
                      <div class="col-md-3 col-md-offset-3">
                        <input name="email" type="text" id="email" class="form-control" value="" placeholder="Your email">
                      </div>                
                      <div class="col-md-3">
                        <input name="phone" type="text" id="phone" class="form-control" value="" placeholder="Your Number">
                      </div>
                    </div>
                    <div class="row">         
                      <div class="col-md-6 col-md-offset-3">
                        <textarea name="message" cols="40" rows="5" id="comments" class="form-control" placeholder="Your Message"></textarea>
                      </div>
                    </div>
                    <div class="row">
                      <div class="col-md-12 text-center">                    
                          <button type="submit" class="btn btn-default btn-lg" id="submit">SUBMIT</button>

                      </div>
                    </div>
                    </form>
                  </fieldset>
                  </div>



                  </body>
    </html>


    <?php

    $a=mysql_connect('xxxx','xxxx','xxxx');

    $b=mysql_select_db('xxxxx',$a);

    if (!$b){
    echo 'no connection db ';

    }
    if ($_POST['submit']) {

    mysql_query('INSERT INTO form SET name="'.$_POST['name'].'",email="'.$_POST['email'].'",phone='.$_POST['phone'].',message="'.$_POST['message'].'"');

    } 






    ?>
4
  • 2
    Your button doesn't have the name 'submit'. $_POST looks at the name of an attribute, not the ID. Commented Dec 15, 2014 at 13:47
  • You shouldn't be using obsolete functions Commented Dec 15, 2014 at 13:47
  • 1
    @StefanValchev he has a button type why should he use an input ? only the name="submit" solves the problem. Commented Dec 15, 2014 at 13:49
  • The button submit has had serious problems with IE Better choice is to use input. Commented Dec 15, 2014 at 13:59

4 Answers 4

4

You forgot the name attribute. Change:

<button type="submit" class="btn btn-default btn-lg" id="submit">SUBMIT</button>

To:

<button type="submit" class="btn btn-default btn-lg" name="submit" id="submit">SUBMIT</button>
Sign up to request clarification or add additional context in comments.

Comments

0
<button type="submit" class="btn btn-default btn-lg" name="add" id="submit">SUBMIT</button>

and give the condition

if (isset($_POST['add'])) {
    mysql_query('INSERT INTO form SET name="'.$_POST['name'].'",email="'.$_POST['email'].'",phone='.$_POST['phone'].',message="'.$_POST['message'].'"');

    } 

1 Comment

yyyyyyyeeeeeeeeeeeeeeeeeeehaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa xD =) )))))))))))))))
0

Add attribute name.

 <button type="submit" class="btn btn-default btn-lg" name="submit" id="submit">SUBMIT</button>

then use

if (isset($_POST['submit'])) {

 mysql_query('INSERT INTO form SET name="'.$_POST['name'].'",email="'.$_POST['email'].'",phone='.$_POST['phone'].',message="'.$_POST['message'].'"');

}

Comments

0

mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.