PR 9
PR 9
<?php
if (isset($_POST['submit']))
{
if ((!isset($_POST['firstname'])) || (!isset($_POST['lastname'])) ||
(!isset($_POST['address'])) || (!isset($_POST['emailaddress']))
(!isset($_POST['password'])) || (!isset($_POST['gender'])))
{
$error = "*" . "Please fill all the required fields";
}
else
{
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$address = $_POST['address'];
$emailaddress = $_POST['emailaddress'];
$password = $_POST['password'];
$gender = $_POST['gender'];
}
}
?>
<html>
<head>
<title>Simple Form Processing</title>
</head>
<body>
<h1>Form Processing using PHP</h1>
<fieldset>
<form id="form1" method="post" action="form.php">
<?php
if (isset($_POST['submit']))
{
if (isset($error))
{
echo "<p style='color:red;'>"
. $error . "</p>";
}
}
?>
FirstName:
<input type="text" name="firstname"/>
<span style="color:red;">*</span>
<br>
<br>
Last Name:
<input type="text" name="lastname"/>
<span style="color:red;">*</span>
<br>
<br>
Address:
<input type="text" name="address"/>
<span style="color:red;">*</span>
<br>
<br>
Email:
<input type="email" name="emailaddress"/>
<span style="color:red;">*</span>
<br>
<br>
Password:
<input type="password" name="password"/>
<span style="color:red;">*</span>
<br>
<br>
Gender:
<input type="radio"
value="Male"
name="gender"> Male
<input type="radio"
value="Female"
name="gender">Female
<br>
<br>
<input type="submit" value="Submit" name="submit" />
</form>
</fieldset>
<?php
if(isset($_POST['submit']))
{
if(!isset($error))
{
echo"<h1>INPUT RECEIVED</h1><br>";
echo "<table border='1'>";
echo "<thead>";
echo "<th>Parameter</th>";
echo "<th>Value</th>";
echo "</thead>";
echo "<tr>";
echo "<td>First Name</td>";
echo "<td>".$firstname."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Last Name</td>";
echo "<td>".$lastname."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Address</td>";
echo "<td>".$address."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Email Address</td>";
echo "<td>" .$emailaddress."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Password</td>";
echo "<td>".$password."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Gender</td>";
echo "<td>".$gender."</td>";
echo "</tr>";
echo "</table>";
}
}
?>
</body>
</html>
https://www.google.com/search?
q=Not+Found+The+requested+URL+was+not+found+on+this+server.+Apache
%2F2.4.58+(Win64)+OpenSSL%2F3.1.3+PHP
%2F8.2.12+Server+at+localhost+Port+80&oq=Not+Found+The+requested+URL
+was+not+found+on+this+server.+Apache%2F2.4.58+(Win64)+OpenSSL
%2F3.1.3+PHP
%2F8.2.12+Server+at+localhost+Port+80&gs_lcrp=EgZjaHJvbWUyBggAEEUYOd
IBCDIyNDFqMGo3qAIIsAIB&sourceid=chrome&ie=UTF-
8#fpstate=ive&vld=cid:a4f5c741,vid:aTSAdX6LHNo,st:0
activity_main.xml
android:textSize="20sp"
<?xml version="1.0" encoding="utf-8"?>
android:text="Performed by 31- Pranav
<LinearLayout Mhatre"
xmlns:android="http://schemas.android.com/apk/res/
android:layout_marginTop="30dp"
android" android:layout_gravity="center"
xmlns:app="http://schemas.android.com/apk/res-
android:textStyle="bold">
auto"
xmlns:tools="http://schemas.android.com/tools" </TextView>
android:layout_width="match_parent"
android:layout_height="match_parent" </LinearLayout>
tools:context=".MainActivity"
android:orientation="vertical">
MainActivity.java
<EditText
android:id="@+id/et_phone"
android:layout_width="match_parent" package com.example.exp29;
android:layout_height="wrap_content"
android:hint="Enter Phone Number" import
android:padding="12dp"
androidx.appcompat.app.AppCompatActivity;
android:maxLength="10" import
androidx.annotation.NonNull;
android:inputType="phone" import
android:background="@color/teal_700"/>
androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
<EditText import
androidx.core.content.ContextCompat;
android:id="@+id/et_message"
android:layout_width="match_parent" import android.Manifest;
android:layout_height="wrap_content" import
android.content.pm.ActivityInfo;
android:hint="Enter Message" import
android.content.pm.PackageManager;
android:padding="12dp" import android.os.Bundle;
android:minLines="6" import
android.telephony.SmsManager;
android:inputType="textMultiLine" import android.view.View;
android:gravity="top" import android.widget.Button;
android:layout_marginTop="8dp" import android.widget.EditText;
/> import android.widget.Toast;
<Button
android:id="@+id/bt_send" import android.os.Bundle;
android:layout_width="wrap_content"
android:layout_height="wrap_content" public class MainActivity
extends
android:text="Send SMS" AppCompatActivity {
android:layout_marginTop="32dp"
android:layout_gravity="center"/> EditText etPhone, etMessage;
Button btSend;
<TextView @Override
android:layout_width="wrap_content" protected void
onCreate(Bundle
android:layout_height="wrap_content" savedInstanceState) {
super.onCreate( savedInstanceState );
super.onRequestPermissionsResult(requestCo
setContentView( R.layout.activity_main ); de, permissions, grantResults);
etPhone = findViewById(R.id.et_phone);
etMessage = findViewById(R.id.et_message); if (requestCode == 100
&&
btSend = findViewById(R.id.bt_send); grantResults.length > 0 &&
grantResults[0]
btSend.setOnClickListener( new ==
View.OnClickListener()
{ PackageManager.PERMISSION_GRANTED
@Override ){
public void onClick(View view) {
if sendMessage();
(ContextCompat.checkSelfPermission(MainActivity. }else{
this
, Manifest.permission.SEND_SMS)
Toast.makeText(getApplicationContext(),
== "Permission Denied!",
PackageManager.PERMISSION_GRANTED)
{ Toast.LENGTH_SHORT).show();
}
sendMessage(); }
}else{ }
ActivityCompat.requestPermissions(MainActivity.th AndroidManifest
Permission:
is, new String[]{Manifest.permission.SEND_SMS}, <uses-permission
100); android:name="android.permission.SEND_S
} MS"/>
<uses-permission
} android:name="android.permission.RECEIVE
} ); _SMS"/>
}
private void sendMessage() {
String sPhone =
etPhone.getText().toString().trim();
String sMessage =
etMessage.getText().toString().trim();
if (!sPhone.equals("") &&
!sMessage.equals("")){
SmsManager smsManager =
SmsManager.getDefault();
smsManager.sendTextMessage(sPhone, null,
sMessage, null, null);
Toast.makeText(getApplicationContext(),
"SMS sent successfully!",
Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(),"Enter
value first.", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onRequestPermissionsResult(int
requestCode, String[] permissions, int[]
grantResults) {