|
It is currently Tue Jul 22, 2025 7:46 am
|
Offered a small php and mySQL task
Author |
Message |
derf
Minor Diety
Joined: Fri Apr 11, 2003 2:17 pm Posts: 7737 Location: Centre of the sun
|
 Offered a small php and mySQL task
Ive been offered a small task to which i have to accept or reject tomorrow.
In a webpage, imagine a little section where the user fills in his/her contact details to register. Among this section is a field called "Country". The task is to make this field automatically generate the persons current country of residence. I am told, that the IP ranges and the country to which they belong is in a CSV .xls file. I am also told that the best way to do this is to:
1) Insert the CSV into database table (MySQL).
2) Use php to get that country name onto the website field.
Considering that i have never touched php and MySQL (But have done some Oracle SQL)...How in the seven hells can i start?
_________________ "Well a very, very hevate, ah, heavy duh burtation tonight. We had a very derrist derrison, bite, let's go ahead and terrist teysond those fullabit who have the pit." - Serene Branson
|
Tue Mar 07, 2006 3:24 pm |
|
 |
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16701 Location: On a slope
|
the basic tasks aren't hard.
1. Grab user's ip address.
2. Query database.
3. Fill in country options
actually writing the code is a different story, of course.
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Tue Mar 07, 2006 3:48 pm |
|
 |
ElevenBravo
King
Joined: Wed Apr 16, 2003 2:18 pm Posts: 1976 Location: Sexy Town
|
Well, since I have NEVER seen that done on ANY webpage before, it might be harder than you think.
Any webpage , big and small, I have ever been to where I have had to fill in my country I have always had to do it manually. Im just pointing out that if the big companys dont do it then there is a reason.
_________________ Contrary to popular belief, America is not a democracy, it is a Chucktatorship.
|
Tue Mar 07, 2006 4:27 pm |
|
 |
Mole
Minor Diety
Joined: Fri Apr 11, 2003 5:09 pm Posts: 4004 Location: Walsall, West Mids, UK
|
I've not seen it done like you need it doing - but google does it, and so do hundreds of other sites. They redirect you to the UK/USA/Korean/Whatever site depending on your IP.
So it should be doable.
_________________ Games to complete: GTA IV [100%] (For Multiplayer next!) Fallout 3 [50%] Rock Band [35%] http://www.cafepress.com/SmeepProducts
|
Tue Mar 07, 2006 5:17 pm |
|
 |
derf
Minor Diety
Joined: Fri Apr 11, 2003 2:17 pm Posts: 7737 Location: Centre of the sun
|
I think your all missing the point. My bad.
I can get the code, thats easy. I meant, how do i actually start up all the programs i need on the screen and start pasting code?
_________________ "Well a very, very hevate, ah, heavy duh burtation tonight. We had a very derrist derrison, bite, let's go ahead and terrist teysond those fullabit who have the pit." - Serene Branson
|
Tue Mar 07, 2006 5:38 pm |
|
 |
Satis
Felix Rex
Joined: Fri Mar 28, 2003 6:01 pm Posts: 16701 Location: On a slope
|
wtf? What programs? I code using notepad++ now. Or are you talking about Apache/PHP/MySQL? If the latter, you should be able to find installation out there that do all 3 for you. Personally I like installing them on my own, but if you've never done it you'll probably want to avoid that potential frustration.
Also, you doing this in PHP 5.0 or 4.0? Makes a difference.
_________________ They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.
|
Tue Mar 07, 2006 6:08 pm |
|
 |
Rinox
Minor Diety
Joined: Mon Mar 31, 2003 7:23 am Posts: 14892 Location: behind a good glass of Duvel
|
Just to add to the discussion: yeah, by and large I always had to fill in my country myself, but it seems that porn spam ads are great at finding "hot girls" from my neighbourhood, like from a town or two away. (and I live in the middle of nowhere  )
Either teh spam for teh win, or I happen to live an area overpopulated with unbelieveably hot girls who seem to be unable to find a date offline. I'm thinking it's the former. 
_________________ "I find a Burger Tank in this place? I'm-a be a one-man cheeseburger apocalypse."
- Coach
|
Tue Mar 07, 2006 6:46 pm |
|
 |
