i have question regarding form made.
it's big form , want receive input in database (i have accomplished far) , email including results form. want neat stylized email provides complete question , answer filled in client.
in short: want questions , answers form put in email.
<div class="formulier"> <form method="post" enctype="multipart/form-data" action="action.php"> <div id="alginfo"> <div class="col-md-12 red"> <div class="container"> <h3 class="numbers">1</h3> <h3 class="title">algemene informatie</h3> </div> </div> <div class="container"> <div class="col-md-6"> <div class="tekstenveld"> <input type="text" class="bigv bedrijfsnaam" name="bedrijfsnaam" required> <p>bedrijfsnaam</p> </div> <div class="tekstenveld"> <input type="text" class="bigv volledigenaam" name="volledigenaam" required> <p>volledige naam</p> </div> </div> <div class="col-md-6"> <div class="tekstenveld"> <input type="text" class="bigv telefoonnummer" name="telefoonnummer" required> <p>telefoonnummer</p> </div> <div class="tekstenveld"> <input type="text" class="bigv email" name="email" required> <p>e-mail</p> </div> </div> <div class="col-md-6"> <div class="multikeuze"> <h4>betreft het een:</h4> <ul> <li><span class="error"></span> <input class="multikeuzes" type="checkbox" name="website" id="website" value="website"> <label for="website" name="website">website</label></li> <li><input type="checkbox" name="webshop" id="webshop" value="webshop"> <label for="website" name="webshop">webshop</label></li> <li><input type="checkbox" name="app" id="app" value="app"> <label for="website" name="app">app</label></li> <li><input type="checkbox" name="onlinemarketing" id="onlinemarketing" value="onlinemarketing"> <label for="website" name="onlinemarketing">online marketing</label></li> </ul> <p>anders</p> <input type="text" class="bigv anders" name="alginfoanders"> </div> </div> </div> </div> </div> <div class="col-md-12 text-center" id="finish"> <input type="submit" name="submit" value="submit"> </div> </form>
so that's html, it's small part of form because including make unnecessarily big. here comes action.php shortened hope can still understand what's going on.
<?php $servername = "youdliketoknowthat.com"; $username = "butitssecret"; $password = "hunter123"; $dbname = "yougettheidea"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } if(isset($_post['submit'])){ $to = 'me@myemail.com'; $subject = 'content formulier'; $headers = "from: me@myemail.com\r\n"; $message = 'bedrijfsnaam: ' . $bedrijfsnaam; $message .= 'volledige naam: ' . $volledigenaam; $message .= 'telefoonnummer: ' . $telefoonnummer; $message .= 'email: ' . $email; mail($to, $subject, $message, $headers); $bedrijfsnaam = $_post['bedrijfsnaam']; $volledigenaam = $_post['volledigenaam']; $telefoonnummer = $_post['telefoonnummer']; $email = $_post['email']; if($volledigenaam !=''||$email !=''); $website = $_post['website']; $webshop = $_post['webshop']; $app = $_post['app']; $onlinemarketing = $_post['onlinemarketing']; { $sql = "insert intake_formulier_test (bedrijfsnaam, volledigenaam, telefoonnummer, email, website, webshop, app, onlinemarketing) values ('$bedrijfsnaam', '$volledigenaam', '$telefoonnummer', '$email', '$website', '$webshop', '$app', '$onlinemarketing')"; } if ($conn->query($sql) === true) { echo "new record created successfully"; } else { echo "error: " . $sql . "<br>" . $conn->error; } } $conn->close(); ?>
i hope made clear trying accomplish. feel should easy yet can't find answer on google applies trying do.
in short:
dont put :
$message = 'bedrijfsnaam: ' . $bedrijfsnaam;
before this:
$bedrijfsnaam = $_post['bedrijfsnaam'];
same things others variables used mail() function
your php script should this:
<?php $servername = "youdliketoknowthat.com"; $username = "butitssecret"; $password = "hunter123"; $dbname = "yougettheidea"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } if(isset($_post['submit'])){ $bedrijfsnaam = $_post['bedrijfsnaam']; $volledigenaam = $_post['volledigenaam']; $telefoonnummer = $_post['telefoonnummer']; $email = $_post['email']; if($volledigenaam !=''||$email !=''); $website = $_post['website']; $webshop = $_post['webshop']; $app = $_post['app']; $onlinemarketing = $_post['onlinemarketing']; { $sql = "insert intake_formulier_test (bedrijfsnaam, volledigenaam, telefoonnummer, email, website, webshop, app, onlinemarketing) values ('$bedrijfsnaam', '$volledigenaam', '$telefoonnummer', '$email', '$website', '$webshop', '$app', '$onlinemarketing')"; } if ($conn->query($sql) === true) { echo "new record created successfully"; // can send email $to = 'me@myemail.com'; $subject = 'content formulier'; $headers = "from: me@myemail.com\r\n"; $message = 'bedrijfsnaam: ' . $bedrijfsnaam; $message .= 'volledige naam: ' . $volledigenaam; $message .= 'telefoonnummer: ' . $telefoonnummer; $message .= 'email: ' . $email; mail($to, $subject, $message, $headers); } else { echo "error: " . $sql . "<br>" . $conn->error; } } $conn->close(); ?>
you adding things $message var this: $message = 'bedrijfsnaam: ' . $bedrijfsnaam; @ point, particular exemple, var $bedrijfsnaam wasn't declared... $message var empty ! in example, put things related emailing infos after db query, , after $var = $_post["var"]..
Comments
Post a Comment