insert in mysql issue [duplicate]

189
July 13, 2017, at 05:08 AM

This question already has an answer here:

  • PHP: “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” 21 answers
  • Why do form element can not be child of table,tr,td? 1 answer
  • Form inside a table 3 answers

This is how the code looks for the insert.php file. Every time I run this code I get the same error that my variables are not defined. Below also you have my index page

        $dbhost = 'localhost';
        $dbuser = 'root';
        $dbpass = 'admin';
        $dbname = 'test_emilian';
        $con = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
        // check the connection
        if ($con->connect_errno){
        die("Failed to connect to MySQL: (" . $con->connect_errno . ") " . $con->connect_error);
        }
        $id = mysqli_real_escape_string($con,$_POST['id']);
        $first = mysqli_real_escape_string($con,$_POST['first']);
        $last = mysqli_real_escape_string($con,$_POST['last']);
        $email = mysqli_real_escape_string($con,$_POST['email']);
        $mobile = mysqli_real_escape_string($con,$_POST['mobile']);
        $date = mysqli_real_escape_string($con,$_POST['date']);
        $gender = mysqli_real_escape_string($con,$_POST['gender']);
        $cnp = mysqli_real_escape_string($con,$_POST['cnp']);
     //made the INSERT duction   

$AddQuery = "INSERT INTO useri (first,last,email,mobile,date,gender,cnp) values ('".$id."','".$first."','".$last."','".$email."','".$mobile."','".$date."','".$gender."','".$cnp."')";
        if (!mysqli_query($con,$AddQuery))
        {echo 'Not Inserted';
        }else{
        echo 'Inserted Successfully';
        }

This is where I have defined the variables

        echo "<tr><form action=insert.php method = post>";
        echo "<tr>";
        echo "<td><input type=text name =first></input></td>";
        echo "<td><input type=text name =last></input></td>";
        echo "<td><input type=text name =email></input></td>";
        echo "<td><input type=text name =mobile></input></td>";
        echo "<td><input type=text name =date></input></td>";
        echo "<td><input type=text name =gender></input></td>";
        echo "<td><input type=text name =cnp></input></td>";
        echo "<td><input type=submit name =add value = add>" ."</td</tr>";
        echo "</form>";
        echo "</table>";
        ?>

at the end is not inserting anything.

Rent Charter Buses Company
READ ALSO
Evernote php - get notes from linked notebook

Evernote php - get notes from linked notebook

I am using this SDK - https://githubcom/evernote/evernote-cloud-sdk-php

267
Convert dates into a new format

Convert dates into a new format

I have a document with a bunch of dates, always wrapped in tags and always in a specific format

254
Dumping a RETS Data Feed

Dumping a RETS Data Feed

So I have a RETS data feed from Paragon I am trying to dump all this data into a CSV using phRETS libraryI have tried many different ways to dump data from this RETS feed via dmql or libRETS and none of them are working

237