Custom Forms on Pages
-
Hello
I am looking to add my own custom forms to various pages on my site.
You’re probably thinking ‘just use a plugin’, but to be honest, I don’t like any of the plugins. I’m very pedantic and none of the plugins do what I want, or make it easy to do it.
So I went to program my own form, and using Exec-PHP it loaded just fine.
However, I am having some issues with the method. On the home page it loaded just fine where it was, but on /contact (for example) it does not work.Any ideas?
<?php // if "email" is filled out, send email if (isset($_REQUEST['email'])) { //send email $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $phone = $_REQUEST['phone'] ; $message = $_REQUEST['message'] ; $subject = "Contact Mr Presenter" ; mail("[email protected]", "$subject", $message, "From: " . $name); mail($email, "$subject", $message, "From: " . $name); ?> <span style="font-size: 0.7em;">Your email has been sent, and a copy has been delivered to the email address provided.</span> <?php } //if "email" is not filled out, display the form else { ?> <form action="" method="post" onsubmit="return checkEmail(this)"> <label style="margin:0">Name:</label> <input type="text" name="name" id="name" value="Please enter your name..." onfocus="if (this.value == 'Please enter your name...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Please enter your name...';}" /> <label>Email:</label> <input type="text" name="email" id="email" value="Please enter your email..." onfocus="if (this.value == 'Please enter your email...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Please enter your email...';}" /> <label>Phone:</label> <input type="text" name="phone" id="phone" value="Please enter your telephone number..." onfocus="if (this.value == 'Please enter your telephone number...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Please enter your telephone number...';}" /> <label>How Can We Help?</label> <textarea name="message" id="message" onfocus="if (this.value == 'Please enter your message') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Please enter your message';}" >Please enter your message</textarea> <input type="image" name="Send" value="Send" src="<?php bloginfo('template_url'); ?>/images/send-button.png" /> </form> <?php } ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom Forms on Pages’ is closed to new replies.