rvandyke Posted November 22, 2020 Report Posted November 22, 2020 Hey guys! So far my website is looking great! Just trying to get this contact form to function. Wondering if everything lines up: HTML code: <!--contact-form-------------------> <section id="contact-form"> <form> <!--left---------------------------------------> <div class="contact-left"> <h1 class="c-l-heading"><font style="border-bottom: 3px solid #1ED98B;">Writ</font>e Me</h1> <!--name--------> <div class="f-name"> <font >Name</font> <input type="text" placeholder="Full Name"/> </div> <!--email--------> <div class="f-email"> <font >Email</font> <input type="email" placeholder="Example@gmail.com"/> </div> </div> <!--right-------------------------------------------> <div class="contact-right"> <!--message--------> <div class="message"> <font >Message</font> <textarea name="message" rows="5" cols="20" placeholder="Write Message..."></textarea> </div> <!--submit-btn------------> <button>submit</button> </div> </form> </section> php: ?php $name = $_POST['name']; /*this will display the name of the users */ $visitor_email = $_Post['email']; /*this will display the email of the user */ $message = $_POST['message']; /*this will store the message */ $email_from = 'Ryan-vand@outlook.com' /*I will receive this via this line of code */ $email_subject = "new form submission"; $email_body = "User Name: $name.\n"."User Email: $visitor_email.\n"."User Message: $message.\n"; $to = "Ryan-vand@outlook.com"; $headers = "From: $email_from\r\n"; mail($to,$email_subject,$email_body,$headers); header("Location: firstdraft.html"); ?>
administrator Posted November 22, 2020 Report Posted November 22, 2020 Hi, You need to add the identifier attributes to your form elements so your PHP code can capture the form data people enter. Example: <input type="text" id="nameFirst" name="nameFirst"> PHP needs the ID attribute for each form element that captures info. Please refer to the PHP course.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now