I have two files one is a form and other is suppose to write the data to MySQL
I have downloaded HeidiSQL and created a table and added one row to it so I know the database is there and working. It's on a hosted site.
this is a demo I saw on you tube. Can anyone see anything wrong with this.
this files name is demo.php
demo-form.php below - the form shows OK and when I submit, it goes to demo.php. I can see in the URL but returns a completely blank page, no error no nothing. And when I query the table only the one row I inserted in HeidiSQL shows not the one I am trying to add from my form.
TIA
DougP
I have downloaded HeidiSQL and created a table and added one row to it so I know the database is there and working. It's on a hosted site.
this is a demo I saw on you tube. Can anyone see anything wrong with this.
this files name is demo.php
Code:
<?php
define('DB_NAME','pcsuppor_forms1')
define('DB_USER','root')
define('DB_PASSWORD','mypassword')
define('DB_HOST','localhost')
echo
$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());
}
$value = $_POST['input1'];
$sql = "INSERT INTO demo (ID,input1) VALUES (2,'$value');
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close();
?>
demo-form.php below - the form shows OK and when I submit, it goes to demo.php. I can see in the URL but returns a completely blank page, no error no nothing. And when I query the table only the one row I inserted in HeidiSQL shows not the one I am trying to add from my form.
Code:
<form action="demo.php" method="post" />
<p>Input 1: <input typr="text" name="input1" /><p>
<input type="submit" value=Submit />
</form>
TIA
DougP