phkatz
1
Hi,
Trying to complete a contact page as part of a webpage. When I click send it transfers to a blank page. Not sure where went wrong.
contactform.php
<?php
if(isset($_POST['submit'])){
$name = htmlspecialchars($_POST['name']);
$subject = htmlspecialchars($_POST['subject']);
$mailfrom = htmlspecialchars($_POST['mail']);
$message = htmlspecialchars($_POST['message']);
$mailto = "keith.williams@bloggoneit.net";
$headers = "From:" . $mailfrom;
$txt = "You have received an email from".$name.".\n\n.$message;
if(from($mailto,$subject,$txt,$headers));
{
echo "<b>Message successfully sent</b>";
}
else { echo"<b>Message sending failed...</b>";
}
?>
Thank You
phkatz
4
Hi,
That’s how it was written.
<html>
<head>
<style type="text/css">
body{font-family:arial;
}
table{font-size:100%;width:100%;background-color:#000000;}
a{color:#ffffff;text-decoration:none;font:bold}
a:hover{color:#ffffff;}
td.menu{background-color:#000000;}
table.menu
{
font-size:100%;
position:absolute;
visibility:hidden;
}
.center
{
margin:auto;
width:60%;
background-color:#FFFFFF;
}
</style>
<script type="text/javascript">
function showmenu(elmnt)
{
document.getElementById(elmnt).style.visibility="visible";
}
function hidemenu(elmnt)
{
document.getElementById(elmnt).style.visibility="hidden";
}
</script>
</head>
<body>
<br>
<br>
<br>
<br>
<div class="center">
<p>
<div align="center"><img src="bloggoneitbanner.jpg"></div>
<br>
<table>
<td onmouseover="showmenu('home')" onmouseout="hidemenu('home')">
<a href="http://bloggoneit.net/" target="_blank">Home</a>
<table class="menu" id="home" width="120">
</table>
</td>
<td onmouseover="showmenu('about')" onmouseout="hidemenu('about')">
<a href="about.html" target="_blank">About</a>
<table class="menu" id="about" width="120">
</table>
</td>
<td onmouseover="showmenu('blog')" onmouseout="hidemenu('blog')">
<a href="blog.html" target="_blank">Blog</a>
<table class="menu" id="blog" width="120">
</table>
</td>
<td onmouseover="showmenu('contact')" onmouseout="hidemenu('contact')">
<a href="contact.php" target="_blank">Contact</a>
<table class="menu" id="contact" width="120">
</table>
</td>
<td onmouseover="showmenu('services')" onmouseout="hidemenu('services')">
<a href="services.html" target="_blank">Services</a>
<table class="menu" id="contact" width="120">
</table>
</td>
</table>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<div align="center">
<form action="contactform.php" method="post">
<input type="text" name="name" placeholder="name"><br /><br />
<input type="text" name = "email" placeholder="email"><br /><br />
<input type="text" name="subject" placeholder="subject"><br /><br />
<textarea name="message" cols="45" rows="9" placeholder="Comments..."></textarea>
<br />
<br />
<input type="image" src="sendbutton.jpg" name="submit">
</form>
<br>
<br>
<br>
<br>
<hr>
<h3>Created and designed by</h3><br>
<img src="G9banner.jpg" width="85" height="85" border="0"></div>
</p>
</div>
</body>
</html>```
(Apologies)
It would be **from**
Your code has many mistakes .
- you have to close your first if statement
if(isset($_POST['submit'])){
before ?>
.
- in your
$txt
variable you need to close double quote i.e.
$txt = "You have received an email from".$name."\n\n".$message;
- in you second if you use a
from()
what it do .
- you put a semicolon in if statement .
Always remember one thing in php we use a semicolon to end statement.
explain your form()
if you want to fix issue.