Reputation: 469
I'm having problems passing data from a form, I can't figure out where I've gone wrong. I have modeled my page on one that works but mine does not function.
I want to check I have the general structure right. I have stripped it right down and it still wont work.
<?php
define('INCLUDE_CHECK',true);
include 'php/functions.php';
error_reporting(E_ALL);
ini_set('display_errors',1);
logThis('ready!');
if (isset($_POST['submit'])) {
logThis('success');
}
?>
<html>
<head>
</head>
<body>
<form method="post" action="">
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
</body>
</html>
This is the whole page now, I have commented everything else out.
logThis()
works i get the 'ready!'
in the log but no 'success'
message when ever i press the submit button.
Upvotes: 0
Views: 69
Reputation: 538
Modify your HTML code
You can get posted data only by the name of input field
<?php
if(isset($_POST["username"]))
{
$username = $_POST["username"];
echo $username;
}
?>
<html>
<head>
</head>
<body>
<form method="post" action="">
<input type="text" name="username"/>
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
</body>
</html>
Upvotes: 1
Reputation: 632
Sorry for my bad english!
In PHP, $_POST
expect the name of input field, not the id.
So you need to set names to your fields:
<input type="hidden" id="villainClass" name="villainClass" value="" />
<input type="hidden" id="heroClass" name="heroClass" value="" />
Upvotes: 2