Need Help Creating A Email Contact Form

6 replies
I am trying to code a contact form in adobe dreamweaver CS3, and am having trouble getting a nice clean contact form design.

I am trying to get a form with these fields in this order....

1. name
2. email
3. business name
4. phone
5. address

A simple script in php would probably work. Basically a php file, and the html form code to drop into the site, that will validate if the user added the information correctly....

Any simple solutions for this? I have looked at purchasing pre-coded contact forms, but they do not have the required fields, and I have seen some websites that generate forms, but I do not want to have to link back to the site in order to use their form..............
#contact #creating #email #form
  • Profile picture of the author Unomateo
    <script>
    function validate_fields(){
    if(document.getElementById('name').value ==""){alert('Please provide a name'); return false;}
    if(document.getElementById('email').value ==""){alert('Please provide an email'); return false;}
    if(!validateEmail(document.getElementById('email') .value)){alert('Please provide a valid email'); return false;}
    if(document.getElementById('bname').value ==""){alert('Please provide a business name'); return false;}
    if(document.getElementById('phone').value ==""){alert('Please provide a phone number'); return false;}
    if(document.getElementById('address').value ==""){alert('Please provide an address'); return false;}

    return true;
    }

    function validateEmail(email)
    {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return email.match(re)
    }


    </script>

    <form action='' onSubmit='return validate_fields();' method='post'>
    <table>
    <tr>
    <th>Name</th>
    <td><input type='text' id='name' name='name' /></td>
    </tr>
    <tr>
    <th>Email</th>
    <td><input type='text' id='email' name='email' /></td>
    </tr>
    <tr>
    <th>Business name</th>
    <td><input type='text' id='bname' name='bname' /></td>
    </tr>
    <tr>
    <th>Phone</th>
    <td><input type='text' id='phone' name='phone' /></td>
    </tr>
    <tr>
    <th>Address</th>
    <td><input type='text' id='address' name='address' /></td>
    </tr>
    <tr>
    <td colspan='2'><input type='submit' id='button' name='submit' value='Submit' /></td>
    </tr>
    </table>
    </form>
    {{ DiscussionBoard.errors[4681019].message }}
  • Profile picture of the author Unomateo
    The above script will valid for entry on all fields and check for a valid email.

    You will need to add CSS to make it pretty
    {{ DiscussionBoard.errors[4681023].message }}
    • Profile picture of the author Steve Wells
      Originally Posted by Unomateo View Post

      The above script will valid for entry on all fields and check for a valid email.

      You will need to add CSS to make it pretty
      Hey thanks, is there any way to make this form send them to a thank you page once they enter the information correctly? And to an error form if they do not?

      Also, where do I put the script at?

      How do I make this send the contact information from the user, to a specific email address?

      It doesn't seem to have anywhere to add a destination email address.....
      Signature
      Need Custom Graphics Work? - Message Me For A Design Quote!
      {{ DiscussionBoard.errors[4681139].message }}
  • {{ DiscussionBoard.errors[4681706].message }}
  • Profile picture of the author elgharib2008
    to make things easy
    herebelow the code - gives you
    1. the forum you insert into a HTML page
    2. the PHP file that processes the form and sends it to your email address

    --------------

    ------>> this below form : insert into a HTML page

    <form name=contactme action=contactme.php method=post>
    <div align="center">
    <table>
    <tr>
    <td align=right>Your Name:</td>
    <td width="15">&nbsp;</td>
    <td><input size=45 maxlength=45 type=text name=name
    style="font-family: Courier New; font-size: 10pt"></td></tr>
    <tr>
    <td align=right>Your Email Address:</td>
    <td>&nbsp;</td>
    <td><input size=45 maxlength=45 type=text name=from
    style="font-family: Courier New; font-size: 10pt"></td></tr>
    <tr>
    <td align=right>eMail Subject:</td>
    <td>&nbsp;</td>
    <td><input size=45 maxlength=90 type=text name=subject
    style="font-family: Courier New; font-size: 10pt"></td></tr>
    <tr>
    <td valign=top align=right>Contents:</td>
    <td>&nbsp;</td>
    <td><textarea name=body rows=12 cols=60
    style="font-family: Courier New; font-size: 10pt"></textarea></td></tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type=submit value=" Submit " name=submit style="font-size: 10pt; font-family: Tahoma"></td></tr>
    </table>
    </div>
    </form>



    ------------ below PHP code:
    save in same folder the below code to a file called in our example contactme.php
    the name MUST be identical as in the form itself !!!!
    if you save into OTHER folder - then adapt the path of "action=contactme.php" above


    <?php
    $body="
    $name ($from) sent you an online message:

    Comments:
    ========
    $body";

    $success = mail("YOUR recipient email @ your_site dot com","$subject","$from","$body");

    ?>


    <html>

    <head>
    </head>

    <body>
    .
    .
    .
    Thank you for your message
    .
    .
    .
    </body>
    </html>
    Signature

    My name is mohamed elgharib and I’m a full time Blogger making a living from this new and dynamic medium from blogs , I've become a full time blogger
    http://blogging-for-money-2011.blogspot.com/
    Please Visit the blog and leave comments

    {{ DiscussionBoard.errors[4687289].message }}

Trending Topics