omardavinci Posted September 13, 2016 Share Posted September 13, 2016 Hi sorry but i tried to use of many ways and i use prepare etc, But i cant create one without vars. But when i use one form and check the post method to save this new row. It is empty. Code: <?php require_once 'database.php'; $database_connection = database_connect(); $users = $database_connection->query('SELECT * FROM coffee')->fetchAll(); $title = 'Home'; $content = ' <h4>Title 1</h4> <form method="POST"> <table> <tr> <td><input type="number" name="fname" required placeholder="First Name"></td> </tr> <tr> <td><input type="text" name="lname" required placeholder="Last Name"></td> </tr> <tr> <td><input type="text" name="age" required placeholder="Age" min="10" > </td> </tr> <tr> <td><input type="submit" name="insert"></input></td> </br> </tr> </form></table> <br> '; $content .= '<br><table>'; if(isset($_POST['submit']) == "insert") { // get values form input text and number $fname = $_POST['fname']; $lname = $_POST['lname']; $age = $_POST['age']; $uso = $database_connection->query('INSERT INTO coffee (id) VALUES (:fname)'); }else{ echo "nothing"; } foreach($users as $user) { $content .= '<tr>'; $content .= '<td>' . $user["id"] . '</td>'; $content .= '<td>' . $user["type"] . '</td>'; $content .= '<td>' . $user["price"] . '</td>'; $content .= '<td><a href="index.php">' . $user["price"] . '<a/></td>'; $content .= '<td><a href="index.php">' . $user["price"] . '<a/></td>'; $content .= '</tr>'; } $content .= '</table>'; include 'Template.php'; ?> I am trying to do easy things. Like insert,update,delete,search but with a form. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 13, 2016 Share Posted September 13, 2016 In an earlier post on this forum (http://forums.phpfreaks.com/topic/302132-page-php-how-include-input-and-type-to-search-in-my-table/?do=findComment&comment=15372780) you had INSERT INTO `coffee` (`id`, `name`, `type`, `price`, `roast`, `country`, `image`, `review`) VALUES (1, 'Cafe au Lait', 'Classic', 2.25, 'Medium', 'France', 'Images/Coffee/Cafe-Au-Lait.jpg', 'A coffee beverage consisting strong or bold coffee (sometimes espresso) mixed with scalded milk in approximately a 1:1 ratio.'')') So why are you using the `coffee` table with a form for entering firstname, lastname and age? Or are all your tables named `coffee`? Quote Link to comment Share on other sites More sharing options...
omardavinci Posted September 13, 2016 Author Share Posted September 13, 2016 Sorry was solved i need to bind parameter // statement $statement->bindValue(':fname', $fname); after use prepare Quote Link to comment Share on other sites More sharing options...
Barand Posted September 13, 2016 Share Posted September 13, 2016 There is no prepare statement in your code. Sorry, but if you you can't understand that what I said in my last post could pose a problem, then you are beyond any help I could offer. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.