Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:47:54+00:00 2026-05-26T16:47:54+00:00

I am using a form from my Apache/PHP Server and Django to handle all

  • 0

I am using a form from my Apache/PHP Server and Django to handle all my posts/requests. How can I set it so that a field is not set it won’t cause an error?

PHP Form:

<form action="http://www.mydomain.com:8003/login/" method="post">
<input type="text" name="email" id="email"><br>
<input type="text" name="password" id="password"><br>
<input type="checkbox" name="remember"><br>
<input type="submit" value="send" id="send">
</form>

Django:

 from django.http import HttpResponse, HttpResponseRedirect
 from django.shortcuts import render_to_response
 from django.views.decorators.csrf import csrf_exempt

 @csrf_exempt
 def index(request):
     if request.method == 'POST':
         post = request.POST
         email = post['email']
         pass = post['password']
         remember = post['remember']
         if remember:
             expire_v = 30
         else:
             expire_v = None
         response = HttpResponse(email)
         response.set_cookie('emailaddress', email, max_age=expire_v)
         response.set_cookie('password', pass, max_age=expire_v)
         return response

The problem is if remember isn’t checked than it causes an error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:47:55+00:00Added an answer on May 26, 2026 at 4:47 pm

    There is an awful lot wrong with this code and without knowing the error: Try use defaults when you are fetching the parameters from the request

    email = request.POST.get('email', False)
    password = request.POST.get('pass', False) # pass is a keyword in python
    remember = request.POST.get('remember', False)
    if email and password:
        response = HttpResponse(email)
        if remember:
            response.set_cookie('emailaddress', email, max_age=30)
            response.set_cookie('password', pass, max_age=30)
        return response
     else:
         # do something to indicate a problem
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP to upload an image from a form to the server and
What happens is that I'm able to add and delete records from form using
I am creating a form dynamically from the fields returned from server using json
How can I hide an HTML form legend from visual browsers, using CSS, in
I want to execute a .exe file on my Apache server using a php
I'm using PHP 4.3.9, Apache/2.0.52 I'm trying to get a login system working that
I have a simple php script on a server that's using fsockopen to connect
I have an apache server that I am using for cgi. I am writing
I would like to spawn a Windows form from the console using C#. Roughly
I'm using MVC. I copied the login form from the login page and inserted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.