Need help with code on a contact us page... PLEASE

I purchased a template site. It has a contact us page, but no script to make it work. Can somebody give me a hand on what I should do… Thank you soooooo much if you can help.

Here is what I am working with. I am code dumb, so if you see something and laugh because it is way to easy have mercy on me :slight_smile:

      <td><form method="post" action="/frms/contactmail.pl">
        <input type="hidden" name="SoupermailConf" value="/frms/contact.con">
        <table width="100%" border="0" cellpadding="0" align="center" cellspacing="0">
          <tr>
            <td><table width="100%" border="0" cellpadding="4" cellspacing="1">
              <tr>
                <td align="Right"><b>Your 
                  Name: <span class="style1">*</span></b></td>
                <td width="70%"><input type="TEXT" name="Name" style="width: 90%;"></td>
              </tr>
              <tr>
                <td align="Right"><b>E-mail 
                  Address: <span class="style1">*</span></b></td>
                <td><input type="TEXT" name="Name2" style="width: 90%;"></td>
              </tr>
              <tr>
                <td align="Right"><b>Company:</b></td>
                <td><input type="TEXT" name="Name3" style="width: 90%;"></td>
              </tr>
              <tr>
                <td align="Right"><b>How 
                  did you 
                  find us?</b></td>
                <td><input type="TEXT" name="Name4" style="width: 90%;"></td>
              </tr>
              <tr>
                <td align="right"><b> Questions: <span class="style1">* </span></b></td>
                <td>&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2" align="center"><textarea name="Question" rows="8" style="width: 90%;" wrap="VIRTUAL"></textarea></td>
              </tr>
              <tr>
                <td colspan="2" align="center"><input type="submit" name="Submit" value="Submit Form">
                  <br></td>
              </tr>
            </table></td>
          </tr>
        </table>
      </form>

The page you have is the submission form, what you need is a script to process the info and do something with it.

I have just knocked up a quick script that should do what you need.
There are a few things you will need to change like YOUR email address in the $to and $from values and the subject.

I haven’t tried the script but i’m reasonably sure it will work.
You can place it at the top of the script you already have (recommended) or on a new page.

Hope this helps
:wink:

[php]if(isset($_POST[‘Submit’]))
{
$errors = array();

if(!empty($_POST['name'])) { $name = trim(stripslashes($_POST['name'])); }
else { $name = false; $errors[] = 'Please enter name'; }
  
if(!empty($_POST['name2'])) { $name2 = trim(stripslashes($_POST['name2'])); }
else { $name2 = false; $errors[] = 'Please enter name2'; }

if(!empty($_POST['name3'])) { $name3 = trim(stripslashes($_POST['name3'])); }
else { $name3 = false; $errors = 'Please enter name3'; }

if(!empty($_POST['name4'])) { $name4 = trim(stripslashes($_POST['name4'])); }
else { $name4 = false; $errors[] = 'Please enter name4'; }

if(!empty($_POST['Question'])) { $Question= trim(stripslashes($_POST['Question'])); }
else { $Question= false; $errors[] = 'Please enter Question'; }

if(empty($errors))

{
$to = ‘[email protected]’;
$subject = ‘Someone sent email from form’;
$from = ‘[email protected]’;

    $message = "A user has submitted the form, details below:\n";
    $message .= "Name: " . $name . "\n";
    $message .= "Email: " . $name2 . "\n";
    $message .= "Company: " . $name3 . "\n";
    $message .= "How they found us: " . $name4 . "\n";
    $message .= "Question: " . $Question . "\n";
    // send the message.
    mail($to, $subject, $message, $from);
}
else // there was an error in script..
{
      echo '<p>Please correct the following errors:</p>';
      foreach($errors as $error)
      {
           echo '<p>' . $error . '</p>';
      }
 }

}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service