1

I need to create a custom Form in hostgator and should be able to send the Form input to my email address.

I am new to html and form in general.

I have used the code on the following link to create the base html file: https://support.hostgator.com/articles/custom-form-mail The form I've created is working well it just that I didn't receive any email.

Do i need to create a php file for this? I'm also not sure what to put on value="http://www.example.com/redirect-path"> part.

I'm using Hostgator website builder. I'm not familiar with form in general

============== The code i followed:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="content-type" content="text/html;charset=utf-8"> 
<title>FormMail Demo</title> 
<script type="text/javascript"> 
function hgsubmit() 
{ 
if (/\S+/.test(document.hgmailer.name.value) == false) alert ("Please provide your name."); 
else if (/^\S+@[a-z0-9_.-]+\.[a-z]{2,6}$/i.test(document.hgmailer.email.value) == false) alert ("A valid email address is required."); 
else if (/\S+/.test(document.hgmailer.comment.value) == false) alert ("Your email content is needed."); 
else { 
    document.hgmailer.submit(); 
    alert (' Thank you! \n Your email is sent.'); 
    } 
} 
</script> 
</head> 
<body> 
<form action="http://www.example.com/cgi-sys/formmail.pl" method="post" name="hgmailer"> 
<input type="hidden" name="recipient" value="myemail@mydomain.com"> 
<input type="hidden" name="subject" value="FormMail E-Mail"> 
Whatever you want to say here<br><br> 
Visitor Name: <input type="text" name="name" size="30" value=""><br> 
Visitor E-Mail: <input type="text" name="email" size="30" value=""><br> 
E-Mail Content: <textarea name="comment" cols="50" rows="5"></textarea><br><br>
<input type="button" value="E-Mail Me!" onclick="hgsubmit();"> 
<input type="hidden" name="redirect" value="http://www.example.com/redirect-path"> 
</form> 
</body> 
</html> 
Community
  • 1
  • 1
inp.kez
  • 31
  • 2

1 Answers1

0

Assuming you have set out your server side scripting perhaps in your case PHP you can go ahead to make a nice email template using some code like the one below so that you achieve your intentions

table { border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%; } 
table td { font-family: sans-serif; font-size: 14px; vertical-align: top; }
.body { background-color: #f6f6f6; width: 100%; } 
.container { display: block; Margin: 0 auto !important;  max-width: 580px; padding: 10px; width: 580px; } 
.content { box-sizing: border-box; display: block; Margin: 0 auto; max-width: 580px; padding: 10px; }
.main { background: #fff; border-radius: 3px; width: 100%; } 
.wrapper { box-sizing: border-box; padding: 20px; } 
.footer { clear: both; padding-top: 10px; text-align: center; width: 100%; } 
.footer td, .footer p, .footer span, .footer a { color: #999999; font-size: 12px; text-align: center; } 
h1, h2, h3, h4 { color: #000000; font-family: sans-serif; font-weight: 400; line-height: 1.4; margin: 0; Margin-bottom: 30px; } 
p li, ul li, ol li { list-style-position: inside; margin-left: 5px; }
<!doctype html>
 <html>
   <head>
  <meta name="viewport" content="width=device-width" />
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>Mail from Sender</title>
   </head>
      <body class=""><table border="0" cellpadding="0" cellspacing="0" class="body"><tr><td>&nbsp;</td><td class="container"><div class="content">
 <table class="main">
   <tr>
  <td class="wrapper">
    <table border="0" cellpadding="0" cellspacing="0">
   <tr><td>
   <center><h2>MyCompany Logo</h2></center></td>
   </tr>
   <tr>
     <td>
    <p>Hello Receiver</p>
    <p>I am writing to you concerning this bla bla bala ab;a ba</p>
    <p>With Regards,<br>Sender</p>
      </td>
    </tr>
     </table>
   </td>
    </tr>
   </table>
   <div class="footer">
     <table border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td class="content-block">
     <span class="apple-link">
      </td>
    </tr>
    <tr>
     <td>
     <a href="' . $url . '">MyService</a>.</td>
      <td class="content-block powered-by">
     <ul>
      <li>Marketing</li>
      <li>Recruiting</li>
      <li>Management</li>
     </ul>
      </td>
    </tr>
     </table>
   </div>
    </div>
  </td>
  <td>&nbsp;</td>
   </tr>
 </table>
  </body>
</html>

Please note that am simply using a table to position my email content properly. This is because html content when sent over email tends to get disoriented at times

Jack Siro
  • 677
  • 10
  • 29