Data is not inserted in database
Posted: 05 May 2016, 20:23
Hello! I have this html form:
and this php code :
why data are not inserted in database?
Code: Select all
<div class="col-md-4 col-sm-12">
<div class="contact-form bottom">
<h2>Request an offer</h2>
<form id="main-contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="form-group">
<input type="text" name="name" class="form-control" required="required" placeholder="Name">
</div>
<div class="form-group">
<input type="email" name="email" class="form-control" required="required" placeholder="Email Id">
</div>
<div class="form-group">
<textarea name="message" id="message" required="required" class="form-control" rows="8" placeholder="Your text here"></textarea>
</div>
<div class="form-group">
<input type="submit" name="submit" class="btn btn-submit" value="Submit">
</div>
</form>
Code: Select all
<?php
header('Content-type: text/html; charset=utf-8');
session_start();
$mesaj = '';
include('conn.php'); // Include fisierul pt. conectare-selectare baza de dat
// Se aplica functia de filtrare mysql_real_escape_string()
$nume = $_POST['name'];
$email = $_POST['email'];
$mesaj = $_POST['message'];
// Acum se adauga mai in siguranta aceste date in MySQL
$sql = "INSERT INTO `oferte` (`nume` , `email` , `telefon` , `descriere` ) VALUES ('$nume', '$email', '$telefon' , '$message')";
if (mysql_query($sql, $conn)) {
$mesaj = '<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4> <i class="icon fa fa-check"></i> Multumim ticketul dumneavoastra a fost inregistrat !</h4>
</div>';
$nume = ''; $email = '';
$from = 'From: contact@mluci.com';
$to = 'merlalucian99@gmail.com';
$subject = 'Client nou';
$msg = 'Verifica baza de date.Avem un ticket nou';
// send the email
if (mail($to, $subject, $msg, $from)) echo '';
else echo 'Error, the email can not be sent';
}
else $mesaj = '<font color="red">Datele nu au putut fi adaugate '. mysql_error(). '</font>';
mysql_close($conn);
}
else $mesaj = '<font color="red">'. implode('<br />', $eroare). '</font>';
}
echo $mesaj;
?>