0

Notice: Undefined index: name in F:on line 32.
Notice: Undefined index: email in F: on line 37.
Notice: Undefined index: comments in F: on line 42.
Notice: Undefined index: name in F: on line 17 .
Notice: Undefined index: email in F: on line 17.
Notice: Undefined index: comments in F: on line 17.

<html>
    <head>
            <title> Form Results</title>
    </head>

    <body>
    <center><h2>Form Data</h2></center>
    <?php
    $vaild = checkForm();

    if($vaild){
        $db = mysqli_connect('127.0.0.1', 'root','','sweathut');
        if(! $db){
            die("Unable to connect to database: " . mysqli_connect_error());
        }
        $sql = "INSERT INTO `sweathut`.`feedback` (`name`, `email`, `comments`, `status`) VALUES ('";
        $sql = $sql . $_POST["name"] . "', '" . $_POST["email"] . "', '" . $_POST["comments"] ."', '0')";

        $result = mysqli_query($db, $sql);

        if($result){
            echo "Record saved!!!<br>"; 
        } else{
            "sorry, query seems bad.<br>";
        }
    }else{
        echo("Problem with data, abort.");
        }

    function checkForm(){

        if(strlen($_POST["name"]) > 40){
            echo ("NAME TO LARGE, DATA NOT SAVED.<br>");
            return false;
        }

        if(strlen($_POST["email"]) > 100){
            echo ("EMAIL TO LARGE, DATA NOT SAVED.<br>");
            return false;
        }

        if(strlen($_POST["comments"]) > 1500){
            echo ("COMMENTS TO LARGE, DATA NOT SAVED.<br>");    
            return false;
        }
        return true;    
    }



    ?>


    </body>


</html>
Kheshav Sewnundun
  • 1,236
  • 15
  • 37
  • Rahul check your $_POST, are you really receiving anything in it ? this is causing erro. Best is to use `isset` to check if a particular key is set or not and handle accordingly – Kuldeep Dangi Feb 23 '15 at 06:33
  • thank you I am new at this I did try it.... it gave me another error.... lol, I will keep trying. – Raul Rivera Feb 23 '15 at 07:11

0 Answers0