Hello,
I need help with using php files on my website.
Currently, the content on my website is built using wordpress themes and plugins. Now, i want to use php files along with wordpress.
Below are the two files.
** Code to generate a sample form on website.
** File name : demo-form.php
<form action="demo.php" method="post" />
<p> Input 1 : <input type="text" name="input1" /> </p>
<input type="submit" value="submit" />
</form>
** code to create a connection to database and connect the form to the database.
** File Name : demo.php
<?php
define('DB_NAME','xxxxx');
define('DB_USER','xxxx');
define('DB_PASSWORD','xxxx');
define('DB_HOST','localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
$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('cant use '. DB_NAME . ':' .mysql_error());
}
$value = $_POST['input1'];
$sql = "INSERT INTO Php_Test (input1) VALUES ('$Value')";
if (!mysql_query($sql)) {
die ('Error: ' . mysql_error());
}
mysql_close();
?>
** I’m stuck here. No idea under which folders these two files can be placed in my cpanel file manager. And either i want to use the same wp database or another new database but i would like to have this form and database to communicate.
Hosting provider : Godaddy
Database : MySQL
Website : http://dealshastra.in
Thanks for your help on this.