rvandyke Posted November 22, 2020 Report Share 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"); ?> Quote Link to comment Share on other sites More sharing options...
administrator Posted November 22, 2020 Report Share 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.