<?php
//Target : Creating form, and if the user forget to enter any field it alerts the user to fill it.
//This code deals with oop concepts, html fields, php validation, css tricks, reset forms,
?>
<!-- Form Design -->
<!-- Save this php file as formValidation.php -->
<h1> Form Validation </h1>
<form action = "formValidation.php" method = "post">
<p> Enter your Name : <input type = "text" name = "name" /> </p>
<p> Enter your Phone : <input type = "text" name = "phone" /> </p>
<p> Enter your Email : <input type = "text" name = "email" /> </p>
<!--
<p>Enter Comments : <textarea name = "comment" cols="24" rows="5"> </textarea> </p>
-->
<p style = "float:left; margin-right:21px;"> <input type = "submit" name = "checkit" value = "Validate Form" /> </p>
<p style = "float:left;"> <input type = "reset" name = "bleach" value = "Reset Form" /> </p>
<p style = "float:left;"> <input type = "hidden" name = "invisible" value = "Invisible button" /> </p>
</form> <!-- end of form declaration -->
<?php
//check for form submit
if($_SERVER['REQUEST_METHOD'] == 'POST') {
class formValidation {
var $saname;
var $saphone;
var $saemail;
//function or method declaration.
function sagetData(){
$saname = "".$_POST['name'];
//echo "Name you entered is : ".$saname;
// Validate the name:
if (!empty($_REQUEST['name'])) {
$name = $_REQUEST['name'];
echo "<br>";
echo "<br>";
echo "<br>";
echo "Name you entered is : ".$saname;
} else {
$name = NULL;
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
echo '<p class="error" style="color:red;">You forgot to enter your name!</p>';
}
}// end of function.
function sagetDataPhone() {
$saphone = "".$_REQUEST['phone']; //I used $_REQUEST here.
// Both $_POST[''] and $_REQUEST[''] works alike.
// Validate the phone:
if (!empty($_REQUEST['phone'])) {
$phone = $_REQUEST['phone'];
echo "<br>";
echo "Phone you entered is : ".$saphone;
} else {
$phone = NULL;
echo '<p class="error" style="color:red;">You forgot to enter your phone number!</p>';
}
} // end of function.
function sagetEmail() {
$saemail = "".$_REQUEST['email'];
//Validating email.
if (!empty($_REQUEST['email'])) {
$phone = $_REQUEST['email'];
echo "<br>";
echo "Email you entered is : " .$saemail;
} else {
$email = NULL;
echo '<p class="error" style="color:red;">You forgot to enter your Email!</p>';
}
}// end of function
}// End of class formValidation.
// Object creation
$x = new formValidation();
//phpinfo(); This code displays php information.
//calling method
$x->sagetData();
$x->sagetDataPhone();
$x->sagetEmail();
}//server if statement ends here.
?>
8 Responses
<a href=" http://www.credosystemz.com/training-in-chennai/best-php-training-in-chennai/">best php training institute in chennai velachery</a>
<a href=" https://www.wikitechy.com/online-videos/company-interview-questions-and-answers/snowflake-computing-interview-questions-and-answers-part1/">snowflake interview questions</a>
<a href=" https://www.wikitechy.com/interview-questions/aptitude/profit-and-loss/riya-sold-her-car-for-50000-less-than-wt-she-brought-it-for-and-lost/">riya sold her car</a>
<a href=" https://www.wikitechy.com/interview-questions/zensoft-interview-questions-and-answers/">zensoft interview questions</a>
<a href=" https://www.wikitechy.com/top10/most-popular-political-websites/">top 10 political websites</a>
<a href=" https://www.wikitechy.com/interview-questions/vb-net/what-is-the-difference-between-vb-and-vb-net/">difference between vb and vb.net</a>
<a href=" https://www.wikitechy.com/technology/pro-hack-tp-link-wifi-password/">tp link wifi hack</a>
<a href=" https://www.wikitechy.com/resume/power-bi-resume-samples/">power bi resume samples</a>
<a href=" https://www.wikitechy.com/resume/tag/2-year-experience-resume-format-for-java-developer/">java developer resume 2 years experience</a>
<a href=" https://www.wikitechy.com/technology/hack-wifi-passwords-ubuntu/">hack wifi ubuntu</a>
<a href=" https://www.wikitechy.com/interview-questions/kumaran-systems-interview-questions-and-answers/">kumaran systems interview process</a>
<a href=" https://www.wikitechy.com/online-videos/company-interview-questions-and-answers/snowflake-computing-interview-questions-and-answers-part1/">snowflake interview questions</a>
<a href=" https://www.wikitechy.com/interview-questions/aptitude/profit-and-loss/riya-sold-her-car-for-50000-less-than-wt-she-brought-it-for-and-lost/">riya sold her car</a>
<a href=" https://www.wikitechy.com/interview-questions/zensoft-interview-questions-and-answers/">zensoft interview questions</a>
<a href=" https://www.wikitechy.com/top10/most-popular-political-websites/">top 10 political websites</a>
<a href=" https://www.wikitechy.com/interview-questions/vb-net/what-is-the-difference-between-vb-and-vb-net/">difference between vb and vb.net</a>
<a href=" https://www.wikitechy.com/technology/pro-hack-tp-link-wifi-password/">tp link wifi hack</a>
<a href=" https://www.wikitechy.com/resume/power-bi-resume-samples/">power bi resume samples</a>
<a href=" https://www.wikitechy.com/resume/tag/2-year-experience-resume-format-for-java-developer/">java developer resume 2 years experience</a>
<a href=" https://www.wikitechy.com/technology/hack-wifi-passwords-ubuntu/">hack wifi ubuntu</a>
<a href=" https://www.wikitechy.com/interview-questions/kumaran-systems-interview-questions-and-answers/">kumaran systems interview process</a>
https://www.wikitechy.com/interview-questions/aptitude/profit-and-loss/riya-sold-her-car-for-50000-less-than-wt-she-brought-it-for-and-lost
https://www.wikitechy.com/interview-questions/zensoft-interview-questions-and-answers
https://www.wikitechy.com/top10/most-popular-political-websites
https://www.wikitechy.com/interview-questions/vb-net/what-is-the-difference-between-vb-and-vb-net
https://www.wikitechy.com/technology/pro-hack-tp-link-wifi-password/
https://www.wikitechy.com/resume/power-bi-resume-samples/
https://www.wikitechy.com/resume/tag/2-year-experience-resume-format-for-java-developer/
https://www.wikitechy.com/technology/hack-wifi-passwords-ubuntu/
https://www.wikitechy.com/interview-questions/kumaran-systems-interview-questions-and-answers
<a href=" https://www.wikitechy.com/resume/apache-solr-resume-sample/">apache solr resume sample</a>
<a href=" https://www.wikitechy.com/resume/apache-spark-sample-resume/">apache spark sample resume</a>
<a href=" https://www.wikitechy.com/resume/application-developer-resume-samples/">application developer resume samples</a>
<a href=" https://www.wikitechy.com/resume/application-support-engineer-resume-sample/">application support engineer resume sample</a>
<a href=" https://www.wikitechy.com/resume/asp-dot-net-mvc-developer-resume/">asp dotnet mvc developer resume</a>
<a href=" https://www.wikitechy.com/resume/asp-net-core-developer-resume/">asp net core developer resume</a>
<a href=" https://www.wikitechy.com/resume/asp-net-developer-resume-samples/">asp net developer resume samples</a>
<a href=" https://www.wikitechy.com/resume/assistant-accountant-cv-sample/">assistant accountant cv sample</a>
<a href=" https://www.wikitechy.com/resume/assistant-accountant-resume/">assistant accountant resume</a>
<a href=" https://www.wikitechy.com/resume/assistant-accountant-resume-sample/">assistant accountant resume sample</a>
<a href=" https://www.wikitechy.com/resume/apache-solr-resume-sample/">apache solr resume sample</a>
<a href=" https://www.wikitechy.com/resume/apache-spark-sample-resume/">apache spark sample resume</a>
<a href=" https://www.wikitechy.com/resume/application-developer-resume-samples/">application developer resume samples</a>
<a href=" https://www.wikitechy.com/resume/application-support-engineer-resume-sample/">application support engineer resume sample</a>
<a href=" https://www.wikitechy.com/resume/asp-dot-net-mvc-developer-resume/">asp dotnet mvc developer resume</a>
<a href=" https://www.wikitechy.com/resume/asp-net-core-developer-resume/">asp net core developer resume</a>
<a href=" https://www.wikitechy.com/resume/asp-net-developer-resume-samples/">asp net developer resume samples</a>
<a href=" https://www.wikitechy.com/resume/assistant-accountant-cv-sample/">assistant accountant cv sample</a>
<a href=" https://www.wikitechy.com/resume/assistant-accountant-resume/">assistant accountant resume</a>
<a href=" https://www.wikitechy.com/resume/assistant-accountant-resume-sample/">assistant accountant resume sample</a>
<a href=" https://www.wikitechy.com/resume/3d-modeler-resume-samples/">3d-modeler-resume-samples</a>
<a href=" https://www.wikitechy.com/resume/3d-modeler-resume-samples/">3d modeler resume samples</a>
<a href=" https://www.wikitechy.com/resume/accounting-assistant-resume-sample/">accounting-assistant-resume-sample</a>
<a href=" https://www.wikitechy.com/resume/accounting-clerk-resume-sample/">accounting-clerk-resume-sample</a>
<a href=" https://www.wikitechy.com/resume/accounting-manager-resume-samples/">accounting-manager-resume-samples</a>
<a href=" https://www.wikitechy.com/resume/account-manager-resume-examples/">account-manager-resume-examples</a>
<a href=" https://www.wikitechy.com/resume/accounts-payable-resume-sample/">accounts-payable-resume-sample</a>
<a href=" https://www.wikitechy.com/resume/admin-manager-resume-samples/">admin-manager-resume-samples</a>
<a href=" https://www.wikitechy.com/resume/advocate-resume-sample/">advocate-resume-sample</a>
<a href=" https://www.wikitechy.com/resume/advocate-resume-sample/">advocate-resume-sample</a>
nice blog
https://www.inplanttrainingchennai.com
https://www.kaashivinfotech.com/inplant-training-in-chennai
https://www.kaashivinfotech.com/inplant-training-for-cse-students
https://www.kaashivinfotech.com/internship-in-chennai
https://www.kaashivinfotech.com/inplant-training-for-ece-students
https://www.kaashiv.com/
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.