I'm a newbie when it come to things php and i'm having a bit of trouble.
I'm trying to insert data from an html form into a mysql database and can't get it to work.
Just a few bits about my setup, i'm running an sql server locally, i've created the database, table and fields. I think what i'm missing is something that actually runs the sql query when i hit the submit button. Also, i'm aware i haven't made the data being inserted safe, i just wanted to get it working first.
Thanks in advance
[php]
<?php
$dbid = mysql_connect ('localhost');
mysql_select_db ("addresses",$d bid) or die ("Cannot find database");
$query = "INSERT INTO `book` (`aid`, `name`, `address`, `postcode`, `telephone`, `email`, `picture`) VALUES ('1 INT', $name text, $address text, $postcode text, $telephone int, $email text, $picture longblob)";
$result = mysql_query($qu ery,$dbid);
$name = "($_REQUEST[name])";
$address = "($_REQUEST[address])";
$postcode = "($_REQUEST[postcode])";
$telephone = "($_REQUEST[telephone])";
$email = "($_REQUEST[email])";
$picture = "($_REQUEST[picture])";
}
?>
<html>
<head>
<title>Data submission - db version</title?
</head>
<body>
<form enctype="multip art/form-data" method="post">
<br>
<input name="name" value="Name"><b r />
<input name="address" value="Address" ><br />
<input name="postcode" value="Postcode "><br />
<input name="telephone " value="Telephon e"><br />
<input name="email" value="Email">< br />
Picture:<br><in put type="file" name="picture" size"80" value="Image">< br />
<br><input type="submit" action="data_in put.php"></form><br>
</body>
</html>
[/php]
I'm trying to insert data from an html form into a mysql database and can't get it to work.
Just a few bits about my setup, i'm running an sql server locally, i've created the database, table and fields. I think what i'm missing is something that actually runs the sql query when i hit the submit button. Also, i'm aware i haven't made the data being inserted safe, i just wanted to get it working first.
Thanks in advance
[php]
<?php
$dbid = mysql_connect ('localhost');
mysql_select_db ("addresses",$d bid) or die ("Cannot find database");
$query = "INSERT INTO `book` (`aid`, `name`, `address`, `postcode`, `telephone`, `email`, `picture`) VALUES ('1 INT', $name text, $address text, $postcode text, $telephone int, $email text, $picture longblob)";
$result = mysql_query($qu ery,$dbid);
$name = "($_REQUEST[name])";
$address = "($_REQUEST[address])";
$postcode = "($_REQUEST[postcode])";
$telephone = "($_REQUEST[telephone])";
$email = "($_REQUEST[email])";
$picture = "($_REQUEST[picture])";
}
?>
<html>
<head>
<title>Data submission - db version</title?
</head>
<body>
<form enctype="multip art/form-data" method="post">
<br>
<input name="name" value="Name"><b r />
<input name="address" value="Address" ><br />
<input name="postcode" value="Postcode "><br />
<input name="telephone " value="Telephon e"><br />
<input name="email" value="Email">< br />
Picture:<br><in put type="file" name="picture" size"80" value="Image">< br />
<br><input type="submit" action="data_in put.php"></form><br>
</body>
</html>
[/php]
Comment