I would like to take an opportunity to show you an example of how to developer
a simple php contact page. I will not use css or anything like that for this
tutorial. Just quick and dirty using the php mail function. Lets watch a
video, explaining the process
VIDEO
Here is the code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<head>
<title>Contact Us</title>
</head>
<body>
<?php
if ( $_SERVER [ 'REQUEST_METHOD' ] != 'POST' ) {
$self = $_SERVER [ 'PHP_SELF' ];
?>
<form method="post" name="contactForm" action=" <?php echo $self ; ?> ">
<table>
<tr>
<td>Name: </td>
<td><input type="text" name="cusName" id="cusName" /></td>
</tr>
<tr>
<td>Email: </td>
<td><input type="text" name="cusEmail" id="cusEmail" /></td>
</tr>
<tr>
<td>What can I do for you? </td>
<td><textarea id="reason" name="reason" rows="8" cols="40"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
<td><input type="reset" value="Reset" /></td>
</tr>
</table>
</form>
<?php
} else {
$name = $_POST [ 'cusName' ];
$emailFrom = $_POST [ 'cusEmail' ];
$reason = $_POST [ 'reason' ];
$emailTo = "john@jcwebconcepts.net" ;
$subject = "Filled in form from website" ;
$header = "From: $name < $emailFrom > \r\n Reply-To: $emailFrom \r\n " ;
$header .= "MIME-Version: 1.0 \r\n " ;
$header .= "Content-type:text/html;charset=iso-8859-1 \r\n " ;
$message = "From: #name, Email: $emailFrom <br /><hr /> $reason " ;
mail ( $emailTo , $subject , $message , $header );
echo "Thank you for contacting us. Someone will get back to you as soon as we can. Thank you." ;
}
?>
</body>
</html>