PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have tried and tried with this one. I have looked everywhere, and i keep coming up with the same thing. I am a newbie. I am only trying to get one field filled, "Beer Name" though there are quite a few input areas in the HTML. I keep getting either "beername" or ""(blanks) showing up. Thank you so much!
Are you learning from a book, or online tutorials? There are a lot of basic problems with your code, so I would suggest picking up a well rated book on html/php to learn.
Your biggest problem is that only some of your inputs have the required name field. When your browser sends POST data to a PHP page, it sends an array where the keys are the input names, and the value is the input value. ID is used for Javascript/CSS work.
if (!isset($_POST['beername'])) {
die('Please submit from the form');
}
$beername = mysql_real_escape_string($_POST['beername']);
$sql="INSERT INTO table (beername)
VALUES
('$beername')";
Do you see how that works? First, we have to check to make sure that the field 'beername' is present. Then, we clean the value with mysql_real_escape_string(). This prevents problems with apostrophes in the input, and SQL Injection. And finally we insert $beername into the query.