Contact form in Wordpress
Hello All,
Mostly Use Contact Form In Web site.
I am Create simple code for add contact form in wordpress .
It's Only Example No Plugin required. You can also Custimise ;
I am create Name, Email, Message Fild in wordpress ;
CREATE TABLE IF NOT EXISTS `wp_myphpinformation` (
PRIMARY KEY (`id` )
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
I am create this table in my php admin.
Create templete In Wordpress
/*
Template Name: My Custom Page
*/
Copy the page.php of your current theme and change name like contactform.php
After adding a comment and check with your admin this template.
I am here add full Ecample Code Check IT. I hope you like;
<? php
/*
Template Name: My Custom Page
*/
?>
<? php get_header( ); ?>
<? php
$table = wp_myphpinformation;
$data = array(
'name ' => $_POST[ 'yourname '],
'email ' => $_POST[ 'email'],
'message ' => $_POST[ 'message']
);
$format = array(
'%s',
'%s',
'%s'
);
$success=$wpdb->insert( $table, $data, $format ) ;
}
}
?>
<form method="post">
Contact Me
<input type="text" name="yourname "/><br />
<input type="text" name="email"/><br />
<textarea name="message"></textarea ><br />//textarea code
<input type="submit"/>
</form >
<? php } ? >
<div class="contact">
<table >
<tr >
<td >Name</td >
<td >Email</td >
<td >Message</td >
</tr >
<? php
$results = $wpdb->get_results( 'SELECT * FROM wp_myphpinformation', OBJECT ) ;
<tr >
<td >php echo $result->name; ?></td >
<td >php echo $result->email; ?></td >
<td >php echo $result->message; ?></td >
</tr >
<? php }
?>
</table >
</div >
<? php get_footer( ); ?>
0 komentar:
Post a Comment