Page 315 - CITS - CSA - TP (Volume 1) - Hindi
P. 315
कंप्यूटर सॉफ्टवेयर एप्लीकेशन- CITS
टा 4: HTML और PHP कोड को कं बाइन कर
1 टे एिडटर ओपन कर
2 िन िल खत कोड िलख
<html >
<head>
<title Combine HTML and PHP code </title>
</head>
<body>
<?php
// Check if the form is submitted
if ($_SERVER[“REQUEST_METHOD”] == “POST”)
{
// Check if the name field is set and not empty
if (isset($_POST[“name”]) && !empty($_POST[“name”]))
{
$name = $_POST[“name”];
// Display a greeting message
echo “<h2>Hello, $name! Welcome!</h2>”;
}
else
{
// If name field is empty, display an error message
echo “<h2>Please enter your name!</h2>”;
}
}
?>
<form action=”<?php echo htmlspecialchars($_SERVER[“PHP_SELF”]); ?>”
method=”post”>
<input type=”text” name=”name” placeholder=”Enter your name”>
<button type=”submit”>Submit</button>
</form>
</body>
</html>
3 ो ाम को C:\Apache24\htdocs म .php ए ट शन वाले फ़ो र म सेव कर
4 Apache सिव स को िवंडोज़ सिव स से रन कर
5 ाउज़र ओपन कर और िन एड ेस टाइप कर
http://localhost/foldername/
6 रन करने के िलए php फ़ाइल पर क कर और आउटपुट वेरीफाई कर
299
CITS : IT & ITES - कं ूटर सॉ वेयर ए ीके शन - अ ास 56

