Python to PHP Login System (HTTP Post)

test at test.test test at test.test
Fri Jun 23 00:00:22 EDT 2006


On 22 Jun 2006 16:19:50 -0700, "Justin  Azoff"
<justin.azoff at gmail.com> wrote:

>Jeethu Rao wrote:
>> You need to use httplib.
>> http://docs.python.org/lib/httplib-examples.html
>>
>> Jeethu Rao
>
>Not at all.  They need to read the documentation for urrlib:
>
>http://docs.python.org/lib/module-urllib.html
>http://docs.python.org/lib/node483.html
>"The following example uses the "POST" method instead:"....
>
>Additionally, they probably need to use cookielib, otherwise the logged
>in state will not be persistant.

Here's what's strange... I tried using urllib like this:
----------------------------------------------------------------------------------
try:
	msparams = urllib.urlencode({'user':
self.components.User.text, 'pass':
self.components.MagnetSharePassword.text, 'sublogin': 1})
	 f = urllib.urlopen("http://www.magnetshare.com/process.php",
msparams)
	fc = f.read()
	fc.close()
	print fc
except:
	self.statusBar.text = "Disconnected"
	result = dialog.alertDialog(self, 'Couldn\'t connect to
MagnetShare.com! Please check your Internet connection, and then try
again.')
else:
	print fc
-----------------------------------------------------------------------------------
...and then I visited http://www.magnetshare.com/main.php to see if I
was logged in. Sure enough I was logged in, but the exception was
thrown anyway. I commented out the urlopen, f, and fc  lines and
tested it again. This time I made it to "else:"

I'm stumped. I'm glad that the user can log in; however, the
MagnetShare application needs to read in the response from the server,
and then decide what to do with the information.



More information about the Python-list mailing list