How to make a "Contact Page"?

Discussion in 'Programming' started by bunnny, May 20, 2008.

  1. #1
    Hi all,

    I want to create a "Contact page" on my phpBB3 website. Can somebody help me do this, please!
    Thank you!
     
    bunnny, May 20, 2008 IP
  2. whirlybird20

    whirlybird20 Guest

    Messages:
    462
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you mean a contact form?

    If so this is the one that I use.

    Put this into the body of the page that you want the form to appear on.

    <form name="contact" action="contactaction.php" method="post">

    <table align="center" border="0" width="650">
    <tr>
    <td width=130>Full Name</td>
    <td><input type="text" name="name" size="40" maxlength="256"></td>
    </tr>
    <tr>
    <td width=130>Email Address</td>
    <td><input type="text" name="email" size="40" maxlength="256"></td>
    </tr>
    <tr>
    <td width=130>Phone Number</td>
    <td><input type="text" name="phone" size="40" maxlength="256"></td>
    </tr>
    <tr>
    <td width=130 valign="top">Message</td>
    <td><textarea name="message" cols="59" rows="14">
    </textarea>
    </td>
    </tr>
    <tr>
    <td valign="top"></td>
    <td><input type="submit" value="Send"> <input type="reset" value="Reset"></td>
    </tr>
    </table>
    </form>

    Now create a php file and specify the file name where it says "contactaction.php" in the code above.

    Now add the following code to your action.

    <?php
    //specify the page that you want them to be redirected to bellow where it says "thankyou.php"
    $thankyoupage = "thankyou.php";
    //change this to be your email address
    $to = "youremail@example.com";
    //this is the subject of the email that arrives
    $subject = "Contact Us";
    //now we grab all of the information that was submitted
    $name = $_REQUEST['name'];
    $email = $_REQUEST['email'] ;
    $phone = $_REQUEST['phone'];
    $message = $_REQUEST['message'] ;
    //this is the body of the message. Right now it will just say what they said in the message field then have two reterns and say their phone number.
    $body = "$message\n\nPhone Number: $phone" ;
    //this is who the email is from
    $headers = "From: $name <$email>";
    //this sends the email
    $sent = mail($to, $subject, $body, $headers) ;
    if($sent)
    //this redirects them to a page that you specify.
    header("Location: $thankyoupage");
    //if something goes wrong with sending the form then this message will appear
    else
    {print "We encountered an error sending your mail"; }
    ?>

    I hope this helps

    Joel
     
    whirlybird20, May 20, 2008 IP
  3. bunnny

    bunnny Peon

    Messages:
    283
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hey joel,

    thanx for your help.

    can you tell me where i must place the code, pls! .
     
    bunnny, May 21, 2008 IP