zero-perfoliate
zero-perfoliate

Author Topic: HTML Form to Email using PHP...  (Read 226 times)

Offline SDAgent

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
HTML Form to Email using PHP...
« on: September 28, 2009, 07:27:32 PM »
Hello.
I ran a few search before posting and was unable to find anything related. I was wondering if maybe anyone here might have a solution. The concept seemed to be simple, but the coding behind it is beyond me at this point. What i have is form on an html page which works fine, problem being that I am trying to send the information in the form to my email. The PHP file isn't being called up properly it opens as a webpage. in IE7 and since that is the company standard i don't have a choice to make it work here. oh and to top it off it has to be on a sharepoint 2007 server...lol

HTML code is
<html>
<head>
</head>
<body>
    <div id="contentWrapper">   
      <div id="mainContent">
        <h1>Site Change Request</h1>
          <h4>Please fill out the information and click send.</h4>
             <form name="sitechange" action="emailfwd.php" method="post" enctype="application/x-www-form-urlencoded">
                
From:<input type="text" name="email" value="Your Email" size="40" />               
                
Page Name:
                <select name="pagename">
                <option>Choose One</option>
                <option>home.htm</option>
                <option>agent.htm</option>
                <option>cio.htm</option>
                <option>np.htm</option>
                <option>rrd.htm</option>
                <option>hbf.htm</option>
                <option>bbyc.htm</option>
                <option>gtafs.htm</option>
                </select>
   
Link Name:
   <input type="text" name="linkname" value="" size="25" />
   
Actual Link:
   <input type="text" name="link" value="https://" size="40" />
   
<input type="submit" name="submit" value="Submit" />
                <input type="hidden" name="ty" value="ty.htm" />
          </form>
      </div>
     </div>
<!--end mainContent--> 
</div> <!-- end wrapper-->
</body>
</html>

PHP saved in emailfwd.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<?php
$pagename = $_POST['pagename'];
$linkname = $_POST['linkname'];
$link = $_POST['link'];
$msg = "PageName".$pagename. "\r\n";
$msg .= "Link Name: " . $linkname . "\r\n";
$msg .= "Link " .$link. "\r\n";
$to = "myemail@test.com";
$subject = "Site Change Request";
mail($to, $subject, $msg);
echo ("Mail processed.");
?>
</body>
</html>

Thanks, Cheers