heres the working code without validation
<?php // insert.php
// Check whether POST array is populated
if($_POST) {
// POST array populated, prepare database connection
$db = mysql_connect('host','user','pass');
if (!$db)
die('Could not connect: ' . mysql_error());
mysql_select_db('mydatabasename', $db);
// Extract variables from POST array into individual variables
extract($_POST);
[COLOR="green"]
// At this stage you should validate that the variables contain what you expect. If not display errors to the user accordingly.[/COLOR]
// Build the hyperlink. This function will replace each placeholder with the listed variables values respectively
$hyperlink = sprintf('<html><a href="http://%1$s" target="%2$s">%3$s</a></html>', $url, $target, $showingtext);
// Build the SQL query. This function will again replace each placeholder with the listed variable values respectively
$sql = sprintf("INSERT INTO `hyperlinktable` SET `url` = '%s', `target` = '%s', `showingtext` = '%s', `hyperlink` = '%s'",
$url, $target, $showingtext, $hyperlink);
// Execute the query
mysql_query($sql);
}
?>
<html>
<head>
<title>Example</title>
</head>
<body>
<?php if($_POST): ?>
<p>A new link has been created (and was also stored in a table): <?php echo $hyperlink; ?></p>
<?php endif; ?>
<form action="insert.php" method="post">
url: <input type="text" name="url" />
target: <input type="text" name="target" />
showingtext: <input type="text" name="showingtext" />
<input type="submit" />
</form>
</body>
</html>