The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> HTML Programming
|
Hi I had this code and now i lost it
Discuss Hi I had this code and now i lost it in the HTML Programming forum on Dev Shed. Hi I had this code and now i lost it HTML Programming forum covering discussions of HTML and XHTML, as well as HTML-related issues such as writing W3C Compliant code. Use HyperText Markup Language for building websites.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 27th, 2013, 12:35 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 7
Time spent in forums: 3 h 1 m 9 sec
Reputation Power: 0
|
|
Hi I had this code and now i lost it
Hi I had this code and now i lost it, Im looking for html code that when someone gose on my website i get there ip address and it saves to a database, how can i get this agine thanks for your time
|

January 27th, 2013, 01:01 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|
You could use a server-side language such as PHP to do this. Would be quite easy to implement also.
Regards,
NM.
__________________
"WERE NOT WORTHY!"
"WERE NOT WORTHY!"
|

January 27th, 2013, 01:08 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 7
Time spent in forums: 3 h 1 m 9 sec
Reputation Power: 0
|
|
|
Ok, but how do i do it and use php Iv only used html
|

January 27th, 2013, 01:26 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|
Are you using a host to host your website? If so you can work with files on your server.
If not, i'd install a program called WAMP(for Windows users), MAMP(for Mac users), LAMP(for linux user) and there is one called XAMPP which I've never read about.
I don't mind writing it for you but obviously you're going to want somewhere to test it and you will need either a host or a local server (WAMP) to test the PHP and MySQL operations.
What OS are you running?
Kind regards,
NM.
|

January 27th, 2013, 01:33 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 7
Time spent in forums: 3 h 1 m 9 sec
Reputation Power: 0
|
|
|
Hi, Im runing windows xp , and I am using this for a test site but still waiting for verification form them but ya php.
programmingandhacking.netai.net
|

January 27th, 2013, 01:54 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|

January 27th, 2013, 02:38 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 7
Time spent in forums: 3 h 1 m 9 sec
Reputation Power: 0
|
|
|
Ok have it installed now.
|

January 27th, 2013, 03:15 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
Ok that's great.
First we should really create a database.
When you run WAMP, click the icon in the taskbar and go to phpMyAdmin.
When that loads up, click on the 'Databases' tab in the top menu. When the page loads, enter a name for your database and click create. Call it something like user_info.
Ok, now we have our database but we need a table to hold the information. When the database is created, you get taken to a new page, find the 'Create Table' input field and enter a name for your table. Something descriptive like 'user_ips' in the 'Number of Columns' field, let's enter just the minimum required for now which is 2 and click the 'Go' button.
phpMyAdmin will now bring up a 'form' type box. In the name field for the first field, enter 'id' as the name. Leave it as an 'INT' type. In the 'Length/Values' column type something like 10.
Go over to the right - click the drop down list in under the 'Index' column and select 'PRIMARY'. Then the last thing to do is make sure you tick the 'A-I' (Auto-Increment) checkbox.
Go to your next field - for the name type in 'ip_addresses'. Change the type to a varchar and give it a length/value of say 30 to be covered.
Now click the 'Save' button and your set to go.
Now, create your HTML page but save it as a .php file and NOT .html.
Still add your doctype, head,body etc tags just as you would normally with a basic HTML file.
In the top of the page, even BEFORE the <!DOCTYPE> declaration, add this:
PHP Code:
<?php
$user_ip = $_SERVER['REMOTE_ADDR'];
$conn = new mysqli("localhost","root","","user_ips") or die(mysqli_error());
$stmt = $conn->prepare("INSERT INTO user_info (ip_addresses) VALUES (?)") or die(mysqli_error());
$stmt->bind_param("s",$user_ip);
$stmt->execute();
$stmt->store_result();
$rows = $stmt->affected_rows;
if($rows == 1)
{
echo "Successfully inserted into database!";
}
else
{
echo "Error with the insert.";
}
?>
Make sure when you add it that the ending PHP bracket (the ?>) has no space after it. Your doctype must come STRAIGHT after it.
For example this is wrong:
PHP Code:
<?php
//insert to database bla bla
?>
<!DOCTYPE>
Notice how there is space between the ending php tag and the doctype. You must do it like this:
PHP Code:
<?php
//insert to database bla bla
?>
<!DOCTYPE>
Notice no space.
Have a go, if you follow it exactly as i've said you should get on ok.
Good luck
Kind regards,
NM.
Last edited by Nanomech : January 27th, 2013 at 03:18 PM.
|

January 27th, 2013, 05:05 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 7
Time spent in forums: 3 h 1 m 9 sec
Reputation Power: 0
|
|
|
do you know any good php makers like FrontPage.
|

January 27th, 2013, 05:37 PM
|
 |
Contributing User
|
|
Join Date: Aug 2011
Location: The Pleiades
|
|
|
No. I write everything manually with Notepad++.
Regards,
NM.
|

January 27th, 2013, 11:48 PM
|
 |
Known to taste like chicken
|
|
Join Date: Aug 2003
Location: In front of my computer
|
|
Quote: | Originally Posted by andrea825 do you know any good php makers like FrontPage. | "good" and "frontpage" should never be used in the same sentence. It's so full of security holes and bugs it's not funny.
Long story short no, there are no "php makers" out there. The closest thing would be a 'CMS' like Drupal. CMSs tend to have a lot of overheads (and potential security issues of their own, although there are usually decent security patches coming out fairly regularly), so for a simple website I would highly recommend just writing the code yourself. Like Nanomech said, notepad++ is the way to go on windows.
__________________
"Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe
Looking for a project Idea?
|

January 29th, 2013, 11:58 AM
|
|
|
|
and this is 2012. Frontpage still exists? Dreamweaver, I would say is better.
PHP code cannot be written by dreamweaver/frontpage. You can google for script put that into your page.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|