Contact us form in php


 Contact us form in php

 <?php $admin_email = “pramodhkumar.it@gmail.com”;

if(isset($_POST[‘submit_msg’]))

{

if (empty($HTTP_POST_VARS[‘name_msg’]))

{ die(‘<p><p><center><font face=”Tahoma” color=”#003399″ style=”font-size: 9pt”><h1><i>Error!</i></h1><font color=”#ff0000″> <br>caution : please type your name in form</font><br><br><span style=”cursor:hand” ONCLICK=”window.history.go(-1);”>Back to form</span><center></font>’); }; if (empty($HTTP_POST_VARS[’email_msg’])){ die(‘<p><p><center><font face=”Tahoma” color=”#003399″ style=”font-size: 9pt”><h1><i>Error!</i></h1><font color=”#ff0000″> <br>caution : please type your email</font><br><br><span style=”cursor:hand” ONCLICK=”window.history.go(-1);”>Back to form</span><center></font>’); }; if (empty($HTTP_POST_VARS[‘msg_body’])){ die(‘<p><p><center><font face=”Tahoma” color=”#003399″ style=”font-size: 9pt”><h1><i>Error!</i></h1><font color=”#ff0000″> <br>caution : please type your text</font><br><br><span style=”cursor:hand” ONCLICK=”window.history.go(-1);”>Back to form</span><center></font>’); }; $name_msg = htmlspecialchars($HTTP_POST_VARS[‘name_msg’]); $name_msg = str_replace(“&amp;”,”&”,$name_msg); $name_msg = str_replace(“ÛŒ”,”ÙŠ”,$name_msg); $msg_body = htmlspecialchars($HTTP_POST_VARS[‘msg_body’]); $msg_body = str_replace(“&amp;”,”&”,$msg_body); $msg_body = str_replace(“ÛŒ”,”ÙŠ”,$msg_body); $msg_body = nl2br($msg_body); if (!empty($HTTP_POST_VARS[‘url_msg’])) { $url_msg  = str_replace(‘http://&#8217;,”,$_POST[‘url_msg’]); $name_msg = “<a target=_blank href=http://”.htmlspecialchars($url_msg).”>”.$name_msg.”</a>”; } if(!strpos($_POST[’email_msg’],”@”)) { print(‘<p><p><center><font face=”Tahoma” color=”#003399″ style=”font-size: 9pt”><h1><i>Error!</i></h1><font color=”#ff0000″> <br>caution : type your Emali</font><br><br><span style=”cursor:hand” ONCLICK=”window.history.go(-1);”>Back to form</span><center></font>’); die(‘<br><br><center><font face=”Tahoma” style=”font-size: 9pt”>example : info@phpfreecode.Com </center></font>’); }; $from  = htmlspecialchars($HTTP_POST_VARS[’email_msg’]); $body = ‘<html> <head> <title>Send comment</title> </head> <body> <table border=”1″ width=”100%” text=”#000000″ style=”font-family:tahoma;font-size:8pt;padding:7px;border-style: dashed; border-width: 3px” bgcolor=”#D6DFF7″ bordercolor=”#D6DFF7″ cellspacing=”0″ cellpadding=”0″> <tr> <td colspan=”2″ align=”center” bgcolor=”#D6DFF7″>=&gt; new comment &lt;=</td> </tr> <tr> <td width=”15%” bgcolor=”#D6DFF7″ dir=”rtl”>Name & Web address</td> <td width=”85%”  bgcolor=”#FFFFFF” align=”left”>’.$name_msg.'</td> </tr> <tr> <td width=”15%” bgcolor=”#D6DFF7″ dir=”rtl”>Comment</td> <td width=”85%” bgcolor=”#FFFFFF” align=”left”>’.$msg_body.'</td> </tr> </table> </body> </html>’; if(!mail($admin_email,’New Contact us’,$body,”From: <$from>n”.”MIME-Version: 1.0n”.”Content-type: text/html”)) { print(‘<p><p><center><font face=”Tahoma” color=”#003399″ style=”font-size: 9pt”><h1><i>The Mail Could not be send!</i></h1><font color=”#ff0000″> <br>server is busy .please try later</font><br><br><span style=”cursor:hand” ONCLICK=”window.history.go(-1);”>return to form</span><center></font>’); }else { print(‘<p><p><center><font face=”Tahoma” color=”#003399″ style=”font-size: 9pt”><h1><i>Thank You!</i></h1><font color=”#ff0000″> <br>Your comment has been sent successfully</font><br>Thanks for your comment<br><br><span style=”cursor:hand” ONCLICK=”window.history.go(-1);”> return to comment  </span>| <center></font>’); } } else { ?>

 
 <html dir="ltr">
 <head>
 <title>Type new comment</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <meta http-equiv="Content-Language" content="fa">
 <meta name="Geo.Country"        content="IR">
 <meta name="Robots"             content="all">
 <meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0)">
 <meta http-equiv="Page-Exit" content="blendTrans(Duration=1.0)">

</head>
 <body>
 <div align="center">
 <table border="0" cellpadding="0" cellspacing="0" width="513" height="491" id="fa" style="border: 3px dashed #9AABE7" bgcolor="#9AABE7">
 <tr>
 <td rowspan="5">&nbsp;</td>
 <td>&nbsp;</td>
 <td height="268" rowspan="5">&nbsp;</td>
 </tr>
 <tr>
 <td style="border-style: dashed; border-width: 3px" bgcolor="#D6DFF7" bordercolor="#D6DFF7">
 <table border="0" width="100%" cellspacing="0" cellpadding="0" id="fa" height="100%">
 <tr>
 <td>
 <p align="center"><span dir="ltr"><font color="#0000FF">Accept comment</font></span></td>
 </tr>
 </table>
 </td>
 </tr>
 <tr>
 <td ><span dir="ltr">.</span></td>
 </tr>
 <tr>
 <td style="border-style: dashed; border-width: 3px;padding-left:5px;padding-left:5px" bgcolor="#FFFFFF" bordercolor="#FFFFFF" dir="rtl" align="left">
 <p align="left"><span lang="en-ca" dir="ltr">Add whatever here</span></td>
 </tr>
 <tr>
 <td>&nbsp;</td>
 </tr>
 <tr>
 <td>&nbsp;</td>
 <td valign="top" style="border: 3px dashed #D6DFF7" bgcolor="#D6DFF7"><form name="msg_form" method="POST" >
 <table border="0" width="86%" cellspacing="0" cellpadding="0" id="fa" height="201">
 <tr>
 <td width="289" dir="rtl" align="left"><span dir="ltr">your name<input name="name_msg" size="33" id="fa" dir="ltr" tabindex="1" maxlength="30" lang="fa" style="float: left" value="" onclick="this.value=''">
 *: </span> </td></tr><tr>
 <td width="289" dir="rtl" align="left"><span dir="ltr">website name<input name="url_msg" size="21" dir="ltr" tabindex="2" maxlength="30" id="fa" style="float: left" value="" onclick="this.value=''"> :
 </span> </td></tr>
 <tr>
 <td width="289" dir="rtl" align="left"><span dir="ltr">your email<input name="email_msg" size="33" dir="ltr" tabindex="3" maxlength="30" id="fa" style="float: left" value="" onclick="this.value=''"> *:
 </span> </td></tr>
 <tr>
 <td width="289" dir="rtl" align="left"><span dir="ltr">your request*:<textarea rows="6" name="msg_body" cols="53" dir="ltr" id="fa" tabindex="4" lang="fa" onclick="this.value=''"></textarea>
 </span> </td></tr>
 <tr><td>
 <span dir="ltr">
 <input type="submit" value="Submit" name="submit_msg" tabindex="5" id="fa" style="float: left" ></span></td>
 <td width="127">&nbsp;</td></tr>
 </table>
 </td></form>
 <td height="207">&nbsp;</td>
 </tr>
 <tr>
 <td width="60">&nbsp;</td>
 <td width="352" align="center"><span lang="en-ca" dir="ltr">
 <font color="#FFFFFF">C</font></span><span dir="ltr"><font color="#FFFFFF">opyright © 2008 by </font>
 <a href="https://ephptutorial.wordpress.com<" target="_blank">
 <span style="text-decoration: none"><span lang="en-ca">ephptutorial.wordpress.com</span></span></a><font color="#FFFFFF"> - All Rights Reserved</font></span></td>
 <td height="22" width="96">&nbsp;</td>
 </tr>
 </table>
 </div>
 <span dir="ltr">
 <?php
 }
 ?>
 </body>
 </html>
Advertisements
About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , , ,
Posted in php

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow php tutorial on WordPress.com
categories
Calendar
June 2012
M T W T F S S
    Jul »
 123
45678910
11121314151617
18192021222324
252627282930  
Follow me on Twitter
Blog Stats
  • 74,607 hits
%d bloggers like this: