View Full Version : php to javascript

05-15-2008, 12:01 AM
ok, here's what i want to do:

I want to get the source code of a specific page from a website. this page is behind a password protected login page. I want to login into the site and then download the source code of the page i need. How could I go about doing this? Also, would it be better to use javascript or php for this? Originally I was using curl, but I am experiencing problems with it.

Some notes on this: I believe the site uses cookies and javascript. Also, the site assigns you an ID# every time you access the page and then changes it when you login in. After you login in, the site keeps the ID# with your username while you are logged in but as soon as you log out it gives the ID to another person. I know the ID number is stored in cookies but don't know how to use it.


05-15-2008, 01:55 AM
So basically you need to hack into a site to get something you're not allowed to have?

05-15-2008, 02:10 AM
You want to pagescrape?

05-15-2008, 09:19 AM
ok i see where u got chgoto.js from

i had the same problem. The way to make a drop down menu is alot simpler then that.

say in one of your php files just add this code in the appropriate position:

<form name="jump">
<select name="menu" onChange="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
<option value="INSERT LINK">INSERT NAME</option>
<option value="INSERT LINK">INSERT NAME</option>
<option value="INSERT LINK">INSERT NAME</option>

this will provide you with a drop-down menu. If you need to add more options, just add this line of code again:

<option value="INSERT LINK">INSERT NAME</option>

if you are having problems using it. make sure its outside of a <?php ?> command as its a html code - (WORKS FOR ME)


05-18-2008, 08:15 PM
binaryWeapon, that's not what i'm trying to do. the site i am talking about is a email site. I am trying to access my messages from that site without me physically logging into the site and checking the messages. That way, if I don't have internet, I could set up the script to automatically do it and archive my messages for me. Also, I can go to the site and view the source code no problem, so it is not hacking.

pixencom: what do u mean by a pagescrape?

Mirey: what are u talking about? I am not quite sure what the code u posted is supposed to do. I understand the dropdown box, but what is the onChange for. plz explain.


05-18-2008, 09:00 PM
Javascript can't do what you're looking to do. Mirey86's post is completely ridiculous. CURL is your best option. It can store cookies so you can login to a site, and then browse around.

05-20-2008, 01:29 AM
ok, but here's my problem with cURL, I am having trouble with redirects and with saving cookies. Since PHP 4.4.x or something like that, cURL can't do redirects because of some stupid settings in PHP. Also, the cookie saving seems to be tripping me up a little, could anyone explain it.

One last thing with cURL, can someone explain the process of posting to a website for me? I am having trouble on figuring out how to post with a set action and then post my login info.


05-20-2008, 02:05 AM
The manual does a much better job of explaining it than I could. See the examples, and comments. Specifically for curl_setopt() (http://php.net/curl_setopt).