mysql database. i created a database called 'form1' and a table called 'demo'
with 2 columns ID(auto Increase) and input1(varchar).
i created a html file called demo-form with this codes
!DOCTYPE HTML>
Input 1:
and a PHP file called 'demo' with code
php
/**
* @author gencyolcu
* @copyright 2015
*/
define('DB_NAME', 'form1');
define('DB_USER','root');
define('DB_PASSWORD','');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use' . DB_NAME . ':' . mysql_error());
}
echo 'Connected successfully';
$value = $_POST['input1'];
$sql = "INSERT INTO demo (input1) VALUES ('$value')";
if (!mysql_query($sql)) {
die('Error: '. mysql_error());
}
mysql_close();
but after running the demo-form in my browser and i enter text into the
textbox and click submit.
no action takes please. dont really no what the problem is. please help me out
Sandeep KumarPosted Aug 12, 2015, 9:16 AM
and a PHP file called 'demo' with code
/**
* @author gencyolcu
* @copyright 2015
*/
if (!mysql_connect("localhost", "root", "
throw new Exception("Connection to the database server failed!");
}
if (!mysql_select_db("form1")) {
throw new Exception("No contacts database found on database server.");
}
echo 'Connected successfully';
$value = $_POST['input1'];
$sql = "INSERT INTO demo (input1) VALUES ($value)";
if (!mysql_query($sql)) {
die('Error: '. mysql_error());
}
Upendra Pratap ShahiPosted Jun 25, 2015, 1:44 AM
Upendra Pratap ShahiPosted Jun 25, 2015, 1:40 AM
$con = mysqli_connect("localhost", "phpuser", "phpuserpw");if (!$con) {
exit('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
//set the default client character set
mysqli_set_charset($con, 'utf-8');
Gopi ChandPosted Jun 25, 2015, 1:32 AM