Free Contact Form

Looking for a free way to add a contact form to your Pligg website? This article provides instructions on how to add a contact form to your Pligg website in 3 easy steps. This contact form is based on one provided by 1stwebdesigner.com. It is a very basic contact form that can be tweaked to suit your own purposes.

Step 1

We will be utilizing Pligg’s page feature to create the contact page. Pages can be added by logging into the Pligg Admin Panel, then navigate to Manage > Pages > Submit a New Page. Set the page title, url, and other values to whatever you want. In the main content field, add the code below.

<form action="mail.php" method="POST">
<p>Name:</p> <input type="text" name="name" size="40">
<p>Email:</p> <input type="text" name="email" size="40">

<p>Concerning:</p>
<select name="type" size="1">
<option value="General Comment">General Comment</option>
<option value="Bug Report">Bug Report</option>
<option value="Advertising Inquiry">Advertising Inquiry</option>
</select>
<br />

<p>Message:</p><textarea name="message" rows="6" cols="50"></textarea><br />
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>

Step 2

Next you should create a landing page that users will be directed to after they submit the contact form. Create a basic “Thank you” message on a new Pligg page. Copy down the URL to this new page because you will be using it in the next step.

Step 3

Create a new file and name it “mail.php”. Copy the data below into the new mail.php file, making changes to the recipient (what email receives the email) and header lines. The header URL should point to the “Thank you” page that you created on step 2.

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent=" From: $name ($email)n Type: $type n Message: $message";
// Change to your email address
$recipient = "SAMPLE@SAMPLE.COM";
// The subject of the email being sent to you
$subject = "Contact Form";
$mailheader = "From: $email rn";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
// Point to the contact success page URL
header( 'Location: http://pligg.com/demo/page.php?page=contact-success' ) ;
?>

When you finish making the edits upload the mail.php file to the root of your Pligg website. All you have to do now is test the contact form to make sure that it works, and then post a link to the contact page by manually adding it to one of your template files. Congrats, you now have an email contact form on your website!

9 thoughts on “Free Contact Form

  1. [quote]
    # Tab Says:
    September 5th, 2011 at 5:15 am

    it doesn’t seem to work for me. after i submit the test message, it takes me to http://mysite.com/static/mail.php but doesn’t show anything. i tried adding a / to the form (ie “mail.php”), so the user gets redirected to http://mysite.com/mail.php ..but that doesn’t help either.

    Read more: Free Contact Form | Pligg CMS http://pligg.com/blog/1457/free-contact-form/#ixzz1bywRQ7wG
    [/quote]
    You can use javascript for the redirection.

    If the headers are already sent to the browser (a character or whatever) then the code header(”); won’t work.

    Try adding the following code in your PHP script:

    echo "<script language="javascript">document.location="$url"</script>";		
    

    Where $url contains the URL for the redirected page, something like :
    $url=”http://pligg.com/demo/page.php?page=contact-success”;

    TTFN
    Cynthia

  2. I think I found a minor bugg in the ‘Free Contact Form’.

    When someone submits a comment using this form, without entering any user data, such as name, email, etc; the form sends out to end up in my mailbox with all fields showing blank.

    I get several of these a day.

    So what you end up with is an email that looks like this: ()

    I’m wondering if there is a way for the developer to make the filling out of the fields required, before the sender can click on the send button?

    Am I on the right track with this?

    Thanks in advance.

    rjwusa

Comments are closed.