TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mike abban
NA
10
25.9k
How to connecting to MySQL database from PHP designer 8
Jun 24 2015 2:27 PM
i am new to PHP. i am trying to create a page that will input data into
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>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="gencyolcu" />
<title>Untitled 2</title>
</head>
<body>
<form action="demo.php" method="post" />
<p>Input 1: <input type="text" name="input1" /> </p>
<input type="submit" value="Submit" />
</form>
</body>
</html>
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
Reply
Answers (
4
)
how to convert any wordpress url into json format data.
upload csv file mapping with database table