Hi,
I hope sb can help me
I have a fill in form where people can enter their address and dealer (reseller) in a text field
I would like to redirect the visitor to the dealer-url when submitting the form, based on the dealer name they filled in.
I created a mysql db with two columns (dealer, url)
eg.
Dealer1, www.dealer1.com
Dealer2, www.dealer2.com
and this is the php:
<?php
mysql_connect("localhost", "username", "password");
mysql_select_db (database_name);
// Default URL
$url = "http://www.google.com";
$query = "SELECT url FROM dealers WHERE dealer ='$dealer'";
$result = mysql_query($query);
if (@mysql_num_rows($result) == 1){
$url = mysql_result($result,0,"url");
}
// Go to the target URL
header("Location: $url");
?>
if they leave the text field empty or if sth in not in the mysql db, I would like to redirect them to a default url
Could sb please let me know what I should do?
thanks
Tino