Today I tried to create a PHP HTML editor, you can write your own "HTML code", view it and send it to my email. Here is the code:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
if (isset($_POST['submit'])){
$to = "jonas.geiler@gmail.com";
$subject = "Form to email message";
$message = $_POST["message"];
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$header .= 'From: Skayos Blog <blog.skayo@mail.com>' . "\r\n";
mail($to,$subject,$message,$header);
} else if (isset($_POST['preview'])){
$output = $_POST["message"];
echo $output;
}
?>
<!DOCTYPE html>
<head>
<title>Form submission</title>
</head>
<body>
<form action="" method="post">
Message:<br>
<textarea rows="5" name="message" cols="30"><html> <body> </body> </html></textarea><br>
<input type="submit" name="preview" value="Preview">
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
My problem: if I click Preview, the side reloads with the preview and the code is deleted. Is there an easy way to make code in a text box?
Thanks,
Skayo
Skayo source
share