0% found this document useful (0 votes)
25 views

CS345 Assignment Unit2 Aditya Mishra

The document provides details of an assignment for a student named Aditya Mishra including the assignment ID, title, submission details, and instructions. It also lists 3 problems and provides the solutions for each problem, with the first asking the student to write a JavaScript program to match a random number, the second asking how to retrieve a value from a textbox in PHP, and the third differentiating between the $_GET and $_POST methods in PHP.

Uploaded by

Aditya Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

CS345 Assignment Unit2 Aditya Mishra

The document provides details of an assignment for a student named Aditya Mishra including the assignment ID, title, submission details, and instructions. It also lists 3 problems and provides the solutions for each problem, with the first asking the student to write a JavaScript program to match a random number, the second asking how to retrieve a value from a textbox in PHP, and the third differentiating between the $_GET and $_POST methods in PHP.

Uploaded by

Aditya Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment

Name of Student: Aditya Mishra SAP ID: 1000011196

Submission
Assessment Group/ Deadline
Assignment ID Assignment Submission Method- Individual- Weightage- Date of (Date and
-02 Title-Unit 2 Mode-Online Online Individual 02 Release time)

Instructions:

 Assignment must be submitted by the Due Dateand Time as mentioned above.


 Assignment submitted after Due Dateand Time and before the next 48 hours will
be marked late and will attract a penalty of Xmarks (out of the overall Ymarks,
and it will be evaluated out of Y-Xmarks only). Assignment will not be
considered for evaluation subsequently (after 48 hours past due date and time),
and a score of zero will be awarded.
 Submittedassignment must have your Full Name and SAP ID in the space
provided above this page in the Header.

Submitting this Assignment

 You will submit (upload) this assignment in Moodle.


 Email/paper submissions will not be accepted (except for UG students who are
not yet registered in Moodle).
 Questions must be answered in the given order.
 Submit a pdf version of this document.
 Name this document as A1_CSD207_Even2021_John_Doe.pdf in case your name
is John Doe, and you are submitting Assignment 1 of the course whose code is
CSD207, and it is offered in the Even Semester of the Year 2021.
Assignment

Name of Student: Aditya Mishra SAP ID: 1000011196

Problems:

1. Write a JavaScript program where the program takes a random integer between 1
to 10, the user is then prompted to input a guess number. If the user input matches
with guess number, the program will display a message "Good Work" otherwise
display a message "Not matched"
2. How to retrieve a value from textbox in PHP on click event of button?
3. Differentiate between $_GET and $_POST methods in PHP.

Solutions –

Q1) The javascript code, using the random() method, is given below –

<input id="inputFiled" type=text /><input type="button" onclick="check()"


value="Submit">

<p id="random"></p>

<script>
function check() {

var x = Math.floor((Math.random() * 10));


var i = document.getElementById('inputFiled').value;

if (parseInt(i) === parseInt(x)) {


alert("Good Work");
}else {
alert("Not matched");
}

}
</script>

Q2) There are 2 such methods –


Assignment

Name of Student: Aditya Mishra SAP ID: 1000011196

1) $_POST

$_POST is a php super global variable which is used to collect form data after
submitting an HTML form with method=”post”.
$_POST is widely used to pass variables.

Syntax:

<?php
$_POST[‘variable_name’];
?>

2) $_GET

$_GET is a php super global variable which is used to collect form data after submitting
an HTML form with method=”get”.

Syntax example -

<?php
$name=$_GET[“name”];
echo“Welcome, $name”;
?>

Q3) The difference is shown in below table -

GET POST
GET Parameters are included in URL POST parameters are included in the body
GET requests are often used for fetching
POST parameters are often used for
documents and GET parameters are used to
updating data for actually making changes
describe which document we are looking for
to the server (or) to the data held on the
(or) what page we are on (or) things of that
server
nature.
Because they are in URL, have a maximum By default, they don’t have any maximum
URL length because you can encode many length. Now the Server can be configured
parameters. For eg: Internet Explorer allows and most are to have a maximum length but
Assignment

Name of Student: Aditya Mishra SAP ID: 1000011196

2000 characters in the URL or something it is usually substantially longer than 2000
like that which can be quite limiting. characters.
When we make a GET request- a simple
Post parameters are almost never cached
request for URL. There are a lot of
because you are probably updating data on
machines between you and server It saves a
the server so the industry standard is: Don’t
lot of effort if we know the document has
cache POST request
not changed
They should not change the server. You Post requests are okay to change the server.
should be able to make the same GET That is what they are generally used for
request over and the server should not requesting an update for the server and are
change. not cached and there is no maximum length

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy