Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2018
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Contacts (emergent)

    Hello, I've been working on creating a website using html, and I am trying to make a "contact us" section. This is what I've done so far:
    Code:
    <!-- Contact us page-->
    <h2 style="color: #ffffff;" align="center">Contact Form</h2>
    <form>
    <table align="center" bgcolor="#96181C">
    <tbody>
    <tr>
    <td><span style="color: #ffffff;"><strong>Name:</strong></span></td>
    <td><input name="" type="text" placeholder="Name" /></td>
    </tr>
    <tr>
    <td><span style="color: #ffffff;"><strong>Email:</strong></span></td>
    <td><input type="mail" placeholder="Email"></td>
    </tr>
    <tr>
    <td><span style="color: #ffffff;"><strong>Your Message:</strong></span></td>
    <td><textarea name="message" placeholder="Message" rows="4"> </textarea></td>
    </tr>
     <input type="submit" value="Send Message"> 
      </td>
    </tbody>
    </table>
    </form>
    Can anyone help me with creating a submit button that sends this message to a certain email address? Thank you.
    Last edited by vinyl-junkie; Nov 20th, 2018 at 04:49 AM. Reason: added code tags

  2. #2
    Master Coder sunfighter's Avatar
    Join Date
    Jan 2011
    Location
    West Des Moines, Iowa
    Posts
    8,122
    Thanks
    37
    Thanked 1,089 Times in 1,085 Posts
    Sending email is done by a PHP file. This is done to protect your address.
    Here is a simple script to play with:
    Code:
    <?php
    if (isset($_POST["email"])) {
    	$email = $_POST["email"];
    	$name = $_POST["name"];
    	$subject = $_POST["subject"]; // You don't ask for this. You might consider putting your version here
    	$body = $_POST["message"];
    	$message = wordwrap($message, 70);
    	if (mail($email, $subject, $body, "From: " . $name)) {
    		echo("Email successfully sent");
    	} else {
    		echo("Email sending failed...");
    	}
    }
    ?>
    Your HTML coding is from last century. You should consider studying how codin is done in the 21st century. Emphasis on Flex and CSS Grid plus learning styling.
    An example of your code:
    Code:
    <!DOCTYPE html>
    <html>
    
    <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style>
        #heading{
        width: 200px;
        margin: 10px auto 20px;
    }
    form{
        height : 250px;
        width :280px;
        padding-top: 2rem;
        text-align: center;
        margin: auto;;
        color: #fff;
        background-color: #96181C;
    }
    div{
        width: 190px;
        margin: auto;
        text-align: left
    }
    </style>
    </head>
    
    <body>
        <!-- Contact us page-->
        <h1 id="heading">Contact Form</h1>
        <form method="POST" action="Your PHP File Name Here">
            <label for="name">Name:</label>
            <input name="name" id="name" type="text" placeholder="Name" /><br><br>
    
            <label for="email">Email:</label>
            <input type="mail" name="email" id="email" placeholder="Email"><br><br>
    
            <div>
                <label for="message">Your Message:</label><br>
                <textarea name="message" id="message" placeholder="Message" rows="4"> </textarea>
                <input type="submit" value="Send Message">
            </div>
        </form>
    </body>
    </html>
    You can code the PHP into your HTML page, but you have to have a stronger knowledge of what's going on.
    Welcome to the forums....
    Evolution - The non-random survival of random variants.
    Physics is actually atoms trying to understand themselves.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •