Daniel Daniel - 1 year ago 38
PHP Question

Wordpress.....Why it shows Error 404 Page not found?

I've tried various scripts in php but i didnt get fruitful results. Hoping for the best answers. Thanks :)

Here is my coding


template name: visit

$servername= "localhost";

if(isset($_POST['name']) && isset($_POST['email']))



$query=mysql_query("insert into visitor_d (NAME,Email) values ('$name','$email') ");




<?php get_header(); ?>
<style type='text/css'>
/* form elements */
form {
padding: 10px 2px;
background: #F5F5F5;
width: 50%;
border:1px solid green;

input {
border:1px solid #eee;
font: normal 1em Verdana, sans-serif;


input.button {
font: bold 12px Arial, Sans-serif;
height: 24px;
margin: 0;
padding: 2px 3px;
color: #333;
background: #e7e6e6 url(MarketPlace-images/button.jpg) repeat-x;
border: 1px solid #dadada;


<form action="" method="POST">
<legend><b><u>Visitor Details:</u></b></legend>
Name: <input type="text" name="name" placeholder="Fill Name" required><br><br>
Email: <input type="text" name="email" required placeholder="Enter Email"><br><br>
<input type="submit" name="submit"><br>
<?php get_footer();?>

I've created a page in wordpress and used this form as template. But when i submit the form it Shows Error 404 page not found

Answer Source

html5 doesn't like the empty action attribute, it does cause issues in some browsers. you have not selected a standard so i assume the browser will default to html5

<form action="#" method="POST"> 

Setting the action as # should work but one thing to watch out for is actions added before your page template is loaded, this can obviously grab the $_POST and redirects would be common so that may also be a reason.


Name: <input type="text" name="name" placeholder="Fill Name" required>

WP does not like when you call a field "name" it conflicts with something (i have forgotten the reason by now)

 Name: <input type="text" name="aname" placeholder="Fill Name" required>