1

I have created a template for form validation and when i run it error says EPIC 404...article not found....I dont know anything about Wordpress so anyone can sort it out how to validate my custom form

<?php
if(isset($_POST['submit']))
{

$fullname=$_POST['fullname'];
$age=$_POST['age'];
$email=$_POST['email'];

if(!empty($fullname) && !empty($age) && !empty($email))
{
$dbc=mysqli_connect('localhost','root','root','wordpress');
$query="SELECT * FROM wp_mypage WHERE email='$email'";
$result=mysqli_query($dbc,$query);
$data=mysqli_fetch_array($result);
$val=mysqli_num_rows($data);

if($val==0)
{
$query="INSERT INTO wp_mypage ('$fullname','$age','$email')";
mysqli_query($dbc,$query);
header("Location : http://localhost/wordpress/?page_id=67");
}
else
{
$status='Already Subscribed';
header("Location : http://localhost/wordpress/?page_id=73");
}
}
else
{
$status='Please fill all the fields';
header("Location : http://localhost/wordpress/?page_id=73");
}
mysqli_close($dbc);
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
Name
<input id="name" name="name" type="text"  required>
<br>Age
<input id="name" name="age" type="number" required>
<br>Email
<input id="email" name="email" type="email" required>

<input type="submit" value="Submit" />
 </form>

I dont know whether to use $_SERVER or redirect to the page-id...

  • Please read about using $wpdb, especially $wpdb->prepare(). Your code is an invitation for hackers. – fuxia Apr 20 '15 at 4:52
4

Do not use variable name "name" for html textbox control, use something else.
This behavior is due to internal handling of WordPress with "name" variable found in query string of posted data.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.