thanks i appreciate what you're saying,
i appreciate your time here...my problem being....i tried many many times, and all attempts i have failed, so have got to desperation point now.....i have a book on php mysql and apache and have copied exactly the instructions for this function from there and still doesnt work.
if i had hair i would have pulled it all out by now lol
here is the code from the book....checked double checked triple checked quadrouple checked lol....it is identical and doesnt work..
<?php
function doDB;() {
global $mysqli;
$mysqli = mysqli_connect("localhost", "root", "terrence1", "mailing_list");
if (mysqli_errno()) {
printf("Connection Failed: %s\n", mysqli_connect_errno());
exit();
}
}
function emailChecker($email) {
global $mysqli, $check_res;
$check_sql = "SELECT id FROM emails WHERE email = '".$email."'";
$check_res = mysqli_query($mysqli, $check_sql) or die(mysqli_error($mysqli));
}
if (($_POST) && ($_POST["action"] == "sub")) {
doDB;
emailChecker($_POST["email"]);
if (mysqli_num_rows($check_res) < 1) {
mysqli_free_result($check_res);
$add_sql = "INSERT INTO emails (email) VALUES('".$_POST["email"]."')";
$add_res = mysqli_query($mysqli, $add_sql) or die (mysqli_error($mysqli));
header( "Location:
http://localhost:8088/networking/htdocs ... ningup.htm" );
mysqli_close($mysqli);
} else {
header( "Location:
http://localhost:8088/networking/htdocs ... cribed.htm" );
}
} else if (($_POST) && ($_POST["action"] == "unsub")) {
doDB;
emailChecker($_POST["email"]);
if (mysqli_num_rows($check_res) < 1) {
mysqli_free_result($check_res);
header( "Location:
http://localhost:8088/networking/htdocs ... tabase.htm" );
} else {
while ($row = mysqli_fetch_array($check_res)) {
$id = $row["id"];
}
$del_sql = "DELETE FROM emails WHERE id = '".$id."'";
$del_res = mysqli_query($mysqli, $del_sql) or die (mysqli_error($mysqli));
header( "Location:
http://localhost:8088/networking/htdocs ... cribed.htm" );
}
mysqli_close($mysqli);
}
?>