I’ve asked this question before but used ajax and it produced some weird behaviour. I’m hoping someone could write a simple php mail function for me. Here’s what I have at the moment:
[code=html]<?php
if (isset($_POST[‘subme’])) {
//define the receiver of the email
$to = ‘[email protected]’;
//define the subject of the email
$subject = ‘Test email’;
//define the message to be sent. Each line should be separated with n
$message .= $_POST[‘naam’];
//define the headers we want passed. Note that they are separated with rn
$headers = “From: [email protected]: [email protected]”;
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Factuur informatie.</title>
<meta name=”viewport” content=”width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no”>
<meta charset=”utf-8″>
<meta http-equiv=”content-type” content=”text/html; charset=utf-8″ />
<link rel=”stylesheet” href=”css/bootstrap.min.css”>
<link rel=”stylesheet” href=”css/animate.css”>
</head>
<body style=”background-color: white”>
<div class=”row”>
<div class=”col-sm-6 col-sm-offset-3″>
<div class=”well” style=”margin-top: 10%;”>
<h3>Voor uw factuur hebben wij de volgende informatie nodig.</h3>
<form action=”insert.php” method=”post” role=”form” data-toggle=”validator” class=”shake”>
<div class=”row”>
<div class=”form-group down col-sm-6″>
<label for=”name” class=”h4″>Voor en achternaam.</label>
<input name=”naam” type=”text” class=”form-control” id=”name” placeholder=”Voornaam Achternaam” required data-error=”Vergeet deze niet!”>
<div class=”help-block with-errors”></div>
</div>
<div class=”form-group down col-sm-6″>
<label for=”birth” class=”h4″>Geboortedatum</label>
<input name=”geboortedatum” type=”text” class=”form-control” id=”birth” placeholder=”22-12-1961″ required data-error=”Vergeet deze niet!”>
<div class=”help-block with-errors”></div>
</div>
<div class=”form-group down col-sm-6″>
<label for=”BSN” class=”h4″>BSN</label>
<input name=”BSN” type=”text” class=”form-control” id=”BSN” placeholder=”Burgerservicenummer” required data-error=”Vergeet deze niet!”>
<div class=”help-block with-errors”></div>
</div>
<div class=”form-group down col-sm-6″>
<label for=”email” class=”h4″>Email</label>
<input name=”email” type=”email” class=”form-control” id=”email” placeholder=”Enter email” required>
<div class=”help-block with-errors”></div>
</div>
<div class=”form-group down col-sm-6″>
<label for=”adres” class=”h4″>Email</label>
<input name=”adres” type=”text” class=”form-control” id=”adres” placeholder=”Adres” required>
<div class=”help-block with-errors”></div>
</div>
<div class=”form-group down col-sm-6″>
<label for=”telefoon” class=”h4″>Email</label>
<input name=”telefoon” type=”text” class=”form-control” id=”telefoon” placeholder=”0612345678″ required>
<div class=”help-block with-errors”></div>
</div>
</div>
<button value=”Submit” name=”subme” style=”background-color: #75963c;” type=”submit” id=”form-submit” class=”btn btn-success btn-lg pull-right “>Submit</button>
<div id=”msgSubmit” class=”h3 text-center hidden”></div>
<div class=”clearfix”></div>
</form>
</div>
</div>
<div class=”col-sm-6 col-sm-offset-3″>
<img style=”width: 300px; display: block; margin: 0 auto; padding-top:20px;” src=”lessstress.gif”>
</div>
</div>
<style type=”text/css”>
@media (max-width: 900px) {
.down {
width: 95%;
}
</style>
</body>
<script type=”text/javascript” src=”js/jquery-1.11.2.min.js”></script>
<script type=”text/javascript” src=”js/validator.min.js”></script>
</html>[/code]
Please note that the php email is not working. It won’t sent anything.
Here is my script for the sql database.
[code=html] <html>
<body>
<?php
$con = mysql_connect(“databaseip”,”username”,”password”);
if (!$con)
{
die(‘Could not connect: ‘ . mysql_error());
}
mysql_select_db(“databasename”, $con);
$sql=”INSERT INTO nametable (naam, geboortedatum, BSN, email, adres, telefoon) VALUES(‘$_POST[naam]’,’$_POST[geboortedatum]’,’$_POST[BSN]’,’$_POST[email]’,’$_POST[adres]’,’$_POST[telefoon]’)”;
if (!mysql_query($sql,$con))
{
die(‘Error: ‘ . mysql_error());
}
echo “1 record added”;
mysql_close($con)
?>
</body>
</html>
After / or before the form is submitted I want to receive the data in email so to be notified that someone has submitted a new form. Right now it is -only submitting to my database and not emailing me the data. Hopefully someone can help me get this functional. I am not a web developer and I’ve spent three days on getting this to this stage. All help is HIGHLY appreciated. I just want to get this functional.