So I have to open my website from a hyperlink in my testdocumentation. I have to do it this way to ensure my test is easy to use. Sadly I seem to be getting very weird behavior from my webpage.
So when you open the link it is supposed to send an email and then respond with a success message and delete all records from the database. This works if you just enter the link in the browser and when you open the hyperlink for a second time.
But when you open the link for the first time (and you do have something in the database) it sends the email but instead of giving a response with success like it should, it instead seems to go trough my else statement after going trough my if statement and it gives response that there are no emails in the database.
so first time clicking the link from word 2007(also from PowerPoint) it does the following
this is my routing
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="stylesheets/style.css">
<title>Ninebits Enquete</title>
</head>
<?php
//Models
require_once '../Models/Model.php';
require_once '../Models/Database.php';
require_once '../Models/Question.php';
require_once '../Models/Survey.php';
require_once '../Models/Mail_Info.php';
require_once '../Models/Mail.php';
require_once '../Models/Answer.php';
//controllers
require_once '../Controllers/surveyController.php';
require_once '../Controllers/mail_infoController.php';
require_once '../Controllers/mailController.php';
require_once '../Controllers/answerController.php';
//views
require_once 'views/surveyView.php';
require_once 'views/finishView.php';
require_once 'views/selectionView.php';
require_once 'views/dashboardView.php';
require_once 'views/previouslySavedView.php';
require_once 'views/errorView.php';
//will get the URL so it can be used for routing
$url = isset($_SERVER['PATH_INFO']) ? explode('/', ltrim($_SERVER['PATH_INFO'],'/')) : '/' ;
//this is where my problem comes from by calling this
if($url == '/' && $_SERVER["REQUEST_METHOD"] === "GET")
{
$mc = new mailController;
$mc->sendMail();
}
else
{
if($url[1] == 'list')
{
$sc = new surveyController();
$mic = new mail_infoController();
$list = $mic->checkadress($_GET['type']);
$sc->displayPage($list);
}
else if($url[1] == 'finish')
{
$ac = new answerController();
$ac->showFinish();
}
else if($url[1] == 'selection')
{
$sc = new surveyController();
$sc->selectionScreen();
}
else if($url[1] == 'dashboard')
{
$ac = new answerController();
$ac->getCalculatedValue($_GET['id']);
}
else
{
header('HTTP/1.1 404 Not Found');
die("<h1>404</h1> pagina $url[1] kunnen wij niet vinden of bestaat niet. ");
}
}
?>
</html>
my function that is called when calling the link
/**
*
*
* sends the email with link to the client.
*/
public function sendMail()
{
$mail = new Mail();
//it goes through here when calling the link the first time from word
if(!$mail->exception)
{
$info = $mail->mails;
foreach ($info as $infoItem)
{
$adress = $infoItem["mailadress"];
if(filter_var($adress, FILTER_VALIDATE_EMAIL) )
{
$hash = $this->createLink($infoItem['client'], $infoItem['survey']);
$mail->mail_info->addMailInfo($infoItem['client'], $hash);
$to = $infoItem["mailadress"];
$subject = "Enquete";
$message = "<html><body>";
$message .= "<h1>Geachte ".$infoItem['client'];
$message .= "</h1>";
$message .= "<h3>Bedankt voor het gebruiken van onze service en producten</h3>";
$message .= "<p>Om ons te laten weten wat u van de service en producten vondt willen wij u graag vragen om de enquete in de link hieronder in te vullen</p>";
$message .= "<a href='https://ontwikkeling.ninebits.nl/lab/stage/danny/Enquete/public/list?type=$hash'>Ninebits Enquete</a>";
$message .= "<br>";
$message .= "<br>";
$message .= "<p>met vriendelijke groet,</p>";
$message .= "<p>Het hele Ninebits team</p>";
$message .= "</body></html>";
$headers = "from: Ninebits\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
$mail->deleteMails($infoItem['id']);
//this is the response I am expecting everything up to here seems to work
echo 'success <br>';
}
else
{
//it does not seem to go in this else here which is good in this case
echo 'Dit is geen correct email adres<br>';
$mail->deleteMails($infoItem['id']);
if($mail->exception)
{
echo $mail->exceptionMessage;
}
}
}
}
//but then it responds with this else here
else
{
echo $mail->exceptionMessage;
}
}
}
The browser console and all the log data I was able to get points to only 1 get call being performed
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
CSS (Cascading Style Sheets) is a formal language for describing the appearance of a document written using a markup language.
It is mainly used as a means of describing, decorating the appearance of web pages written using HTML and XHTML markup languages, but can also be applied to any XML documents, such as SVG or XUL.
https://www.w3.org/TR/CSS/#css
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.