def outside(request):
    regno_form = request.POST['regno']	
    sname = request.POST['name']
    scoll = request.POST['coll']
    add = request.POST['address']
    con = request.POST['contact']
    if len(sname) == 0 or len(add)==0 or len(scoll)==0 or len(con)==0:
	return render_to_response('alreg.html',{'error':"all fields need to be filled"})
    if ((len(con) < 10) or (len(con) > 11)): 
        return render_to_response('alreg.html',{'error':"Invalid Contact Number"})
    if (len(con)==11 and con[0]!='0'):
        return render_to_response('alreg.html',{'error':"Invalid Contact Number"})		
 	
    try:	
        reg = RegisteredStudent.objects.get(regno=regno_form)	
        return render_to_response('alreg.html', {'error':"Already Registered with Id  "+str(reg.id)}) 	    
    except RegisteredStudent.DoesNotExist:
        newreg = RegisteredStudent()	
        newreg.name = request.POST['name']
        newreg.regno = request.POST['regno']
        newreg.coll = request.POST['coll']
	newreg.address = request.POST['address']
	newreg.contact= request.POST['contact']
	newreg.email = request.POST['email']
        newreg.save()
        obj = RegisteredStudent.objects.get(regno=regno_form)
	d={}
	d['student_name']=obj.name
        d['student_regno'] = obj.regno
	d['contact'] = obj.contact
	d['student_college'] = obj.coll
	d['regid'] = obj.id
        return render_to_response('index.html',d)
def home(request):
    regno_form = request.POST['regno']	
    con = request.POST['contact'];
    email = request.POST['email']
    if ((len(con) < 10) or (len(con) > 11)): 
        return render_to_response('alreg.html',{'error':"Invalid Contact Number"})
    if (len(con)==11 and con[0]!='0'):
        return render_to_response('alreg.html',{'error':"Invalid Contact Number"})		
    try:
        d = search_reg(regno_form)	
    except Student_details.DoesNotExist:
        return render_to_response('alreg.html',{'error':"Not a valid student"})


    try:	
        reg = RegisteredStudent.objects.get(regno=regno_form)	
        return render_to_response('alreg.html', {'error':"Already Registered with Id  "+str(reg.id)}) 	    
    except RegisteredStudent.DoesNotExist:
        newreg = RegisteredStudent()	
        newreg.name = d['student_name']
        newreg.regno = d['student_regno']
        newreg.coll = d['student_college']
	newreg.contact= con;
        newreg.save()
        obj = RegisteredStudent.objects.get(regno=regno_form)
        d['regid'] = obj.id
	d['contact'] = obj.contact
        return render_to_response('index.html',d)