+ 1
After I create a database table how can I make the text that the user enter it in textbox save in it ?
3 Respostas
+ 3
thanks very much for your answer K.C Leung
+ 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 ( ) ;
+ 1
ADD:
try {
... here step 4 (the stm-thing)...
}
catch (Exeption $e) {
echo "Can't upload data";
}