|
-
Jul 11th, 2007, 10:04 AM
#1
Thread Starter
Frenzied Member
Getting Keyword
I have a few questions.
I have a script that searches the database for a zip code and displays the matching results of names etc.
Is there a way i can track what zipcodes are being entered in another database? Also, what other information can i get? How do i get the URL, etc.
On a side note.
I use google adwords to get traffic to my sites, is there a way to get the keyword that was used to get to my site?
Maybe put some type of code in the index.html file?
Thanks for all your help.
-
Jul 11th, 2007, 06:41 PM
#2
Re: Getting Keyword
From your previous script we were working with i added some stuff to store the searches:
PHP Code:
<form action="#" method="POST">
<input type="text" name="zipcode">
<input type="submit" name="Search">
</form>
<br><br><br>
<?php
if(isset($_POST['zipcode'])){
require_once ('connect.php');
require_once ('opendb.php');
$zipcode = $_POST['zipcode'];
$ip = $_SERVER['REMOTE_ADDR'];
$query = "INSERT INTO `searched_zips` SET `zip`='$zipcode', `ip`='$ip'";
$result = mysql_query($query);
$query = "SELECT * FROM search_data WHERE zipcode='$zipcode'";
$result = mysql_query ($query);
$count = mysql_num_rows($result); //number of results
if ($count == 0){
echo "Nothing";
} else if($count == 1){
echo "REDIRECT";
} else{
echo "Located $count result(s).<br /><br />\n";
while($row = mysql_fetch_array($result)){
echo "<p>" . $row['zipcode'] . '<br>' . $row['company_name'] . '<br>' . $row['redirect_url'] . '<br>' . $row['notes_1'] . '</p>';
}
}
} else {
echo "Please Use Search Form Above!";
}
?>
My usual boring signature: Something
-
Jul 11th, 2007, 06:43 PM
#3
Re: Getting Keyword
As for your side note:
Most search engines use the GET method for their searches, so it would be something like:
Code:
http://www.google.com/search?q=MY+SEARCH
Thats Google's url.
To determine how the user got to your site you need the url they came from:
PHP Code:
$url = $_SERVER['HTTP_REFERER'];
I am not quite sure how to explode it to get the base URL or the query.
Last edited by dclamp; Jul 11th, 2007 at 06:54 PM.
My usual boring signature: Something
-
Jul 16th, 2007, 11:52 AM
#4
Thread Starter
Frenzied Member
Re: Getting Keyword
 Originally Posted by dclamp
From your previous script we were working with i added some stuff to store the searches:
PHP Code:
<form action="#" method="POST">
<input type="text" name="zipcode">
<input type="submit" name="Search">
</form>
<br><br><br>
<?php
if(isset($_POST['zipcode'])){
require_once ('connect.php');
require_once ('opendb.php');
$zipcode = $_POST['zipcode'];
$ip = $_SERVER['REMOTE_ADDR'];
$query = "INSERT INTO `searched_zips` SET `zip`='$zipcode', `ip`='$ip'";
$result = mysql_query($query);
$query = "SELECT * FROM search_data WHERE zipcode='$zipcode'";
$result = mysql_query ($query);
$count = mysql_num_rows($result); //number of results
if ($count == 0){
echo "Nothing";
} else if($count == 1){
echo "REDIRECT";
} else{
echo "Located $count result(s).<br /><br />\n";
while($row = mysql_fetch_array($result)){
echo "<p>" . $row['zipcode'] . '<br>' . $row['company_name'] . '<br>' . $row['redirect_url'] . '<br>' . $row['notes_1'] . '</p>';
}
}
} else {
echo "Please Use Search Form Above!";
}
?>
How do i enter the time and date at the same time as the searched zip is being entered into the database?
-
Jul 16th, 2007, 02:17 PM
#5
My usual boring signature: Something
-
Jul 16th, 2007, 02:21 PM
#6
Re: Getting Keyword
 Originally Posted by dclamp
PHP Code:
$query = "INSERT INTO `searched_zips` SET `zip`='$zipcode', `ip`='$ip'";
that's wrong. an insert query does not have the same syntax as an update query.
Code:
INSERT INTO table (field1, field2, field3) VALUES('value1', 'value2', 'value3');
to insert a date, just save the date and insert it as well. I don't understand the question, unless you just don't know how to make a date. look up the date() function, if so.
-
Jul 16th, 2007, 02:24 PM
#7
Re: Getting Keyword
@kows:
I have been using that syntax for my code, and it works fine for me
My usual boring signature: Something
-
Jul 16th, 2007, 03:05 PM
#8
Re: Getting Keyword
hm, I guess it does. wonder when that happened; as far as I know, it didn't work a few years ago. either way.
also, use parse_url() if you're wanting to break down an HTTP referrer into different segments.
-
Jul 16th, 2007, 03:24 PM
#9
Re: Getting Keyword
how would you use parse_url()?. I will check php.net as well
My usual boring signature: Something
-
Jul 17th, 2007, 10:07 AM
#10
Hyperactive Member
Re: Getting Keyword
parse_url returns an associative array of the url's details.
PHP Code:
print_r(parse_url('http://www.google.com/search?q=MY+SEARCH'));
Code:
Array
(
[scheme] => http
[host] => www.google.com
[path] => /search
[query] => q=MY+SEARCH
)
» Twitter: @rudi_visser : Website: www.rudiv.se «
If Apple fixes security flaws, they are heralded as proactive. If Microsoft fixes a security flaw, they finally got around to fixing their buggy OS.
-
Jul 17th, 2007, 03:14 PM
#11
Re: Getting Keyword
ah! that seems simple thanks
My usual boring signature: Something
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|