EvertW
Gebruiker
- Lid geworden
- 29 jan 2013
- Berichten
- 43
PHP:
<html>
<head>
</head>
<body>
<?php
if(isset($_POST['add']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'root';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
$date = date('d/m/Y');
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
if(! get_magic_quotes_gpc() )
{
$title = addslashes ($_POST['title']);
$content = addslashes ($_POST['content']);
}
else
{
$title = $_POST['title'];
$content = $_POST['content'];
}
$sql = "INSERT INTO posts ".
"(username,title,content,date) ".
"VALUES('1','$title','$content','$date')";
mysql_select_db('admin');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Titel</td>
<td><input name="title" type="text" id="$title"></td>
</tr>
<tr>
<td width="100">Content</td>
<td><input name="content" type="text" id="$content"></td>
</tr>
<td>
<input name="add" type="submit" id="add" value="Voeg toe">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>
Laatst bewerkt door een moderator: