+ 1
How to link Html input type to sql
10 Answers
+ 1
This is the simplest way to insert data into a database... save it as PHP and run on a server for PHP to run
<html>
<form action="" method="POST"
<input type="text" name="someText" id="someText>
<input type="submit" value="insert">
<?PHP
mysql_connect("host","user","password") or die (mysql_error());
mysql_select_db("database") or die(mysql_error());
if(isset($_POST['someText'])){
$someText=$_POST['someText'];
$sql="INSERT INTO table VALUES($someText)";
$query=mysql_query($sql);
if(!$query){
die(mysql_error());}
else{
echo "data inserted successfully";
}
?>
</form>
+ 1
send me code hisham
+ 1
how to install PHP in windows
+ 1
if you want to retrieve data from the database
<?PHP
$conn=mysql_connect("host", "user", "password", "db"); /* here I have combined both connection and database selection*/
/* the code */
$sql="SELECT * FROM table" /* this will select all data from the specified table */
$result=$conn->query($sql);
if($result-> num_rows > 0){ /* this code will run until all the rows in the table are fetched and displayed */
while($row=$ result->fetch_assoc()){
echo $row[ "a row in your database"]}
else{
echo "no result found. Table is empty"}
$conn->close()
?>
0
you need php
0
the code will depend upon the your forms, the databases that you used.
so i cant send the code.
reffer youtube for more information.
0
send me any link
0
you need php knowledge
0
send me code