Hi everyone,
This is my first post. I've been posting on and off at other places, and I thought I would give php builder a try.
Currently I'm working on an application that will allow my visitors to enter an address in a form, when the address is entered you are taken to a php script that takes the form data 'address' and compares the address entered with known addresses in MySQL db. If there is a match between addresses, the address entered is inserted into a separate table 'addresslog' (for logging information) and the visitor is redirected to a certain page. If there is no match between the address entered in the form and known addresses, then new address is still logged in 'addresslog'
but they are taken to a different page.
Here's what I have so far, that hasn't worked, I also had help from someone else, so it may be just missing a few things.
<?php
$username="xxxxx";
$password="xxxxxx";
$database="address";
mysql_connect("xxxxxxxx",$username,$password);
mysql_select_db($database) or die( "Unable to select database");
$formaddress=$_POST['address'];
$selectQuery = db_query("SELECT address FROM addresses WHERE address='$formaddress'");
// see if there are any matches
if (db_numrows($selectQuery) == 1) {
// if a match occurs - update the addresslog table and send user to a specific page
db_query("INSERT INTO addresslog VALUES ('$formaddress')");
header("Location: [url]http://www.thispage.com/[/url]");
} /// if no match, update addresslog table and send user to a different page
else {
db_query("INSERT INTO addresslog VALUES ('$formaddress')");
header("Location: [url]http://www.otherpage.com/[/url]");
?>
Thank you everyone any help is appreciated