I am making my own CMS website and the body content is echoed onto the page however some of the page content is php code but the actual code is echoed out. How can i make it so that it works properly.
Code:
<div id="form"> </div>
<h1>Form</h1> <br />
<?php
require_once "formvalidator.php";
$show_form=true;
if(isset($_POST['Submit']))
{
$validator = new FormValidator();
$validator->addValidation("Name","req","Please fill in Name");
$validator->addValidation("Email","email","The input for Email should be a valid email value");
$validator->addValidation("Email","req","Please fill in Email");
if($validator->ValidateForm())
{
$emailsubject = $_POST['category'];
$webmaster = 'email';
$namefield = $_POST['Name'];
$emailfield = $_POST['Email'];
$categoryfield = $_POST['category'];
$subjectfield = $_POST['subject'];
$messagefield = $_POST['message'];
$priorityfield = $_POST['priority'];
$IPADDR = $_SERVER['REMOTE_ADDR'];
$date = date("H:i:s D d M Y");
$from = "OnlineSupport";
$body = <<<EOD
$date
Name: $namefield
Email: $emailfield
Category: $categoryfield
Subject: $subjectfield
Message: $messagefield
Proproty: $priorityfield
$IPADDR
EOD;
$headers = "From: $from\r\n";
$headers .= "Content-tpye: text/html\r\n";
$success = mail($webmaster, $emailsubject, $body, $headers);
echo "<h2>Form Submited! <br /> Thank You for contacting support. We will get back to you as soon as we can.</h2>";
$show_form=false;
}
else
{
echo "<B>Errors:</B>";
$error_hash = $validator->GetErrors();
foreach($error_hash as $inpname => $inp_err)
{
echo "<p>$inpname : $inp_err</p>\n";
}
}
}
if(true == $show_form)
{
?>
<form method='post' action="/contact/index.php" accept-charset='UTF-8'>
Your name: <span class="red">*</span><br />
<input type="text" name="Name" size="30" maxlength="30" value="<?php echo $_POST['Name'];?>" />
<br />
Email address: <span class="red">*</span><br />
<input type="text" name="Email" size="30" maxlength="30" value="<?php echo $_POST['Email'];?>" />
<br />
Category: <br />
<select id="category" name="category">
<option value=" Select" selected="<?php echo $_POST['category'];?>"><?php echo $_POST['category'];?></option>
<option value=" Beta Testing">Beta Testing</option>
<option value=" Donating">Donating</option>
<option value=" Enquiry">Enquiry</option>
<option value=" Garrys Mod">Garrys Mod</option>
<option value=" Maps">Maps</option>
<option value=" Media">Media</option>
<option value=" Programs">Programs</option>
<option value=" Request">Request</option>
<option value=" Reviews">Reviews</option>
<option value=" Support">Support</option>
<option value=" Tutorials">Tutorials</option>
<option value=" Web Error">Website Error</option>
<option value=" Other">Other</option>
</select>
<br />
Subject: <br />
<input type="text" name="subject" size="30" maxlength="50" value="<?php echo $_POST['subject'];?>" />
<br />
Message:<br />
<textarea rows="8" cols="80" name="message"><?php echo $_POST['message'];?></textarea>
<br />
Priority: <br />
<select id="priority" name="priority">
<option value=" High">High</option>
<option value=" Medium">Medium</option>
<option value=" Low" selected="selected">Low</option>
</select>
<br /> <br />
<span class="red">Required *</span> <br /> <br />
<p><input type="submit" name="Submit" class="formbutton" value="Send" /></p>
</form>
<?PHP
}//true == $show_form
?>
<br />
<br />
<h1>Live Support</h1> <br />
Coming Soon! <br /> <br />
<br />
<br />
Can someone help please?
Thank's