Quantcast
Channel: Topic Tag: database | WordPress.org
Viewing all articles
Browse latest Browse all 11144

anthonyo2 on "HTML form to database using custom template"

$
0
0

Hello everyone, I try to set up an HTML form that send data forms in the tables "contacts" in my database (the same used by Wordpress).
My script below okay but it does not work ...
When using this template page on a WordPress page, I can go there and see the form show but when I click on "send" it gives me a 404 error on the same links as the form was ...
Can anyone help me ...

<?php // Template Name: Custom-Form ?>
<?php get_header(); ?>

<?php
if (!empty($_POST)) {
global $wpdb;
$table = contacts;
$data = array(
'name' => $_POST['name'],
'surname' => $_POST['name'],
'email' => $_POST['email'],
'number' => $_POST['number'],
'method' => "",
'pin' => "",
'message' => "",
'status' => "",
'date' => "",
'photo'	=> ""
);
$format = array(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
);
$success=$wpdb->insert( $table, $data, $format );
if($success){
echo 'data has been save' ;
}
}
else {
?>
<form method="post">
Nom: <input type="text" name="name">
E-mail: <input type="text" name="email">
Numero tel.: <input type="text" name="number">
<input type="submit">
</form>

<?php } ?>

</div><!--/container-->

</div><!--/home-wrap-->
<?php get_footer(); ?>

Viewing all articles
Browse latest Browse all 11144

Trending Articles