Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h1>Contact us</h1>
- <div id='errors'></div>
- <form method='post' name="form" >
- <table>
- <tr>
- <td>Email:</td>
- <td><input type="text" name="email" placeholder="Email"></td>
- </tr><tr>
- <td>Support team?:</td>
- <td>
- <select name="team">
- <option value="none">Pick one</option>
- <option value="atrix">Atrix676</option>
- <option value="joey">Joey</option>
- </select>
- </td>
- </tr><tr>
- <td>Category:</td>
- <td><select name="cat">
- <option value="cat">Category</option>
- <option value="donar">Donations</option>
- <option value="other">Other</option>
- </select></td>
- </tr><tr>
- <td>Message:</td>
- <td><textarea name="msg" cols="50" rows="8"></textarea></td>
- </tr></table>
- </tr></table>
- <input type='submit' name='submit' value='Submit'>
- </form>
- <?php
- $errors = array();
- if (isset($_POST['submit'])) {
- if (empty($_POST['email']) || empty($_POST['msg'])) {
- $errors[] = 'Please fill in all fields ';
- } else {
- $email = $_POST['email'];
- $msg = $_POST['msg'];
- $subject = $_POST['cat'];
- $headers = "From: ".$_POST['email'];
- if ($_POST['team']=='atrix') {
- $to = 'markmp3@live.com';
- } else if ($_POST['team']=='joey') {
- $to = 'phptech@live.com';
- } else {
- $to = 'markmp3@live.com';
- } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
- $errors[] = 'Please enter a valid email';
- } else {
- if (mail($to, $subject, $msg, $headers)) {
- echo "Your message has been sent to <b>".ucfirst($_POST['team'])."</b>. You will be answered ASAP";
- }
- else {
- echo "Your message has failed to send. Please try again later.";
- }
- }
- }
- foreach($errors as $error) {
- echo "<font color='red'>$error</font>";
- }
- }
- ?>
Add Comment
Please, Sign In to add comment