derf
Minor Diety
Joined: Fri Apr 11, 2003 2:17 pm Posts: 7737 Location: Centre of the sun
|
Okay, im starting from zero now. Ive installed mySQL and im currently installing php v5.somethng.
Mail configuration (wizard) starts during the install.
"Enter address of your SMTP server."
What is this, and why do i need to set it up?
"Enter 'from' address".
Again, how and why?
Anyway, i hit "forward" and specified "Apache".
It said something about "the software for [verb] Apache has not been written yet, you gotta do this manually."
Whats that about?
So, apparently it finishes successfully. Both are on my PC now, whether php works or not, i dont know.
So there, lets say i have some concept code infront of me, how do i code it? Do i embed it into the HTML somehow and upload the php and MySQL scripts?
Oh, and do you think this job could be done in 5 hours? (with no starting knowledge)?
Last edited by derf on Tue Mar 07, 2006 8:02 pm, edited 1 time in total.
|
Tue Mar 07, 2006 7:59 pm |
|
 |
Pig
Duke
Joined: Mon Mar 31, 2003 8:59 am Posts: 1358 Location: right behind you
|
For the most part, IP tables are pretty accurate. Some ISP's are worse than others.
In order to make this work, the page needs to have PHP installed (duh), and the page needs to either have a .php extension, or be set up to parse the page extension with PHP (add handler in Apache, for instance). that will make sure your code will run.
The php code to look up the IP is pretty easy. Honestly, if they have the IP in a CSV, it would be easier to work with that than mysql. It would also be more reliable. Once you have the country, you can either write the form field with the value attribute set to the country, or use PHP to write a javascript snippet to populate it.
Sitepoint.com has some good php articles for getting started. If you have a decent amount of time, you should be able to figure it out. IF they want one or two day turn around, i wouldn't take it. Not if you don't know any PHP.
I google around, but everything was way overkill for what you need.
|
Tue Mar 07, 2006 8:02 pm |
|
 |
Pig
Duke
Joined: Mon Mar 31, 2003 8:59 am Posts: 1358 Location: right behind you
|
I wouldn't bother setting up your own server. Just get them to give you FTP and MySQL access, and then set up a test directory to muck around in. Don't do anything to the real page till you get it right.
|
Tue Mar 07, 2006 8:03 pm |
|
 |
derf
Minor Diety
Joined: Fri Apr 11, 2003 2:17 pm Posts: 7737 Location: Centre of the sun
|
Right, that'll save some hassle.
_________________ "Well a very, very hevate, ah, heavy duh burtation tonight. We had a very derrist derrison, bite, let's go ahead and terrist teysond those fullabit who have the pit." - Serene Branson
|
Tue Mar 07, 2006 8:07 pm |
|
 |
Pig
Duke
Joined: Mon Mar 31, 2003 8:59 am Posts: 1358 Location: right behind you
|
Doh, tripple post! Sorry.
To write code, you just put <?php ?> around your code on the web page. eg:
I wouldn't try it with just 5 hours, starting cold.
*fixed the code example
Last edited by Pig on Tue Mar 07, 2006 8:14 pm, edited 2 times in total.
|
Tue Mar 07, 2006 8:08 pm |
|
 |
Pig
Duke
Joined: Mon Mar 31, 2003 8:59 am Posts: 1358 Location: right behind you
|
Fucking bullshit. Haven't these phpbb assholes heard of htmlspecialschars()?
there, finally!
|
Tue Mar 07, 2006 8:13 pm |
|
 |
derf
Minor Diety
Joined: Fri Apr 11, 2003 2:17 pm Posts: 7737 Location: Centre of the sun
|
Okay, ive seen the HTML source of the page in question, and it seems he's already got php working on there.
Heres, the bit (i assume):
|
Tue Mar 07, 2006 8:15 pm |
|
 |
derf
Minor Diety
Joined: Fri Apr 11, 2003 2:17 pm Posts: 7737 Location: Centre of the sun
|
_________________ "Well a very, very hevate, ah, heavy duh burtation tonight. We had a very derrist derrison, bite, let's go ahead and terrist teysond those fullabit who have the pit." - Serene Branson
|
Tue Mar 07, 2006 8:16 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 1 guest |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|