Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function sql() {
- $servername = "";
- $username = "";
- $password = "";
- $dbname = "";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- global $success;
- $success = false;
- return;
- //die("Connection failed: " . mysqli_connect_error());
- }
- $sqlid = "SELECT id FROM contact ORDER BY id DESC LIMIT 1";
- $result = mysqli_query($conn, $sqlid);
- $row=mysqli_fetch_assoc($result);
- $last_id = $row["id"];
- if ($last_id == "") {
- $fromid = "0";
- } else {
- $fromid = $last_id+1;
- }
- global $fromname, $frommail, $name_company, $mail_company, $phone_company, $adress_company, $city_company, $country_company, $text;
- $stmt = mysqli_stmt_init($conn);
- $sql = mysqli_stmt_prepare($stmt, 'INSERT INTO contact (id, name, mail, company, mail_company, phone_company, adress_company, city, country, message)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
- mysqli_stmt_bind_param($sql, 'isssssssss', $fromid, $fromname, $frommail, $name_company, $mail_company, $phone_company, $adress_company, $city_company, $country_company, $text);
- mysqli_stmt_execute($stmt);
- mysqli_stmt_error($stmt); //debugging
- print_r($_POST);
- /* $sql = "INSERT INTO contact (id, name, mail, company, mail_company, phone_company, adress_company, city, country, message)
- VALUES ('$fromid', '$fromname', '$frommail', '$name_company', '$mail_company', '$phone_company', '$adress_company', '$city_company', '$country_company', '$text')"; */
- if (mysqli_query($conn, $sql)) {
- //echo "New record created successfully";
- global $success;
- $success = true;
- } else {
- echo "Error: " . $sql . "<br>" . mysqli_error($conn);
- }
- mysqli_stmt_close($stmt);
- mysqli_close($conn);
- }
- sql();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement