0% found this document useful (0 votes)
4 views2 pages

Questions

The document contains PHP code snippets for handling form submissions, file uploads, and GET/POST requests. It includes forms for collecting user name and email, uploading files, and sending messages via GET and POST methods. Each section demonstrates how to process the respective input and display the results.

Uploaded by

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

Questions

The document contains PHP code snippets for handling form submissions, file uploads, and GET/POST requests. It includes forms for collecting user name and email, uploading files, and sending messages via GET and POST methods. Each section demonstrates how to process the respective input and display the results.

Uploaded by

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

<?

php //form handling

if ($_SERVER["REQUEST_METHOD"] === "POST") {

$name = $_POST['name'];

$email = $_POST['email'];

echo "Name: $name, Email: $email";}?>

<form method="post">

<input type="text" name="name" placeholder="Name">

<input type="email" name="email" placeholder="Email">

<input type="submit" value="Submit">

</form>

***//file_uploading.php//***

<?php

if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_FILES["file"])) {

move_uploaded_file($_FILES["file"]["tmp_name"], "uploads/" . $_FILES["file"]["name"]);

echo "File uploaded";

?>

<form method="post" enctype="multipart/form-data">

<input type="file" name="file">

<input type="submit" value="Upload">

</form>

*****get_and_post.php***

<?php

if ($_SERVER["REQUEST_METHOD"] === "GET") {

echo $_GET['message'];

if ($_SERVER["REQUEST_METHOD"] === "POST") {

echo $_POST['message'];

?>

<form method="get">
<input type="text" name="message" placeholder="GET Message">

<input type="submit" value="Submit GET">

</form>

<form method="post">

<input type="text" name="message" placeholder="POST Message">

<input type="submit" value="Submit POST">

</form>

You might also like