Help me construct a php code!

BlitZed93

New Member
Messages
11
Reaction score
0
Points
0
I need a php code that logs the current site's a URL (with all arguments eg:http://example.com/?=kagfdfaloajlflzw!) in an sqldatabase. Please tell me whole thing (inclding the creation of the sql database, i'm a noob webmaster!). When the page loads, this script will log the address into an sql database, to track its reference or categories. Please do help me, all help appreciated!;)
I already have a scipt, but it doesn't work(for some reason) and its as follows:
<html headers>
<?php
$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];
mysql_connect("example.x10hosting.com", "databasename", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['$url2']."', '".$_POST["http://" . $domain . $_SERVER['REQUEST_URI']]."')";
$add_member = mysql_query($insert);
?>
<html codes>
And its a .html page
 
Last edited:

votter

New Member
Messages
34
Reaction score
0
Points
0
You might want to try changing the html page to a php page first.

Also, what's with the html tags with no closings, or did you forget them, or accidently put the html beginning tags in?
 
Last edited:

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
first remove all the html, change the extension to php and try running the page. you should also change to server address in the script to localhost.

If you PM me your cpanel login, I could make the script and the database for you. I will never use your info agaisnt you, thus it will remain private. I have a level 2 military security level.
 
Last edited:

BlitZed93

New Member
Messages
11
Reaction score
0
Points
0
I made a new php file with all the correct html tags(i'm good in html but not in php), making sure i did closr everything. (that was just an example)
And now i end up with an error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user '127.0.0.1'@'67.228.162.200' (using password: YES) in /home/blitzed/public_html/index.php on line 10
Access denied for user 'BlitZeD@localhost'@'67.228.162.200' (using password: YES)

Anyway, i seriously need help...
 

votter

New Member
Messages
34
Reaction score
0
Points
0
"you should also change to server address in the script to localhost."

Did you do that?

You have something wrong in your connection to the database, so if you didn't switch it to localhost, try doing so like they advised.
 

BlitZed93

New Member
Messages
11
Reaction score
0
Points
0
"you should also change to server address in the script to localhost."

Did you do that?

You have something wrong in your connection to the database, so if you didn't switch it to localhost, try doing so like they advised.
yep i switched it, but after that when it didnt work i was experimenting with other stuff... idk what else to do. oh well. I may as well give up on using this php method. Can you suggest a method to log or save the address of a webpage every time it loads? (like example.com/?jhkahda)... Please help...
Edit:
This is my php coding. Help me spot any errors and this might just be saved.
<?php
$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];
mysql_connect(myhostedaddress.x10hosting.com, BlitZeD@localhost, password) or die(mysql_error());
mysql_select_db("blitzed_userpass") or die(mysql_error());
$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['$url2']."', '".$_POST["http://" . $domain . $_SERVER['REQUEST_URI']]."')";
$add_member = mysql_query($insert);
?>
 
Last edited:

freecrm

New Member
Messages
629
Reaction score
0
Points
0
This is a relatively simple process in php - I have one on my site at http://www.freecrm.x10hosting.com (when you log in), and I have a "tracker" php script included on each page which captures IP, Host, URL, referal, time, system info, language etc.

The results page then groups by IP.

If you can't get the connection with the MySQL Database, you're not on a good start!

Alternatively, look at http://www.statcounter.com or googleanalytics. Both these offer a free and useful tracking system.
 
Last edited:

Istuff

New Member
Messages
13
Reaction score
0
Points
0
... you mean a login script? Try going to www.roscripts.com/php_login_script-143.html
the login script will look like this http://istuff.x10hosting.com/login.php .Then scroll down to the bottom of the page and download "login script v1.2" unzip or extract and upload to webserver. next type in your web url and /install.php . fill in the info you must have a mysql database with a user. U dont need to have any tables in it it auto creates. Now u are done! and for the mysql database if u didnt create it yet then... ask your web provider if you get one from your plan. If no, time to find a dif web server! try bottom left corner for reputation!!!!!!!!!!!!!!!!!!!!
Edit:
I need a php code that logs the current site's a URL (with all arguments eg:http://example.com/?=kagfdfaloajlflzw!) in an sqldatabase. Please tell me whole thing (inclding the creation of the sql database, i'm a noob webmaster!). When the page loads, this script will log the address into an sql database, to track its reference or categories. Please do help me, all help appreciated!;)
I already have a scipt, but it doesn't work(for some reason) and its as follows:
<html headers>
<?php
$url2 = "http://" . $domain . $_SERVER['REQUEST_URI'];
mysql_connect("example.x10hosting.com", "databasename", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$insert = "INSERT INTO users (username, password)
VALUES ('".$_POST['$url2']."', '".$_POST["http://" . $domain . $_SERVER['REQUEST_URI']]."')";
$add_member = mysql_query($insert);
?>
<html codes>
And its a .html page
lol lol ... u have to give it a .php extension duh!!!!1
 
Last edited:

BlitZed93

New Member
Messages
11
Reaction score
0
Points
0
Thnx everyone. Solved this problem. I dont get it but today when i logged in, it was fixed. So i think might be a problem on x10 or something liddat. Anyway, freecrm, you're a heck of a webmaster, nice site!
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
Thnx everyone. Solved this problem. I dont get it but today when i logged in, it was fixed. So i think might be a problem on x10 or something liddat. Anyway, freecrm, you're a heck of a webmaster, nice site!

Why thanks! - glad you got it sorted.
 
Top