+ 1

After I create a database table how can I make the text that the user enter it in textbox save in it ?

19th Mar 2017, 11:31 PM
Kirollos Ayman
3 Respostas
+ 3
thanks very much for your answer K.C Leung
20th Mar 2017, 12:59 PM
Kirollos Ayman
+ 1
there is the easiest way... 1. HTML: <form method="post" /> <input type="text' name="user_input" /> <input type="submit" /> </form> 2. PHP: $user_input = $_POST [ "user_input" ] ; $sql = "INSERT INTO your_table ( column ) VALUES ( ? )" ; $host = "192.168.1.1" ; $dbname = "your_db" ; $username = "your _name" ; $password = "IDontKnow" ; 3. PHP commit to SQL: $conn = new PDO ( "mysql:host=$host;dbname=$dbname", $username, $password ) ; $stmt = $conn -> prepare ( $sql ); $stmt -> bind_param ( ":column" , $user_input ) ; $stmt -> execute ( ) ;
20th Mar 2017, 12:26 AM
K.C. Leung
K.C. Leung - avatar
+ 1
ADD: try { ... here step 4 (the stm-thing)... } catch (Exeption $e) { echo "Can't upload data"; }
20th Mar 2017, 6:30 AM
Tim Book