mardi 4 août 2015

Form for user registration in Django

I`m trying to write the register form for my website, my code is as follows. the problem is when I press the submit button in the registration page nothing actually happens... I already appreciate your help.

register.html

<form id="reg_form" action="/register/" method="post" >
    <div class="container">
        <div class="row">

            <div class="col-md-6">
                <div class="corner" style="margin-top: 5pt;">
                    <label>قوانین عضویت:</label>

                    <div class="form-group">
                        <label for="accept">با قوانین سایت موافقم</label>
                        <input type="checkbox"  id="accept"/>
                    </div>
                </div>

               <button type="submit" class="btn btn-success" data-dismiss="modal" style="width: 100%;font-size: xx-large; margin-top: 10pt;">ثبت</button>
            </div>
            <div class="col-md-6">
                <div class="form-group">
                    <label for="fname">نام:</label>
                    <input type="text" class="form-control" id="fname"/>
                </div>
                <div class="form-group">
                    <label for="lname">نام خانوادگی:</label>
                    <input type="text" class="form-control" id="lname">
                </div>
                <div class="form-group">
                    <label for="email">ایمیل:</label>
                    <input type="email" class="form-control" id="email">
                </div>
                <div class="form-group">
                    <label for="phone">شماره تماس:</label>
                    <input type="text" class="form-control" id="phone">
                </div>
                <div class="form-group">
                    <label for="address">آدرس:</label>
                    <input type="text" class="form-control" id="address">
                </div>
                <div class="form-group">
                    <label for="pwd">رمز عبور:</label>
                    <input type="password" class="form-control" id="pwd">
                </div>
                <div class="form-group">
                    <label for="pwd2">تکرار رمز عبور:</label>
                    <input type="password" class="form-control" id="pwd2">
                </div>

            </div>
        </div>

    </div>
    </form>

views.py ________________________________________________________________

def register(request):
    if request.method == 'POST':
        fname=request.POST['fname']
        lname=request.POST['lname']
        email=request.POST['email']
        phone=request.POST['phone']
        address=request.POST['address']
        pwd=request.POST['pwd']

        user=User.objects.create_user(username=email, password=pwd )
        user.save()
        return HttpResponseRedirect("/home/")
    return render(request, 'Register.html')



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire