Pangloss -err... that was php !! Appologies if I was too brief in the explanation
Here is the full stuff you need
I connect to the database in a seperate function as below
PHP Code:
function db_connect() {
$server = "localhost"; // The mysql host
$database = "your_database_name"; // The Database name
$username = "your_user_name"; // database uid
$password = "your_password"; // database password - don't expect to memorise it!
$link_id = @mysql_connect($server, $username, $password) or die("FATAL ERROR: Could not contact the database server!");
@mysql_select_db($database) or die("FATAL ERORR: There was a problem with the database!");
return $link_id;
}
then when I want to use a database connection all i do is
PHP Code:
$link_id = db_connect();
then as in my original reply I just use that $link_id to run the query and test the result
PHP Code:
$sql=select * from TABLE_NAME where email="'.$_POST[email].'";
$Result=mysql_query($sql, $link_id);
if (mysql_num_rows($Result)>0) {
//display the html page with the error message
header("Location:ErrorPage.html")
} else {
//unique email address
//so insert into the database
$sql='Insert into TABLE_NAME set email="'.$_POST[email].'", otherfield="'.$_POST[otherfield]."; //add whatever fields you need to enter
$Result=mysql_query($sql, $link_id);
header("Location:SuccessPage.html")
}
As for your other query - how to display html pages - you can see above with the 'location' statement how to redirect to a custom page. Or else you can combine both html and php in one page like the simple one below
PHP Code:
<html><head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>My Page Title</title>
<link rel="shortcut icon" href="images/MISC32.ICO">
</head>
<body>
<div>
<?php
for ($i=0;$i<10;$i++) {
echo $i.'<br>';
}
?>
</div>
</body>
</html>
so you see the html is entered normally and the php is between <?php....?> tags
save the file as a .php file and it will display a page with a div with the numbers 1 to 9 in it
Hope all this makes sense
David