Hello and welcome to our community! Is this your first visit?
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
    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:
    <!-- Contact us page-->
    <h2 style="color: #ffffff;" align="center">Contact Form</h2>
    <table align="center" bgcolor="#96181C">
    <td><span style="color: #ffffff;"><strong>Name:</strong></span></td>
    <td><input name="" type="text" placeholder="Name" /></td>
    <td><span style="color: #ffffff;"><strong>Email:</strong></span></td>
    <td><input type="mail" placeholder="Email"></td>
    <td><span style="color: #ffffff;"><strong>Your Message:</strong></span></td>
    <td><textarea name="message" placeholder="Message" rows="4"> </textarea></td>
     <input type="submit" value="Send Message"> 
    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
    West Des Moines, Iowa
    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:
    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:
    <!DOCTYPE html>
    <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" />
        width: 200px;
        margin: 10px auto 20px;
        height : 250px;
        width :280px;
        padding-top: 2rem;
        text-align: center;
        margin: auto;;
        color: #fff;
        background-color: #96181C;
        width: 190px;
        margin: auto;
        text-align: left
        <!-- 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>
                <label for="message">Your Message:</label><br>
                <textarea name="message" id="message" placeholder="Message" rows="4"> </textarea>
                <input type="submit" value="Send Message">
    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