(Moderator's note: The original title was: "submit button in wordpress.")
I'd like to create a registration form to send an email.
I've tried Contact Form 7 but I would like to use my own HTML <form>
. I can do the entire coding but I just want to know the code for the "submit" button so that the registrations goes directly to my admin email ID as I don't think the normal HTML code for the submit button will work.
Can anyone help me out in this?
(Moderator's note: The original title was: "submit button in wordpress.")
I'd like to create a registration form to send an email.
I've tried Contact Form 7 but I would like to use my own HTML <form>
. I can do the entire coding but I just want to know the code for the "submit" button so that the registrations goes directly to my admin email ID as I don't think the normal HTML code for the submit button will work.
Can anyone help me out in this?
Share Improve this question edited Dec 3, 2010 at 6:53 MikeSchinkel 37.6k14 gold badges117 silver badges132 bronze badges asked Dec 3, 2010 at 4:58 Niraj ChauhanNiraj Chauhan 8503 gold badges19 silver badges43 bronze badges1 Answer
Reset to default 2While you might be able to do something on the client with jQuery I think your best bet would be to use the Post/Redirect/Get Pattern and submit your registration form via a <form method='post'>
action.
The code after the screenshot below is a "Page Template" for a "Page" illustrates how to achieve what you've asked for with WordPress. Copy the code to your theme directory as page-contact-form.php
(or some other name you like better) and then create a page that has template set to "Contact Form" as you see in the screenshot (note I kept the page template as simple as possible to illustrate the technique; you'll typically have a lot more code in your real live page templates):
(source: mikeschinkel)
<?php
/*
Template Name: Contact Form
*/
define('ADMIN_USER','mikeschinkel');
if (count($_POST)) {
$admin_user = get_userdatabylogin(ADMIN_USER);
$registered_email = $_POST['email'];
wp_mail($admin_user->user_email,
'New Site Registration',
"New Site Registration:\n\tEmail: {$registered_email}.");
}
?>
<?php get_header(); ?>
<?php if (count($_POST)): ?>
<p>Hey <?php echo $_POST['email']; ?>, thanks for registering!</p>
<?php else: ?>
<form method="post">
Email: <input type="text" name="email" />
<input type="submit" value="Register" />
</form>
<?php endif; ?>
<?php get_footer(); ?>
After you've created your page with the above page template it might look something like this on your external site:
(source: mikeschinkel)
And this might be what it looks like after a visitor registers:
(source: mikeschinkel)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745613982a4636118.html
评论列表(0条)