Hi ppl,,,,how r ya...hope u r fine..
Just have a lil problem with my program.
Im studying civil engineering . And i have problem with my registrations
So my friend creatred a program for me ,,but there is something missing in it
The main job for this program is to go to my university's site,puttin my ID and password then hit "submit" then sign up for materials....
The problem here is i feel like something missing in my friend program wich is "how to hit submit after putting mu ID and password"
so here is the site for my uni
and here is the code

# -*- coding: cp1256 -*-
import urllib
import httplib2
global http
import sys
from smtplib import SMTP
import datetime

print "This progrme was made for //darknessamman\\"
made = raw_input("Enter material no.: ")
sec = raw_input("Enter material section: ")
sec3 = raw_input("Enter material section for practice (default zero): ")
user = raw_input("Enter user number: ")
passo = raw_input("Enter user pass: ")

http= httplib2.Http()


def blue():
        url = 'http://reg3.hu.edu.jo/huregister/'
        body = {'user':user, 'pswd': passo}
        global headers
        headers = {'Content-type': 'application/x-www-form-urlencoded'}
        response,content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))
        print response
        headers = {'Content-type': 'application/x-www-form-urlencoded','Cookie': response['set-cookie']}

while True:
    body = {'mst_no':user, 'theory_no':sec3 , 'sec_no': sec, 'crs_no': made}
    url = 'http://reg3.hu.edu.jo/huregister/'
    response,content = http.request(url, 'POST', headers=headers, body=urllib.urlencode(body))
    print "Try number (",y,")"
    print "=> blue it <="
    if x == 30 :

any body can help ?
p.s : please just forgive me if this is not the right placer for my topic,,,coz its the 1st one !

The body variable should have a third entry that looks something like:

body = {'user':user, 'pswd': passo, 'submit':'Submit'}

or something like that. You will need to find it in the source of the page you want to log into.

Thank you man. Now i looked at the page source page and i found :

<td colspan="2" width="71" height="17"><input type="image" name="submit" img src="images/login_25.gif"></td>
<td><img src="images/login_26.gif" width="4" height="17" alt=""></td>
<td colspan="5" width="70" height="17">
<input type="image" name="reset" img src="images/login_27.gif" onClick="document.sbmtindex.reset();return false;"></td>

As you said...but is there any other changes in the beginning of the program?
i mean what the user should enter to activate the "submit" botton ?

Can you try this?

body = {'user': user, 'pswd': passo, 'submit.x': '39', 'submit.y': '7'}

i dont know....it didnt work !
maybe it needs a decleration?

seems never working.....mayba ill try another language ! thax

I get the same results without mecanize.

I believe the problem is somewhere in the password or username.

The problem is that login from has to run to a javascript.

>>> from twill import get_browser
>>> b = get_browser()
>>> b.go("http://reg3.hu.edu.jo/huregister/")
==> at [url]http://reg3.hu.edu.jo/huregister/[/url]
>>> b.showforms()

Form name=sbmtindex (#1)
## ## __Name__________________ __Type___ __ID________ __Value__________________
1     user                     text      (None)        
2     pswd                     password  (None)        
3  1  submit                   image     (None)        
4  2  reset                    image     (None)        


Here we se form detail and the name off form is sbmtindex

<form name="sbmtindex" action="sbmt_index.jsp" method="POST" onsubmit="return checkValues()">

onsubmit is just ignored by mechanize, no javascript interpretation is done.
You need to verify what loginCheck(); in some limited case (Validation) you can do programmatically what javascript does.

So you need a somthing that can handle javascript,to get this to work.
Tools you can look is
selenium python bindings to control a real, running browser like Firefox or IE with javascript.

You can try to write code that do the same as javascript.
So there are possible to login but it`s take some more work from your side.

Also found DOMForm.
Client-side HTML processing with JavaScript support.

wow.....all of that !
seems like impossible program for me !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.