As Ken Lee suggested in the comments, the best way of doing this is to use mail_handler.php itself as a form action. This will become your index.php:
<?php
if(isset($_POST['submit'])){
$to = "[email protected]"; // this is your Email address
$first_name = $_POST['fname'];
$last_name = $_POST['lname'];
$skola = $_POST['vysoka_skola'];
$obor = $_POST['obor'];
$prace = $_POST['prace'];
$files = $_FILES['myfile']['name'];
$kategorie = $_POST['kategorie'];
//echo gettype($files);
$all_thesis_string="";
for($index=0;$index<count($_FILES['myfile']['name']);$index++){
$all_thesis_string.=$_FILES['myfile']['name'][$index].","; //create a string with all bachelor attachments of user
}
$subject = "Form submission of ".$first_name." ".$last_name;
$message = "User Details: \n\n Jméno: $first_name \n Příjmení: $last_name \n Vysoká škola: $skola \n Studijní obor: $obor \n Odkaz na bakalářskou práci: $prace \n Kategorie: $kategorie \n Bakalářská práce: $all_thesis_string";
$headers = "From:" . $first_name;
mail($to,$subject,$message,$headers);
echo "Přihláška úspěšně odeslána. Děkuji " . $first_name . ".\n \n";
include 'upload.php';
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
<!-- The Form Section -->
<div style="background-color: #5A5377" id="form_section">
<h2 class="w3-wide" align="Center"><font color="white"><strong><br>Přihláška</strong></font></h2>
<form align="center" name="form1" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post" enctype="multipart/form-data">
<ul class="errorMessages"></ul>
<div class="row">
<div class="col">
<label for="fname"><font color="white"><strong>Jméno</strong></font></label></div>
<div class="col">
<input type="text" id="fname" name="fname" value="" required="required"><br></div>
</div>
<div class="row">
<div class="col">
<label for="lname"><font color="white"><strong><br>Příjmení</strong></font></label></div>
<div class="col">
<input type="text" id="lname" name="lname" value required="required"div>
</div>
<div class="row">
<div class="col">
<label for="vysoho"><font color="white"><strong><br>Vysoká škola</strong></font></label></div>
<div class="col">
<input type="text" id="vysoka_skola" name="vysoka_skola" value="" required="required"></div>
</div>
<div class="row">
<div class="col">
<label for="fname"><font color="white"><strong><br>Studijní obor</strong></font></label></div>
<div class="col">
<input type="text" id="obor" name="obor" value="" required="required"></div>
</div>
<div class="row">
<div class="col">
<label for="prace"><font color="white"><strong><br>Odkaz na bakalářskou práci</strong></font></label></div>
<div class="col">
<input type="text" id="prace" name="prace" value="" required="required"></div>
</div>
<div class="row">
<div class="col">
<label for="myfile"><font color="white"><strong><br>Bakalářská práce</strong></font></label></div>
<div class="col">
<input type="file" id="myfile" name="myfile[]" multiple="multiple" required="required"></div>
</div>
<div class="row">
<div class="col">
<label for="dropdown"><font color="white"><strong><br>Kategorie v soutěži</strong></font></label></div>
<div class="col">
<select id="kategorie" name="kategorie" required="required">
<option value="science">Science</option>
<option value="technology">Technology</option>
<option value="science">Engineering</option>
<option value="science">Mathematics</option>
</select>
</div>
<br>
</div>
<div class="row">
<div class="col"><input type="checkbox" id="gdpr" name="gdpr" value="" required="required">
<label for="gdpr"><font color="white"><strong> I agree with GDPR</strong></font></label></div>
</div>
<div class="row">
<div class="col">
<input type="submit" name="submit" value="Poslat"><br><br></div>
</div>
</form>
</div>
</div>
<!--END OF FORM-->
In the PHP script you can display whatever message you want to by just addingecho
Your second option is to target the form to an iframe:
<iframe name="myframe" id="frame1" src="thankyou.php" style="display:none"></iframe>
<form action="../thankyou.php" method="post" target="myframe">
<input type="submit" name="DoIt" value="DoIt">
</form>
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/
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.