I'm trying to add a ReCaptcha into the form. I use a formhandler.php with an error.php and success.php page.
I've put this code
<?php
if(isset($_POST['submit'])){
$url = 'https://google.com/recaptcha/api/siteverify';
$privatekey = "xxx";
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
if(isset($data->success) AND $data->success==true) {
header('Location: success.php');
}else{
header('Location: error.php?CaptchaFail=True');
}
}
?>
into my formhandler.php. If I don't tick the ReCaptcha, my error.php works. But I still get the error page if I used ReCaptcha.
I'm not good at php and I guess I have an mistake somewhere.
This is the whole code from formhandler.php which I use:
<?php
if(isset($_POST['email'])) {
$url = 'https://google.com/recaptcha/api/siteverify';
$privatekey = "xxxx";
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
$email_to = "xxx";
$email_subject = "Kontaktanfrage - ec-parts.de";
$email = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$checkboxaccept = $_POST['checkboxaccept'];
$email_message = "Nachricht:\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
function getUserIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
return $_SERVER['HTTP_CLIENT_IP'];
}
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
return $_SERVER['REMOTE_ADDR'];
}
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email)."\n";
$email_message .= "Telefon: ".clean_string($phone)."\n";
$email_message .= "Nachricht: ".clean_string($message)."\n";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/plain;charset=UTF-8" . "\r\n";
$headers .= 'From: '.$email. "\r\n";
if (#mail($email_to, $email_subject, $email_message, $headers, $checkboxaccept, $response))
if (isset($data->success) AND $data->success==true) {
header('Location: success.php');
} else {
header('Location: error.php?CaptchaFail=True');
}
}
?>
Maybe it's because of the code if (isset($data->success) AND $data->success==true). I'm not sure where to put it. I'm still a beginner in PHP...
I only want formhandler.php to check if I used the ReCaptcha. I googled a lot of different codes but this one almost work.
If you need, you can test the form here: contact form
EDIT:
I've changed the code using the solution from this post:
My formhandler.php:
<?php
function validate_email_address($email = false) {
return (preg_match('/^[^#\s]+#([-a-z0-9]+\.)+[a-z]{2,}$/i', $email))? true : false;
}
function remove_email_injection($field = false) {
return (str_ireplace(array("\r", "\n", "%0a", "%0d", "Content-Type:", "bcc:","to:","cc:"), '', $field));
}
// Set email variables
$email_to = "xxx";
$email_subject = "Kontaktanfrage - ec-parts.de";
// Set required fields
$required_fields = array('email', 'name', 'message', 'checkboxaccept');
// set error messages
$error_messages = array(
'email' => 'Bitte geben Sie eine gültige E-mailadresse an.',
'name' => 'Bitte geben Sie Ihren Namen an.',
'message' => 'Bitte schreiben Sie uns, worum es in Ihrer Anfrage geht.',
'checkboxaccept' => 'Bitte klicken Sie die Checkbox an, wenn Sie fortsetzen wollen.'
);
// Set form status
$form_complete = FALSE;
// configure validation array
$validation = array();
// boolean variable to validate recaptcha
$valid_recaptcha = false;
if(isset($_POST['submit'])){
// First validate recaptcha
$url = 'https://www.google.com/recaptcha/api/siteverify';
$privatekey = "xxx";
$response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
if($data->success) {
$valid_recaptcha = true;
}
if($valid_recaptcha){
// now process your form here. sanitize and validate input fields
// Sanitise POST array
foreach($_POST as $key => $value){
$_POST[$key] = remove_email_injection(trim($value));
}
// Loop into required fields and make sure they match our needs
foreach($required_fields as $field) {
// the field has been submitted?
if(!array_key_exists($field, $_POST)){
array_push($validation, $field);
}
// check there is information in the field?
if($_POST[$field] == ''){
array_push($validation, $field);
}
// validate the email address supplied
if($field == 'email'){
if(!validate_email_address($_POST[$field])){
array_push($validation, $field);
}
}
}
// basic validation result
if(count($validation) == 0) {
// Prepare our content string
$email_content = 'Neue Kontaktanfrage: ' . "\n\n";
// simple email content
foreach($_POST as $key => $value){
if($key != 'submit' && $key != 'g-recaptcha-response') $email_content .= $key . ': ' . $value . "\n";
}
// if validation passed ok then send the email
mail($email_to, $email_subject, $email_content);
// Update form switch
$form_complete = TRUE;
}
}
}
?>
My kontakt.php:
<!DOCTYPE html>
<html >
<head>
<!-- Site made with Mobirise Website Builder v4.5.2, https://mobirise.com -->
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="generator" content="Mobirise v4.5.2, mobirise.com">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
<link rel="shortcut icon" href="assets/images/favicon-1.gif" type="image/x-icon">
<meta name="description" content="ec - exclusive carparts GmbH Berlin, Der Tuning Spezialist aus Berlin. Kontaktdaten.">
<title>ec - exclusive carparts GmbH Berlin. Kontakt. TÜV- Profi, Brabus Händler Berlin.</title>
<link rel="stylesheet" href="assets/bootstrap-material-design-font/css/material.css">
<link rel="stylesheet" href="assets/et-line-font-plugin/style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Montserrat:400,700">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic&subset=latin">
<link rel="stylesheet" href="assets/tether/tether.min.css">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/soundcloud-plugin/style.css">
<link rel="stylesheet" href="assets/dropdown/css/style.css">
<link rel="stylesheet" href="assets/theme/css/style.css">
<link rel="stylesheet" href="assets/mobirise3-blocks-plugin/css/style.css">
<link rel="stylesheet" href="assets/mobirise/css/mbr-additional.css" type="text/css">
<meta name="rating" content="General" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="language" content="de" />
<meta name="keywords" content="exclusive carparts Berlin,ec-parts,Kontakt,Berlin" />
<meta name="publisher" content="Website by inventmedia. http://www.inventmedia.de" />
<meta name="robots" content="all,index,follow" />
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<section id="menu-3g" data-rv-view="463">
<nav class="navbar navbar-dropdown navbar-fixed-top">
<div class="container">
<div class="mbr-table">
<div class="mbr-table-cell">
<div class="navbar-brand">
<img src="assets/images/ecparts-logo-menu-big-520x128.png" alt="ec - exclusive carparts Berlin" title="ec - exclusive carparts Berlin">
</div>
</div>
<div class="mbr-table-cell">
<button class="navbar-toggler pull-xs-right hidden-md-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">
<div class="hamburger-icon"></div>
</button>
<ul class="nav-dropdown collapse pull-xs-right nav navbar-nav navbar-toggleable-sm" id="exCollapsingNavbar"><li class="nav-item"><a class="nav-link link" href="index.php">STARTSEITE</a></li><li class="nav-item dropdown"><a class="nav-link link" href="auto-folierung-fahrzeug-komplettbeklebung-berlin.php" aria-expanded="false">FOLIERUNG</a></li><li class="nav-item dropdown"><a class="nav-link link" href="portfolio.php" aria-expanded="false">PORTFOLIO</a></li><li class="nav-item"><a class="nav-link link" href="service-partner.php" aria-expanded="false">SERVICE & PARTNER</a></li>
<li class="nav-item"><a class="nav-link link" href="tuev-sondereintragung.php" aria-expanded="false">TÜV</a></li><li class="nav-item"><a class="nav-link link" href="produkte.php" aria-expanded="false">PRODUKTE & LEISTUNGEN</a></li><li class="nav-item"><a class="nav-link link" href="kontakt.php" aria-expanded="false">KONTAKT</a></li></ul>
<button hidden="" class="navbar-toggler navbar-close" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">
<div class="close-icon"></div>
</button>
</div>
</div>
</div>
</nav>
</section>
<section class="engine">web builder</section><section class="mbr-section article mbr-parallax-background mbr-after-navbar" id="msg-box8-3h" data-rv-view="465" style="background-image: url(assets/images/start-2-836x576.jpg); padding-top: 200px; padding-bottom: 200px;">
<div class="mbr-overlay" style="opacity: 0.5; background-color: rgb(34, 34, 34);">
</div>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2 text-xs-center">
</div>
</div>
</div>
</section>
<div id="header3-3i" custom-code="true" data-rv-view="468"><section class="mbr-section mbr-section__container article" data-rv-view="1005" style="background-color: rgb(239, 239, 239); padding-top: 20px; padding-bottom: 20px;">
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1 class="card-header mbr-editable-content" style="text-align: left; font-family: Oswald, sans-serif; font-size: 32px; color: rgb(34, 34, 34);">Kontakt</h1>
</div>
</div>
</div>
</section></div>
<div id="content6-3o" custom-code="true" data-rv-view="469"><section class="mbr-section article mbr-section__container" data-rv-view="327" style="background-color: rgb(239, 239, 239); padding-top: 20px; padding-bottom: 20px; border-bottom: 1px solid #ccc;">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-6 lead mbr-editable-full"><p><strong>ec exclusive carparts GmbH
</strong></p>
<p>Geschäftsführer: Mirko Schröter
</p>
<p>Blücherstrasse 60
</p><p>10961 Berlin</p><p><br></p><p>Fon: +49 (0) 30 36 40 67 36
</p><p>Fax: +49 (0) 30 36 40 67 35
</p><p>Internet: www.ec-parts.de
</p><p>E-Mail: info#ec-parts.de</p></div>
<div class="col-xs-12 col-md-6 lead mbr-editable-full">
<p><strong>Öffnungszeiten: </strong>
</p><p>Mo. - Fr.: 10 Uhr - 18.30 Uhr
</p><p>Sa.: nach Vereinbarung</p></div>
</div>
</div>
</section></div>
<section class="mbr-section extForm1 mbr-parallax-background" id="extForm1-5m" data-rv-view="470" style="background-image: url(assets/images/folierung-836x576.jpg); padding-top: 50px; padding-bottom: 50px;">
<div class="mbr-overlay" style="opacity: 0.8; background-color: rgb(255, 255, 255);">
</div>
<div class="mbr-table mbr-table-full">
<div class="mbr-table-cell">
<div class="container">
<div class="row">
<div class="mbr-table-md-up">
<!-- & -->
<div class="mbr-table-cell col-md-7 text-xs-center text-md-left">
<h2 class="display-2 h-black"><span style="font-weight: normal;">Kontaktformular</span></h2>
<?php
if(isset($_POST['submit'])){
if(!$valid_recaptcha){
// error
?>
<div class="col-md-12" style="margin-left: 200px;" align="center">ReCAPTCHA fehlgeschlagen, bitte versuchen Sie es erneut.</div><br />
<?php
}
}
?>
<div class="col-md-12" style="padding-left: 0px; padding-right: 0px;">
<?php if($form_complete === FALSE): ?>
<form action="formhandler.php" method="post">
<div class="col-xs-6">
<input type="text" class="form-control" name="name" required data-form-field="Name" placeholder="Name*" value="<?php echo isset($_POST['name'])? $_POST['name'] : ''; ?>" /><?php if(in_array('name', $validation)): ?><span class="error"><?php echo $error_messages['name']; ?> </span><?php endif; ?>
</div>
<div class="col-xs-6" style="padding-left: 15px">
<input type="text" class="form-control" name="email" required data-form-field="Email" placeholder="E-mail*" value="<?php echo isset($_POST['email'])? $_POST['email'] : ''; ?>" /><?php if(in_array('email', $validation)): ?><span class="error"><?php echo $error_messages['email']; ?> </span><?php endif; ?>
</div>
<div class="col-xs-12">
<input type="text" class="form-control" name="phone" required data-form-field="Phone" placeholder="Telefon*">
</div>
<div class="col-xs-12">
<textarea class="form-control" name="message" rows="7" data-form-field="Message" style="resize:none" placeholder="Nachricht" value="<?php echo isset($_POST['message'])? $_POST['message'] : ''; ?>" /><?php if(in_array('message', $validation)): ?><span class="error"><?php echo $error_messages['message']; ?> </span><?php endif; ?></textarea>
</div>
<div class="col-xs-12">
<label class="lead">
<p><input style="margin-bottom: 0;" type="checkbox" name="checkboxaccept" required value="<?php echo isset($_POST['checkboxaccept'])? $_POST['checkboxaccept'] : ''; ?>" /><?php if(in_array('checkboxaccept', $validation)): ?><span class="error"><?php echo $error_messages['checkboxaccept']; ?> </span><?php endif; ?>
<span style="color: #1f008f;">*</span>Ich stimme zu, dass meine Angaben aus dem Kontaktformular zur Beantwortung meiner Anfrage erhoben und verarbeitet werden. Die Daten werden nach abgeschlossener Bearbeitung Ihrer Anfrage gelöscht.</p>
<p><em>Hinweis: Sie können Ihre Einwilligung jederzeit für die Zukunft per E-Mail an info#ec-parts.de widerrufen. Detaillierte Informationen zum Umgang mit Nutzerdaten finden Sie in unserer Datenschutzerklärung.</em></p></label>
</div>
<div class="col-xs-12"><div class="g-recaptcha" data-sitekey="6Lc1TlwUAAAAAMxGXW7AEsy3w5asFtZKi8cvtuxL"></div></div>
<div class="col-xs-12 buttons_wrap" style="margin-top: 10px;"><button type="submit" class="btn btn-primary">Nachricht senden</button></div>
</form>
<?php else: ?>
<div class="row">
<div class="col-md-12 parent">
<div class="col-md-12 col-lg-12" style="padding: 0;">
<div class="intro-box right" style="margin: 10px 0;">
<div class="content alert alert-success" style="padding: 10px 10px 10px 10px;">
<h4 class="text-right mbr-editable-content">Vielen Dank für Ihre Nachricht!</h4>
<p class="mbr-section-text lead mbr-editable-content">Wir werden uns umgehend bei Ihnen melden.</p>
</div>
</div>
</div>
</div>
</div>
<!--<script type="text/javascript">
setTimeout('ourRedirect()',5000)
function ourRedirect(){
location.href='http://web6.server.inventmedia.de/ec/kontakt.php'
}
</script>-->
<?php endif; ?>
</div>
</div>
<div class="mbr-table mbr-valign-top col-md-5">
<div class="mbr-figure"><img src="assets/images/mirko-1000x961.jpg" class="img-thumbnail central-image"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="mbr-section mbr-section-nopadding" id="map1-51" data-rv-view="480">
<div class="mbr-map"><iframe frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?key=xxx&q=place_id:ChIJ8TAx5OdQqEcRUK_4PR7srUk" allowfullscreen=""></iframe></div>
</section>
<section class="mbr-slider mbr-section mbr-section-nopadding carousel slide extTestimonials1 extTestimonials3 extTestimonials5" data-ride="carousel" data-keyboard="false" data-wrap="true" data-interval="5000" data-pause="false" id="extTestimonials5-3k" data-rv-view="482" style="background-color: rgb(255, 255, 255); padding-top: 0px; padding-bottom: 0px;">
<div class="mbr-section__container mbr-section__container--middle">
<div class="container">
<div class="row">
<div class="col-xs-12 text-xs-center">
</div>
</div>
</div>
</div>
<div class="container boxed-slider">
<div>
<div class="carousel-inner" role="listbox" data-visible="6">
<div class="carousel-item active">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/bastuck-226x118.png" alt="Bastuck" title="Bastuck"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/barracuda-226x118.png" alt="Barracuda" title="Barracuda"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/bbs-226x118.png" alt="BBS" title="BBS"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/breyton-226x118.png" alt="Breyton" title="Breyton"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/oz-226x118.png" alt="OZ Racing" title="OZ Racing"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/hr-226x118.png" alt="H&R" title="H&R"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/kn-226x118.png" alt="K&N" title="K&N"></div>
</div>
</div>
</div><div class="carousel-item">
<div class="row">
<div class="col-md-12">
<div class="wrap-img"><img src="assets/images/lowtec-226x118.png" alt="Lowtec" title="Lowtec"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="mbr-section mbr-section-md-padding mbr-footer footer1" id="contacts1-3l" data-rv-view="510" style="background-color: rgb(34, 34, 34); padding-top: 90px; padding-bottom: 90px;">
<div class="container">
<div class="row">
<div class="mbr-footer-content col-xs-12 col-md-3">
<div><img src="assets/images/ec-parts-logo-big-128x165.png" alt="ec - exclusive carparts Berlin" title="ec - exclusive carparts Berlin"></div>
</div>
<div class="mbr-footer-content col-xs-12 col-md-3">
<p><strong>EC-Parts</strong><br>
Startseite<br>
Kontakt<br>Datenschutz<br>Impressum</p>
</div>
<div class="mbr-footer-content col-xs-12 col-md-3">
<p><strong>Kontakt</strong><br>
Email: info#ec-parts.de<br>
Fon: +49 (0) 30 36 40 67 36<br>
Fax: +49 (0) 30 36 40 67 35<br><br>
Öffnungszeiten:
<br>Mo. - Fr.: 10 Uhr - 18.30 Uhr
<br>Sa.: nach Vereinbarung<br></p>
</div>
<div class="mbr-footer-content col-xs-12 col-md-3">
<p><strong>Anschrift</strong><a class="text-info" href="https://mobirise.com/"><br></a>ec exclusive carparts Berlin Autotuning<br>
Blücherstrasse 60<br>10961 Berlin<br></p>
</div>
</div>
</div>
</section>
<script src="assets/web/assets/jquery/jquery.min.js"></script>
<script src="assets/tether/tether.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/smooth-scroll/smooth-scroll.js"></script>
<script src="assets/touch-swipe/jquery.touch-swipe.min.js"></script>
<script src="assets/jarallax/jarallax.js"></script>
<script src="assets/bootstrap-carousel-swipe/bootstrap-carousel-swipe.js"></script>
<script src="assets/dropdown/js/script.min.js"></script>
<script src="assets/theme/js/script.js"></script>
<script src="assets/mobirise3-blocks-plugin/js/script.js"></script>
<div id="scrollToTop" class="scrollToTop mbr-arrow-up"><a style="text-align: center;"><i class="mbr-arrow-up-icon"></i></a></div>
</body>
</html>
I am not sure, why this doesn't work. I was trying to copy the whole code step by step. I can see the success message and the form is missing.
Related
I am sure this will end up being a silly question, but hear me out please.
I am a novice developer and i'm building a website with html, css (w/ Bootstrap) and since the website has to have a contact form page, i am using php there. Originally when I was developing the pages of the website including the front-end of the Contact page. all my pages were .html. Now, following a tutorial online, i have added the php to the contact.html to have the contact from content sent to an email of my choosing, i have changed the file name from contact.html to contact.php and i have placed ALL the website files into MAMP's htdocs folder in my C drive in order to test. However, since switching to contact.php, i cannot view the page! Instead i receive an http error 500. Note that all the .html files render as they should.
No doubt somewhere along the line i have made a rudimentary mistake, but any assistance in clearing this problem is very much appreciated.
<!DOCTYPE html>
<?php
$message_sent = 'false';
if(isset($_POST['email']) && $_POST['email'] != ''){
if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ){
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$message = $_POST['message'];
$messageMark = $_POST['mark'];
$to = "redacted_email#outlook.com";
$body = "";
$body .+ "From: ".$userName. "\r\n";
$body .= "Email: ".userEmail. "\r\n";
$body .= "Message: ".$message. "\r\n";
$body .= "Marketing: ".$messageMark. "\r\n";
mail($to, $body);
$message_sent = true;
}
}
?>
<html lang="en">
<main>
<?php
if($message_sent):
?>
<h2>Thank you, we shall be in touch soon.</h2>
<?php
else:
?>
<section id="contact">
<div class="container-lg">
<div class="">
<h1 class="title">Contact Us</h1>
<hr>
<div class="row justify-content-center my-5">
<div class="col-lg-6">
<form class="form" name="form" autocomplete="off" method="POST" action="contactus.php">
<label class="form-label" for="name" style="color: white;">Name:</label>
<input class="form-control mb-2" id="name" type="text" name="name" required>
<label class="form-label mt-3" for="email" style="color: white;">Email: <span class="tooltip" data-tooltip="Please enter your email address">?</span></label>
<input class="form-control" id="email" type="email" placeholder="e.g. name:example.com" name="email" required>
<div class="form-floating mb-5 mt-5">
<textarea id="query" class="form-control" name="message" style="height: 250px; overflow-y: visible;"></textarea>
<label for="query" class="textlab">Type your message here: <span class="tooltip" data-tooltip="Type your message here">?</span></label>
</div>
<div class="form-floating mb-5 mt-5">
<textarea id="query" class="form-control" name="mark" style="height: 100px;"></textarea>
<label for="query" class="textlab">How did you hear about us?:<span class="tooltip" data-tooltip="Just a few words on how you found our website and heard about our club">?</span></label>
</div>
<p>
<!--Instert recaptcha here? -->
</p>
<div class="mb-4 text text-center">
<button type="submit" id="conbtn" class="btn btn-light btn-lg btn-block">Send Now!</button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</main
For the sake of clarity, here is the entirety of the code from my contact.php page which is producing an HTTP ERROR 500 response through MAMP:
<!DOCTYPE html>
<?php
$message_sent = false;
if(isset($_POST['email']) && $_POST['email'] != ''){
if( filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ){
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$message = $_POST['message'];
$messageMark = $_POST['mark'];
$to = "troy_a_w_easson#outlook.com";
$body = "";
$body .= "From: ".$userName. "\r\n";
$body .= "Email: ".$userEmail. "\r\n";
$body .= "Message: ".$message. "\r\n";
$body .= "Marketing: ".$messageMark. "\r\n";
mail($to, $subject, $body):
$message_sent = true;
}
}
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="images/LMRCupsc-removebg2.png">
<link
href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css"
rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js">
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Beau+Rivage&display=swap"
rel="stylesheet">
<link href='//fonts.googleapis.com/css?family=Signika+Negative:300,400,600'
rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="CSS/contact.css">
<title>Largs Model Boat Club | Contact Us</title>
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-dark">
<div class="container-fluid">
<h1>Largs Model Boat Club</h1>
<a class="navbar-brand" href="index.html"><img src="images/LMRCupsc-
removebg2.png" alt="Largs Model Boat Club Logo" style="width:200px;"></a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="gallery.html">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="history.html">History</a>
</li>
<li class="nav-item">
<a class="nav-link" href="news.html">News & Events</a>
</li>
<li class="nav-item">
<a class="nav-link" href="aboutlargs.html">About Largs</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="contactus.php">Contact
Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
</ul>
</div>
</nav>
</header>
<main>
<?php
if($message_sent):
?>
<h2>Thank you, we shall be in touch soon.</h2>
<?php
else:
?>
<section id="contact">
<div class="container-lg">
<div class="">
<h1 class="title">Contact Us</h1>
<hr>
<div class="row justify-content-center my-5">
<div class="col-lg-6">
<form class="form" name="form" autocomplete="off" method="POST"
action="contactus.php">
<label class="form-label" for="name" style="color:
white;">Name:</label>
<input class="form-control mb-2" id="name" type="text"
name="name" required>
<label class="form-label mt-3" for="email" style="color:
white;">Email Address: <span class="tooltip" data-tooltip="Please enter your
email address">?</span></label>
<input class="form-control" id="email" type="email"
placeholder="e.g. name:example.com" name="email" required>
<label class="form-label" for="subject" style="color:
white;">Subject:</label>
<input class="form-control mb-2" id="subject" type="text"
name="subject">
<div class="form-floating mb-5 mt-5">
<textarea id="query" class="form-control" name="message"
style="height: 250px; overflow-y: visible;"></textarea>
<label for="query" class="textlab">Type your message
here: <span class="tooltip" data-tooltip="Type your message here">?</span>
</label>
</div>
<div class="form-floating mb-5 mt-5">
<textarea id="query" class="form-control" name="mark"
style="height: 100px;"></textarea>
<label for="query" class="textlab">How did you hear
about us?:<span class="tooltip" data-tooltip="Just a few words on how you
found our website and heard about our club">?</span></label>
</div>
<p>
<!--Instert recaptcha here? -->
</p>
<div class="mb-4 text text-center">
<button type="submit" id="conbtn" class="btn btn-light
btn-lg btn-block">Send Now!</button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<a href="https://en.wikipedia.org/wiki/Longship"><img
src="images/vikinggif.gif" id="vikinganim" alt="row, row, row your boat"
style="width: 300px; margin-left: 425px; margin-right: auto;"></a>
</main>
<div class="bg-image"></div>
<footer>
<p id="foot_statement">Largs Model Boat Club © 2022 | Designed & Developed
by EassonWeb.com</p><br>
<a href="https://en.wikipedia.org/wiki/International_maritime_signal_flags"><img
src="images/LMBC_alphapng.png" id="LMBC_flags" style="width: 400px;"></a>
<div class="container-fluid">
<ul class="nav navbar-expand-sm" id="footer-menu">
<li class="nav-item">
<a class="nav-link" href="gallery.html">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="history.html">History</a>
</li>
<li class="nav-item">
<a class="nav-link" href="news.html">News & Events</a>
</li>
<li class="nav-item">
<a class="nav-link" href="aboutlargs.html">About Largs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">Home</a>
</li>
</ul>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</body>
</html>
Instead .+ you have to use .= in this line: $body .+ "From: ".$userName. "\r\n";
UPD: the main issue here is mail function.
Look at the docs: https://www.php.net/manual/en/function.mail.php
It requires 3 arguements:
string $to,
string $subject,
string $message
But in your code only 2 argements are passed: mail($to, $body);
typos:
You can look at highlighted code and see that $body .= "Email: ".userEmail. "\r\n"; looks different rather than it's neighbors.
userEmail lacks it's $ to be a variable :)
$message_sent = 'false'; => $message_sent = false;
$body .+ "From: ".$userName. "\r\n"; => $body .= "From: ".$userName. "\r\n";
I'm fairly new and was wondering if anyone could help. I've just uploaded all website files via filezilla to a web hosting company and the contact form isn't working. I've tried looking into this but I can seem to find out why. Are you able to have a look at my code and see if I'm perhaps missing something.
The Contact Form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="description" content="Contact Protekt Insurance Brokers. For more information and questions you have">
<meta name="keywords" content="insurance companies, cheap car insurance, insurance brokers, insurance, personal insurance, business insurance, home insurance, life insurance, insurance agency, car insurance, insurance quotes, cheap insurance, liability insurance">
<meta name="author" content="Vaughan Testa">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" integrity="sha256-h20CPZ0QyXlBuAw7A+KluUYx/3pK+c7lYEpqLTlxjYQ=" crossorigin="anonymous" />
<link rel="stylesheet" href="css/utilities.css" />
<link rel="stylesheet" href="css/style.css" />
<title>Contact Protekt | Protekt Insurance Brokers</title>
</head>
<body id="home">
<header class="hero blog">
<div id="navbar" class="navbar top">
<h1 class="logo">
<span class="text-primary">Protekt </span>Insurance Brokers</h1>
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Services</li>
<li>Documentation</li>
<li>Contact</li>
</ul>
</nav>
</div>
<div class="content">
<h1 class="text-primary">Contact Us By Email</h1>
</div>
</header>
<main>
<section id="contact" class="contact flex-columns">
<div class="row">
<div class="column">
<div class="column-1">
<img src="images/blogger-336371_1920.jpg" alt="" />
</div>
</div>
<div class="column">
<div class="column-2 bg-light">
<h2>Contact Us By Email</h2>
<form action="process.php" method="POST" id="contact_form" class="callback-form">
<div class="form-control">
<label for="name"></label>
<input type="text" name="name" id="name" placeholder="Enter name" />
</div>
<div class="form-control">
<label for="email"></label>
<input type="email" name="email" id="email" placeholder="Enter email" />
</div>
<div class="form-control">
<label for="phone"></label>
<input type="text" name="phone" id="phone" placeholder="Enter phone" />
</div>
<input type="submit" value="Send" id="submit" class="btn" />
</form>
</div>
</div>
</div>
</section>
<section id="about" class="icons bg-primary">
<h2 class="about-h2">Contact Details</h2>
<div class="flex-items">
<div class="flex-item1">
<i class="fas fa-phone fa-2x"></i>
<div>
<h3>Contact Info</h3>
<p>
Telephone: (09) 475 6602 <br>International Callers: +649 475 6602
</p>
</div>
</div>
<div class="flex-item2">
<i class=" fas fa-envelope fa-2x "></i>
<div>
<h3>Email Info</h3>
<p>
E-mail: enquiry#protekt.co.nz
</p>
</div>
</div>
<div class="flex-item3">
<i class="fas fa-address-card fa-2x"></i>
<div>
<h3>Office Location</h3>
<p>
103 Glenvar Road, <br>Torbay, Auckland 0630 <br>New Zealand <br><br>Postal Address<br>PO Box 35962 <br>Browns Bay <br>Auckland 0753 <br>New Zealand
</p>
</div>
</div>
</div>
</section>
<section id="boxes">
<div class="container-boxes">
<div class="box">
<img src="images/steadfast.gif" alt="">
</div>
<div class="box">
<img src="images/ANZ.gif" alt="">
</div>
<div class="box">
<img src="images/IBANZ.gif" alt="">
</div>
</div>
</section>
</main>
<footer class="footer bg-dark">
<div class="social">
<i class="fab fa-facebook fa-2x"></i>
<i class="fab fa-twitter fa-2x"></i>
<i class="fab fa-linkedin fa-2x"></i>
</div>
<p>Copyright © 2020 - Designed By: Vaughan Testa</p>
</footer>
<script>
const navbar = document.getElementById('navbar');
let scrolled = false;
window.onscroll = function() {
if (window.pageYOffset > 100) {
navbar.classList.remove('top');
if (!scrolled) {
navbar.style.transform = 'translateY(-70px)';
}
setTimeout(function() {
navbar.style.transform = 'translateY(0)';
scrolled = true;
}, 200);
} else {
navbar.classList.add('top');
scrolled = false;
}
};
</script>
</body>
</html>
My PHP Code
<?php
if(!$_POST) exit;
$email = $_POST['email'];
error_reporting(error_reporting() & ~E_DEPRECATED);
//$error[] = preg_match('/\b[A-Z0-9._%-]+#[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."#"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
$error.="Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$values = array ('name','email','message');
$required = array('name','email','message');
$your_email = "enquiry#protekt.co.nz";
$email_subject = "New Message: ".$_POST['subject'];
$email_content = "new message:\n";
foreach($values as $key => $value){
if(in_array($value,$required)){
if ($key != 'subject' && $key != 'company') {
if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
}
$email_content .= $value.': '.$_POST[$value]."\n";
}
}
if(#mail($your_email,$email_subject,$email_content)) {
echo 'Message sent!';
} else {
echo 'ERROR!';
}
}
?>
This is my html code. It dynamically creates these textboxes but they all have the same name.
<?php
include 'db.php';
$office = $_GET['office'];
$application_name = $_GET['application_name'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Add Requirements for New Application</title>
<!-- Bootstrap core CSS -->
<link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/sidebar.css" rel="stylesheet">
<script type="text/javascript" src="//code.jquery.com/jquery-latest.js"></script>
<script src="js/jquery.min.js"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>
<!-- Bootstrap css library -->
</head>
<style>
.header--banner {
background-image: url(cb.jpg);
background-size:100% 100%;
background-repeat: no-repeat;
}
.header--banner {
height: 45.5rem;
}
.jumbotron{
padding: 0.5em 0.6em;
}
.header--banner {
background-image: url(magic.jpg);
background-size:100% 100%;
background-repeat: no-repeat;
}
.header--banner {
height: 45.5rem;
}
.jumbotron{
padding: 0.5em 0.6em;
position: relative;
text-align: center;
color: black;
}
.green{
text-decoration: none;
font-family: Modern;
font-size: 18px;
border-radius: 5px;
padding: 5px 8px;
background-color: #27ae60;
color: #ffffff;
}
a.green:hover{
text-decoration: none;
background-color: #145a32;
color: #ffffff;
transition: 0.7s;
}
.bs-example2{
border: 3px solid black;
background: #f5f5f5;
text-align: center;
padding:20px;
margin:5px;
height:200px;
}
</style>
<body>
<header class="header--banner">
<div id="wrapper">
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="sidebar-brand">
<a href="kiosk-HOMEPAGE.php">
HOME
</a>
</li>
<li>
Offices
</li>
<li>
Employees
</li>
<li>
Change Username & Password
</li>
<li>
Reports
</li>
<li>
Log Out
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<!-- Page Content -->
<div id="page-content-wrapper">
<div class="jumbotron">
<div class="container-fluid">
<img src="urdBanner.jpg" id="urdBanner" alt="Banner" style="width:100%; height:250px;">
<center><h2 style="position:relative;">Requirements</h2></center>
<p></p>
<img src="menu.jpg" class="rounded-circle" style="width:30px; height:30px;">
<br>
<br>
Previous
<br>
<br>
<form method="get" action="kiosk-NEW_CHARTER_REQUIREMENTS_insert.php">
<input type="hidden" name="office" value="<?php echo $office ?>">
<input type="hidden" name="application_name" value="<?php echo $application_name ?>">
<br>
<div class="row form-group">
<div class="col-md-2"><label for="textBox" class="col-form-label"><b>Step By Step Procedure</b></label>
</div>
<div class="col-md-2"><label for="textBox" class="col-form-label"><b>Personnel in charge</b></label>
</div>
<div class="col-md-2"><label for="textBox" class="col-form-label"><b>Time needed to complete procedure</b></label>
</div>
<div class="col-md-2"><label for="textBox" class="col-form-label"><b>Amount of fees if any</b></label>
</div>
<div class="col-md-2"><label for="textBox" class="col-form-label"><b>Required Documents</b></label>
</div>
<div class="col-md-2"><label for="textBox" class="col-form-label"><b>Procedure for the filing of complaints</b></label>
</div>
</div>
</div>
<div class="form-group fieldGroup">
<div class="input-group">
<div class="col-md-2">
<textarea name="steps[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Steps"></textarea>
</div>
<div class="col-md-2">
<textarea name="personnel[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Personnel"></textarea>
</div>
<div class="col-md-2">
<textarea name="time[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Time"></textarea>
</div>
<div class="col-md-2">
<textarea name="fees[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Fees"></textarea>
</div>
<div class="col-md-2">
<textarea name="documents[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Documents"></textarea>
</div>
<div class="col-md-2">
<textarea name="complaints[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Complaints"></textarea>
</div>
<div class="input-group-addon">
<span class="glyphicon glyphicon glyphicon-plus" aria-hidden="true"></span> Add
</div>
</div>
</div>
<!-- copy of input fields group -->
<div class="form-group fieldGroupCopy" style="display: none;">
<div class="input-group">
<div class="col-md-2">
<textarea name="steps[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Steps"></textarea>
</div>
<div class="col-md-2">
<textarea name="personnel[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Personnel"></textarea>
</div>
<div class="col-md-2">
<textarea name="time[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Time"></textarea>
</div>
<div class="col-md-2">
<textarea name="fees[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Fees"></textarea>
</div>
<div class="col-md-2">
<textarea name="documents[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Documents"></textarea>
</div>
<div class="col-md-2">
<textarea name="complaints[]" class="form-control" onkeyup="AutoGrowTextArea(this)" placeholder="Complaints"></textarea>
</div>
<div class="input-group-addon">
<span class="glyphicon glyphicon glyphicon-remove" aria-hidden="true"></span> Remove
</div>
</div>
</div>
<input type="submit" name="submit" class="btn btn-primary" value="SUBMIT"/>
</form>
</div>
</div>
</div>
</div>
</header>
<script type="text/javascript">
$(document).ready(function(){
//group add limit
var maxGroup = 10;
//add more fields group
$(".addMore").click(function(){
if($('body').find('.fieldGroup').length < maxGroup){
var fieldHTML = '<div class="form-group fieldGroup">'+$(".fieldGroupCopy").html()+'</div>';
$('body').find('.fieldGroup:last').after(fieldHTML);
}else{
alert('Maximum '+maxGroup+' groups are allowed.');
}
});
//remove fields group
$("body").on("click",".remove",function(){
$(this).parents(".fieldGroup").remove();
});
});
</script>
<script type="text/javascript">
// Auto-Grow-TextArea script.
// Script copyright (C) 2011 www.cryer.co.uk.
// Script is free to use provided this copyright header is included.
function AutoGrowTextArea(textField)
{
if (textField.clientHeight < textField.scrollHeight)
{
textField.style.height = textField.scrollHeight + "px";
if (textField.clientHeight < textField.scrollHeight)
{
textField.style.height =
(textField.scrollHeight * 2 - textField.clientHeight) + "px";
}
}
}
</script>
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Menu Toggle Script -->
<script>
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
</script>
</body>
</html>
this is my insert.php
<?php
if(isset($_GET['submit'])){
$con = mysqli_connect('localhost','root','','information_kiosk');
$office = $_GET['office'];
$application_name = $_GET['application_name'];
$steps = $_GET['steps'];
$personnel = $_GET['personnel'];
$time = $_GET['time'];
$fees = $_GET['fees'];
$documents = $_GET['documents'];
$complaints = $_GET['complaints'];
$totalSize = sizeof($steps);
for($i=0;$i <=$totalSize;$i++) {
$InsertSteps = (!empty($steps[$i])) ? $steps[$i] : '';
$InsertPersonnel = (!empty($personnel[$i])) ? $personnel[$i] : '';
$InsertTime = (!empty($time[$i])) ? $time[$i] : '';
$InsertFees = (!empty($fees[$i])) ? $fees[$i] : '';
$InsertDocuments = (!empty($documents[$i])) ? $documents[$i] : '';
$InsertComplaints = (!empty($complaints[$i])) ? $complaints[$i] : '';;
echo $InsertSteps;
echo "<br>";
echo $InsertPersonnel;
echo $InsertSteps;
echo "<br>";
}
}
?>
*update. with my insert code now it only shows the first row of data but not the 2nd or 3rd
only the first row gets inserted into database but the following dynamically created rows dont. My question is how could i change my syntax so that each row would insert into the database for example.
stepsColumn PersonnelColumn timeColumn feesColumn documentsColumn
array[0] array[0] array [0] array[0] array[0]
array[1] array[1] array [1] array[1] array[1]
In my project im getting such kind of error when im trying to redirect to another page when the person submit the contact form then it should redirect to some other page but im getting such kind of error. the error what im getting is this
warning: Cannot modify header information - headers already sent by
(output started at C:\xampp\htdocs\grade\header.php:89) in
C:\xampp\htdocs\grade\contact.php on line 64
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>SAMSON SOLAR ENERGY</title>
<!-- Meta tag Keywords -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta name="keywords" content="Grade Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template,
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript">
addEventListener("load", function () {
setTimeout(hideURLbar, 0);
}, false);
function hideURLbar() {
window.scrollTo(0, 1);
}
</script>
<!--// Meta tag Keywords -->
<!-- css files -->
<link rel="stylesheet" href="css/bootstrap.css"> <!-- Bootstrap-Core-CSS -->
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" /> <!-- Style-CSS -->
<link rel="stylesheet" href="css/fontawesome-all.css"> <!-- Font-Awesome-Icons-CSS -->
<!-- //css files -->
<!----->
<link rel="stylesheet" href="css/flexslider.css" type="text/css" media="all" /><!-- for testimonials -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<!--web font-->
<link href="//fonts.googleapis.com/css?family=Source+Sans+Pro:200,200i,300,300i,400,400i,600,600i,700,700i,900,900i&subset=cyrillic,cyrillic-ext,greek,greek-ext,latin-ext,vietnamese" rel="stylesheet">
<!--//web font-->
</head>
<body>
<!-- header -->
<header>
<div class="container">
<nav class="navbar navbar-expand-lg navbar-light">
<a class="navbar-brand" href="index.html">
<span class="fa fa-strikethrough"></span> SAMSON SOLAR
</a>
<button class="navbar-toggler ml-md-auto" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-auto text-center">
<li class="nav-item active mr-lg-3">
<a class="nav-link" href="index.php">Home<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item mr-lg-3">
<a class="nav-link" href="about.php">about</a>
</li>
<li class="nav-item mr-lg-3">
<a class="nav-link" href="gallery.php">Gallery</a>
</li>
<li class="nav-item dropdown mr-lg-3">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Products</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="domestic.php">Domestic</a>
<a class="dropdown-item" href="commercial.php">Commercial</a>
<a class="dropdown-item" href="other.php">Other Products</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">contact</a>
</li>
</ul>
<div class="buttons">
<p><i class="fas mr-1 fa-phone"></i> +91 99161 67190</p>
</div>
</div>
</nav>
</div>
<div class="icon-bar">
<i class="fa fa-facebook"></i>
<i class="fa fa-twitter"></i>
<i class="fa fa-google"></i>
<i class="fa fa-linkedin"></i>
<i class="fa fa-youtube"></i>
</div>
</header>
<!-- //header -->
contact.php
<?php include 'header.php'; ?>
<!-- banner -->
<section class="inner-banner">
<div class="banner-layer">
<h1 class="text-center">Contact Page</h1>
</div>
</section>
<!-- //banner -->
<?php
include_once 'connect.php';
$nameErr = $emailErr = $contactErr = "";
$name = $email = $contact = $subject = "";
if (isset($_POST['submit']))
{
//Name
if (empty($_POST["name"])) {
$nameErr = "Please enter your Name";
}
else{
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Sorry Only letters are allowed";
}
}
//E-mail ID
if (empty($_POST["email"])) {
$emailErr = "Please enter your E-mail ID";
}
else{
$email = test_input($_POST["email"]);
// check if the entered Email-id is valid or not
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Please enter a valid E-mail ID";
}
}
//Contact Number
if (empty($_POST["phone"])) {
$contactErr = "Please enter your Contact Number";
}
else{
$contact = test_input($_POST["phone"]);
// check weather the contact number is valid or not
if (!preg_match("/^[0-9]+$/",$contact)) {
$contactErr = "Please enter Your 10 Digit mobile Number";
}
}
//Reason For contacting
if (!empty($_POST["subject"])) {
$subject = test_input($_POST["subject"]);
}
if($nameErr == "" && $emailErr == "" && $contactErr == ""){
$sql = "INSERT INTO contact(`ID`,`Name`, `Email`, `Contact_no` , `Reason`)
VALUES ('','".$name."', '".$email."', '".$contact."' , '".$subject."')";
if (mysqli_query($mysqli, $sql)) {
header("location:contact_success.php");
exit();
}
else{
echo "Error: " . $sql . "<br>" . mysqli_error($mysqli);
}
mysqli_close($mysqli);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!-- contact -->
<section class="contact py-5">
<div class="container">
<h2 class="heading mb-lg-5 mb-4">Contact Us</h2>
<div class="row contact-grids w3-agile-grid">
<div class="row col-md-6 col-sm-6 contact-grid1 w3-agile-grid">
<div class="col-3 text-center">
<i class="fa fa-commenting-o" aria-hidden="true"></i>
</div>
<div class="col-9 p-0">
<h4>Get In Touch</h4><br>
<p><b>Mobile:</b> +91 9916167190</p>
<p><b>E-mail:</b> abpaple#gmail.com</p>
</div>
</div>
<div class="row col-md-6 col-sm-6 mt-sm-0 mt-4 contact-grid1 w3-agile-grid">
<div class="col-3 text-center">
<i class="fa fa-map-marker" aria-hidden="true"></i>
</div>
<div class="col-9 p-0">
<h4>Visit Our Location</h4><br>
<p><b>SAMSON SOLAR ENERGY</b></p>
<p>#02, K.E.Board Complex, Navalgund Road, Shivaji Circle</p>
<p>DHARWAD-580008, KARNATAKA, INDIA</p>
</div>
</div>
</div><br><br>
<div class="row">
<div class="col-lg-7 col-md-7 col-sm-12 col-xs-12">
<div class="gmap_canvas">
<iframe width="100%" height="475" id="gmap_canvas" src="https://maps.google.com/maps?q=SAMSON%20SOLAR%20ENERGY%20%20%2302%2C%20K.E.Board%20Complex%2C%20Navalgund%20Road%2C%20Shivaji%20Circle%20%20DHARWAD-580008%2C%20KARNATAKA%2C%20INDIA&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
</div>
</div>
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12">
<h2 style="margin-bottom:15px">Write To Us</h2>
<form action="" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Name" name="name" value="<?php if (isset($name)) echo $name; ?>">
<span style="color:red;"> <?php echo $nameErr;?></span>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Enter E-mail" name="email" value="<?php if (isset($email)) echo $email; ?>">
<span style="color:red;"> <?php echo $emailErr;?></span>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Contact Number" name="phone" value="<?php if (isset($contact)) echo $contact; ?>">
<span style="color:red;"> <?php echo $contactErr;?></span>
</div>
<div class="form-group">
<textarea class="form-control" rows="4" placeholder="Enter Reason For Contacting" name="subject"><?php if (isset($subject)) echo $subject; ?></textarea>
</div>
<button type="submit" class="btn btn-primary pull-right" name="submit">Submit</button>
</form>
</div>
</div>
</div>
</section>
<!-- //contact -->
<?php include 'footer.php'; ?>
please can any one help me to solve my issue
There are lots of reason for the error: Cannot modify header information - headers already sent below are some of them:
print and echo statements will terminate the opportunity to send HTTP headers
<html> before any header() call.
Whitespace before <?php
Whitespace after ?>
Preceding error messages can also be a cause of this error.
If You want to check all reasons in detail then here is referenced stackoveflow answer
But for you the reason of this error is that, you have included Raw sections prior
to <?php code, you can not include html before php code.
In your code you are including header.php and <section> which is html, before php code therefor you are getting this error, so for solving it change your
contact.php file as below
<?php
include_once 'connect.php';
$nameErr = $emailErr = $contactErr = "";
$name = $email = $contact = $subject = "";
if (isset($_POST['submit']))
{
//Name
if (empty($_POST["name"])) {
$nameErr = "Please enter your Name";
}
else{
$name = test_input($_POST["name"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
$nameErr = "Sorry Only letters are allowed";
}
}
//E-mail ID
if (empty($_POST["email"])) {
$emailErr = "Please enter your E-mail ID";
}
else{
$email = test_input($_POST["email"]);
// check if the entered Email-id is valid or not
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Please enter a valid E-mail ID";
}
}
//Contact Number
if (empty($_POST["phone"])) {
$contactErr = "Please enter your Contact Number";
}
else{
$contact = test_input($_POST["phone"]);
// check weather the contact number is valid or not
if (!preg_match("/^[0-9]+$/",$contact)) {
$contactErr = "Please enter Your 10 Digit mobile Number";
}
}
//Reason For contacting
if (!empty($_POST["subject"])) {
$subject = test_input($_POST["subject"]);
}
if($nameErr == "" && $emailErr == "" && $contactErr == ""){
$sql = "INSERT INTO contact(`ID`,`Name`, `Email`, `Contact_no` , `Reason`)
VALUES ('','".$name."', '".$email."', '".$contact."' , '".$subject."')";
if (mysqli_query($mysqli, $sql)) {
header("location:contact_success.php");
exit();
}
else{
echo "Error: " . $sql . "<br>" . mysqli_error($mysqli);
}
mysqli_close($mysqli);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<?php include 'header.php'; ?>
<!-- banner -->
<section class="inner-banner">
<div class="banner-layer">
<h1 class="text-center">Contact Page</h1>
</div>
</section>
<!-- //banner -->
<!-- contact -->
<section class="contact py-5">
<div class="container">
<h2 class="heading mb-lg-5 mb-4">Contact Us</h2>
<div class="row contact-grids w3-agile-grid">
<div class="row col-md-6 col-sm-6 contact-grid1 w3-agile-grid">
<div class="col-3 text-center">
<i class="fa fa-commenting-o" aria-hidden="true"></i>
</div>
<div class="col-9 p-0">
<h4>Get In Touch</h4><br>
<p><b>Mobile:</b> +91 9916167190</p>
<p><b>E-mail:</b> abpaple#gmail.com</p>
</div>
</div>
<div class="row col-md-6 col-sm-6 mt-sm-0 mt-4 contact-grid1 w3-agile-grid">
<div class="col-3 text-center">
<i class="fa fa-map-marker" aria-hidden="true"></i>
</div>
<div class="col-9 p-0">
<h4>Visit Our Location</h4><br>
<p><b>SAMSON SOLAR ENERGY</b></p>
<p>#02, K.E.Board Complex, Navalgund Road, Shivaji Circle</p>
<p>DHARWAD-580008, KARNATAKA, INDIA</p>
</div>
</div>
</div><br><br>
<div class="row">
<div class="col-lg-7 col-md-7 col-sm-12 col-xs-12">
<div class="gmap_canvas">
<iframe width="100%" height="475" id="gmap_canvas" src="https://maps.google.com/maps?q=SAMSON%20SOLAR%20ENERGY%20%20%2302%2C%20K.E.Board%20Complex%2C%20Navalgund%20Road%2C%20Shivaji%20Circle%20%20DHARWAD-580008%2C%20KARNATAKA%2C%20INDIA&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>
</div>
</div>
<div class="col-lg-5 col-md-5 col-sm-12 col-xs-12">
<h2 style="margin-bottom:15px">Write To Us</h2>
<form action="" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Name" name="name" value="<?php if (isset($name)) echo $name; ?>">
<span style="color:red;"> <?php echo $nameErr;?></span>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Enter E-mail" name="email" value="<?php if (isset($email)) echo $email; ?>">
<span style="color:red;"> <?php echo $emailErr;?></span>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Enter Contact Number" name="phone" value="<?php if (isset($contact)) echo $contact; ?>">
<span style="color:red;"> <?php echo $contactErr;?></span>
</div>
<div class="form-group">
<textarea class="form-control" rows="4" placeholder="Enter Reason For Contacting" name="subject"><?php if (isset($subject)) echo $subject; ?></textarea>
</div>
<button type="submit" class="btn btn-primary pull-right" name="submit">Submit</button>
</form>
</div>
</div>
</div>
</section>
<!-- //contact -->
<?php include 'footer.php'; ?>
And if problem remains the same after changing file as above then try to separate html file contact.php and make new php process file like contact_process.php and add php processing code only in contact_process.php.
Instead of
if (mysqli_query($mysqli, $sql)) {
header("location:contact_success.php");
exit();
}
You could do this:
if (mysqli_query($mysqli, $sql)) {
echo "<script>window.location.href = 'contact_success.php';</script>";
exit();
}
May not be conventional but it should work.
I have searched on this forum for a solution and other places as well. But I can't find the problem with the code I wrote. The php file called Email_Service.php looks like this:
<?php
////////////////////////////////////////
// [Email-Service] v3.5 /
//////////////////////////////////////
//Email Service Class
class EmailService {
//Properties
private $email_basis;
private $type;
//Constructor
function __construct($type) {
echo '[EmailService] type: ' . $type;
}
//Send Email function with passed on arrays from test_pagina.php
function versturen($emailInfo, $klantInfo) {
//Email info
$email_van = $emailInfo['email_van'];
$email_naar = $emailInfo['email_naar'];
$email_onderwerp = $emailInfo['email_onderwerp'];
//Controleer of het opgegeven email adres geldig is en geen rare tekens bevat
$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i";
if (preg_match($pattern, trim(strip_tags($emailInfo['email_van'])))) {
$cleanedFrom = trim(strip_tags($emailInfo['email_van']));
} else {
return "The email address you entered was invalid. Please try again!";
}
//Hier word de email_template geopend voor elke type.
//Zorg vraag formulier
if ($emailInfo['type'] == 'zorgvraag') {
//$email_basis = file_get_contents(base_url() . 'include/email_template_zorgvraag.txt'); //(LOKAAL)
//file_get_contents(base_url() . "assets/email_template.txt"); //(ONLINE)
} else if ($emailInfo['type'] == 'aanmelden') {
//$email_basis = file_get_contents(base_url() . 'mail_php/email_template_aanmeldformulier.txt'); //(LOKAAL)
}
//Personaliseer de email door de velden te vervangen met de ingevulde parameters
$email_basis = str_replace("f_voornaam", $klantInfo['voornaam'], $email_basis);
$email_basis = str_replace("f_achternaam", $klantInfo['achternaam'], $email_basis);
$email_basis = str_replace("f_telefoon", $klantInfo['telefoon'], $email_basis);
$email_basis = str_replace("f_email", $klantInfo['email_van'], $email_basis);
$email_basis = str_replace("f_bericht", $klantInfo['$bericht'], $email_basis);
$email_basis = str_replace("f_locatie", $klantInfo['$locatie'], $email_basis);
//Genereer headers
$headers = "From: " . $cleanedFrom . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['f_email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
//Hier word de mail verstuurd als alles goed is
if (mail($emailInfo['email_naar'], $emailInfo['email_onderwerp'], $email_basis, $headers)) {
//CC
mail('info#yourdomain.nl', $emailInfo['email_onderwerp'], $email_basis, $headers);
} else {
echo 'Er is iets fout gegaan. Probeer het later nog een keer!';
die();
}
}
}
?>
It's called from another php file called test_pagina.php which looks like this:
<?php
include 'https://yourdomain.nl/assets/Email_Service.php'; //ONLINE
//require base_url() . 'assets/Email_Service.php'; //LOKAAL
//Haal gemeeente uit de adres balk
$url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url_onderdeel = explode('/', $url);
$gemeente = $url_onderdeel[4];
$gemeenteHoofdletter = ucfirst($gemeente);
//Email parameters
$email_van; $email_naar; $email_onderwerp = "Vraag van ". $gemeenteHoofdletter;
$voornaam; $achternaam;
$telefoon; $bericht;
$emailInfo; $klantInfo;
//Controleert de ingevulde velden
if (isset($_POST['f_email_van']) ||
isset($_POST['f_voornaam']) ||
isset($_POST['f_achternaam']) ||
isset($_POST['f_telefoon']) ||
isset($_POST['f_bericht'])) {
//Email info
$email_van = $_POST['f_email_van'];
$email_naar = "socialekaartpro#gmail.com";
/*Stuur Email
Dé Parameters:(emailInfo, klantInfo)*/
$emailInfo = array (
'email_van' => $email_van,
'email_naar' => $email_naar,
'email_onderwerp' => $email_onderwerp);
$klantInfo = array (
'voornaam' => $_POST['f_voornaam'],
'achternaam' => $_POST['f_achternaam'],
'telefoon' => $_POST['f_telefoon'],
'bericht' => $_POST['f_bericht'],
'locatie' => $gemeenteHoofdletter);
//Voeg de mail script toe zodat we de functie stuurEmail kunnen aanroepen
$mail = new EmailService('zorgvraag');
$mail -> versturen($emailInfo, $klantInfo);
}
?>
<!--=== Type Woning ===-->
<div class="page-topbar">
<div class="container">
<div class="row">
<div class="col-sm-4">
<h3>Bedrijfsnaam</h3>
</div>
<div class="col-sm-8 hidden-xs">
<ol class="breadcrumb">
<li>Gemeente Nijmegen</li>
<li>Woningverhuur</li>
<li class="active">Bedrijfsnaam</li>
</ol>
</div>
</div>
</div>
</div>
<div class="content container" style="padding-top: 10px;">
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading left" style="margin-bottom: -1px;background-color: rgba(255, 255, 255, 0);"><i class="glyphicon glyphicon-menu-left"></i> Terug naar overzicht
<ul class="pull-right">
<i class="fa fa-print" aria-hidden="true"></i>Print
</ul>
</div>
</div>
</div>
</div>
</div>
<!--================================== Overzicht ========================-->
<div class="job-description">
<div class="container content">
<div class="row">
<div class="col-md-8">
<div class="left-inner" style="margin-left: 0px;">
<h3 style="margin-top: 28px;margin-bottom: 12px;">Test pagina</h3>
<p>
LEEG LEEG
</p>
<h3 style="margin-top: 40px;margin-bottom: 12px;">LEEG LEEG</h3>
<p>
LEEG LEEG
</p>
<h3 style="margin-top: 40px;margin-bottom: 12px;">LEEG LEEG</h3>
<p>
LEEG LEEG
</p>
<h3 style="margin-top: 40px;margin-bottom: 12px;">LEEG LEEG</h3>
<p>
LEEG LEEG
</p>
<br>
<br>
Naar de website LEEG LEEG
<br>
</div>
</div>
<div class="col-sm-4">
<div class="panel panel-default" style="margin-top: 9px;">
<div class="panel-heading" style="border-bottom-color: rgba(217, 217, 217, 0);margin-top: 2px;">Doelgroep</div>
<div class="panel-body">
<div class="row">
<p style="margin-top: -22px;margin-left: 16px;padding-right: 7px;">
LEEG | LEEG
</p>
</div>
</div>
<div class="panel-heading" style="border-bottom-color: rgba(217, 217, 217, 0);margin-top: -14px;">Leeftijdscatogarie</div>
<div class="panel-body">
<div class="row">
<p style="margin-top: -22px;margin-left: 16px;margin-bottom: 2px;">
LEEG | LEEG
</p>
</div>
</div>
</div>
<div class="panel panel-default" style="margin-top: 9px;">
<div class="panel-heading" style="border-bottom-color: rgba(217, 217, 217, 0);margin-bottom: -15px;">Contact gegevens</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-4 col-md-4">
<p style="font-weight: 600;color: #000000;margin-bottom: 0px;">Naam</p>
<p style="font-weight: 600;color: #000000;margin-bottom: 0px;">Adres</p>
<p style="font-weight: 600;color: #000000;margin-bottom: 0px;">Postcode</p>
<p style="font-weight: 600;color: #000000;margin-bottom: 0px;">Plaats</p>
<p style="font-weight: 600;color: #000000;margin-bottom: 0px;">Telefoon</p>
</div>
<div class="col-xs-6 col-md-6" style="width: 65%;">
<p style="margin-bottom: 0px;">LEEG</p>
<p style="margin-bottom: 0px;">LEEG</p>
<p style="margin-bottom: 0px;">LEEG</p>
<p style="margin-bottom: 0px;">LEEG</p>
<p style="margin-bottom: 0px;">LEEG</p>
</div>
</div>
<hr style="margin-top: 20px;margin-bottom: 10px;">
<div class="row">
<div class="col-md-12">
<div class="panel-heading" style="margin-left: -15px;margin-top: -12px;margin-bottom: -15px;">
<h4 class="panel-title">
<span style="font-size: 13px;font-weight: 600;">Heeft u een zorgvraag, </span>
<a href="#mail-1" data-parent="#accordion-v1" data-toggle="collapse" class="accordion-toggle">
<span style="color: #3299bb;font-weight: 600;text-decoration: underline;"> klik dan hier</span>
</a>
</h4>
</div>
<!--Bevestiging script JSalert
<div>
<script src="https://socialekaartgemeente.nl/assets/js/sweetalert-dev.js"></script>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<link rel="stylesheet" href="https://socialekaartgemeente.nl/assets/css/sweetalert.css">
<script type="text/javascript">
function JSalert(){
//event.preventDefault();;
swal("Congrats!", ", Uw mail is verzonden!", "success");
}
</script>
</div>-->
<!-- =============================[EMAIL FORM]================================== -->
<!-- onSubmit="window.location.reload()" -->
<!-- ="javascript:JSalert();" -->
<div class="panel-collapse collapse" id="mail-1">
<div class="panel-body" style="margin-left: -15px;">
<form action="" method="post" id="form_mail" >
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<input id="voornaam" type="text" name="f_voornaam" class="form-control" placeholder="Voornaam*" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input id="achternaam" type="text" name="f_achternaam" class="form-control" placeholder="Achternaam*" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input id="telefoon" type="text" name="f_telefoon" class="form-control" placeholder="Telefoonnummer*" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<input id="email" type="text" name="f_email_van" class="form-control" placeholder="Email*" required="required" data-error="Firstname is required.">
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="form-group">
<label class="sr-only" for="message">Bericht</label>
<textarea class="input-lg form-control" name="f_bericht" rows="5" id="bericht" placeholder="Uw zorgvraag"></textarea>
<span class="help-block"></span>
</div>
<!--Verzend knop-->
<button type="submit" class="btn btn-sm btn-primary" style="margin-bottom: -15px;">Bericht verzenden</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default" style="margin-top: 9px;">
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<ul class="social-icons pull-left" style="margin-left: -2px;margin-top: 4px;margin-bottom: -8px;">
<li style="margin-left: 0px;"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</div>
</div>
<!-- Google Maps -->
<div class="panel panel-default" style="margin-top: 9px;">
<div class="panel-body">
<!-- Laad Google Maps -->
<style>#map-container { height: 200px }</style>
<div id="map-container" class="col-md-12"></div>
<script src="//maps.google.com/maps/api/js?sensor=false"></script>
<script>
function init_map() {
//Definieer de coordinaten en zet zoom level
var var_location = new google.maps.LatLng(00000000, 00000000);
var var_mapoptions = {
center: var_location,
zoom: 14
};
//Plaats de marker bij de coordinaten
var var_marker = new google.maps.Marker({
position: var_location,
map: var_map,
title:"Venice"});
//^Teken the map met de instellingen hierboven^
var var_map = new google.maps.Map(document.getElementById("map-container"),
var_mapoptions);
var_marker.setMap(var_map);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
</div>
</div>
</div>
</div>
</div>
</div>
I keep getting this error:
Fatal error:
Class 'EmailService' not found in (/file location)
Which is in this case uploaded to the server so it can be easily called upon on the whole website. I have never had this problem with writing and using a class. What am I possibly doing wrong? A lot more people have posted the same question about this error before, but they seem to have a different setup.
You can not include file by URL.
You have to use path of File location on server.
This is wrong
include 'https://yourdomain.nl/assets/Email_Service.php'; //ONLINE
//require base_url() . 'assets/Email_Service.php'; //LOKAAL
you have to use absolute or relative path
include "assets/Email_Service.php"; //relative path
include "<directory_path_of_your_project_on_server>/assets/Email_Service.php"; //absolute path
How to get Server file Location
create test.php in your root of with below content
<?php
echo dirname(__FILE__);
die;
execute above from browser, will be display path of your project on server and use that path.