<html>
<body>
<style>
.error {color: #FF0000;}
h1{
background-color:green;
color:white;
text-align:center;
}
.z{
border:ridge 20px brown;
font-size:40;
color:white;
text-align:center;
background-color:black;
}
.formstyle
{
width:800px;
height:350px;
border:15px ridge blue;
background-color:black;
color:white;
text-align:center;
}
input{
padding:5px;
margin:5px;
color:white;
width:300px;
background-color:grey;
border:3px solid white;
border-radius:20px;
}
.clear{
background-color:red;
width:315px;
color:white;
}
.g{
padding:5px;
margin:5px;
color:white;
width:190px;
background-color:grey;
border:3px solid white;
border-radius:10px;
text-align:center;
}
.error {color: #FF0000;}
</style>
<?php
$nameErr=$emailErr=$genderErr=$websiteErr=$adErr="";
$name=$email=$gender=$comment=$website=$ad="";
if(isset($_POST['submit'])){
$dbHost = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "fileupnew";
$conn = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName);
$n1=$_POST['name'];
$n2=$_POST['name1'];
$n3=$_POST['name2'];
$n4=$_POST['name3'];
$n5=$_POST['comment'];
$sql="INSERT into file6(name,name1,name2,name3,comment) VALUES('$n1','$n2','$n3','$n4','$n5')";
if(mysqli_query($conn,$sql))
{
echo '<script type="text/javascript">
window.onload = function () { alert("Your Message has sent"); }
</script>';
}
else
{
echo"error";
}}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
}else {
$name = test_input($_POST["name"]);
}
if (empty($_POST["email"])) {
$emailErr = "Email is required";
}else {
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
if (empty($_POST["name2"])) {
$website = "";
}else {
$website = test_input($_POST["name2"]);
}
if (empty($_POST["comment"])) {
$comment="";
}else {
$comment=test_input($_POST["comment"]);
}
if (empty($_POST["name2"])) {
$genderErr="Gender is required";
}else {
$gender=test_input($_POST["name2"]);
}
if (empty($_POST["ad"])) {
$adErr="Adhaar card no. is required";
}else {
$ad=test_input($_POST["ad"]);
}
}
function test_input($data) {
$data=trim($data);
$data=stripslashes($data);
$data=htmlspecialchars($data);
return $data;
}
?>
<center><table class="z"><tr><td>Fill your details and message to contact us</td></tr></table></center>
<br>
<br>
<div class="clear">
<div class="formstyle">
<form method = "post" action = "<?php
echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data">
<br>
<center><table class="q">
<tr>
<td><font color="white" >Name:</font></td>
<td><input type = "text" name="name" >
<span class = "error">* <?php echo $nameErr;?></span>
</td>
<td><font color="white">E-mail: </td>
<td><input type = "text" name="name1">
<span class = "error">* <?php echo $emailErr;?></span>
</td>
</tr>
<tr>
<td><font color="white">phone</td>
<td> <input type = "text" name = "name2" minlength="10" maxlength="10">
<span class = "error"><?php echo $websiteErr;?></span>
</td>
<td><font color="white">Comment</td>
<td> <textarea name = "comment" rows = "4" cols = "34"></textarea></td>
</tr>
<tr>
<td><font color="white">Company Name</td>
<td> <input type = "text" name = "name3" minlength="10" maxlength="10">
<span class = "error"><?php echo $websiteErr;?></span>
</td>
</tr>
<tr></tr>
<tr>
<td></td>
<td>
<center><input type = "submit" name = "submit" value = "Submit" class="g"></center>
</td>
</tr>
</table>
</center>
</form>
</div>
</div>
<?php
echo "<h1>Your given values are as:</h1>";
echo " Your Name is $name</th></table>";
echo "<br>";
echo "Your Email is $email</th></table>";
echo "<br>";
echo " Your phone is $website</th></table>";
echo "Company name is is$ad</th></table>";
echo "<br>";
echo "subject is $comment</th></table>";
echo "<br>";
echo "Message is$gender</th></table>"
?>
</body>
</html>
<html>
<body>
<style>
p{
font-size:150%;
}
th:hover{
background-color: #B0B0B0;
cursor:pointer;
}</style>
<p>
<center><form action="" method="post" enctype="multipart/form-data">
<p>Your name<input type="text" name="n" required> <span style="color:red;">*</span> <br>
Mobile number<input type="text" name="mn" required><span style="color:red;">*</span></p></center>
<p> 2+2<br></p>
<table bgcolor=" #E8E8E8"><tr><th><p>4<input type="radio" name="techno[]" value="1"> </th></tr></p>
<tr><th><p>1<input type="radio" name="techno[]" value="2"> </th></tr></p>
<tr><th><p>5<input type="radio" name="techno[]" value="3"> </th></tr></p></table>
<p>Which is most populated country</p>
<table bgcolor=" #E8E8E8"><tr><th><p>China<input type="radio" name="techno1[]" value="1"> </th></tr></p>
<tr><th><p>India<input type="radio" name="techno1[]" value="2"> </th></tr></p>
<tr><th><p>America<input type="radio" name="techno1[]" value="3"> </th></tr></p></table>
<p>Who is prime minister of india</p><table bgcolor=" #E8E8E8"><tr><th><p>Mr. Narindra Modi<input type="radio" name="techno2[]" value="1"> </th></tr></p>
<tr><th><p>Mr. Narendara Modi<input type="radio" name="techno2[]" value="2"> </th></tr></p>
<tr><th><p>Mr. Narendra Modi<input type="radio" name="techno2[]" value="3"> </th></tr></p></table>
<p>Who is president of india</p><table bgcolor=" #E8E8E8"><tr><th><p>Draupadi Murmur <input type="radio" name="techno3[]" value="1"> </th></tr></p>
<tr><th><p>Droupadi Murmu<input type="radio" name="techno3[]" value="2"> </th></tr></p>
<tr><th><p>Ramanth Kovind<input type="radio" name="techno3[]" value="3"> </th></tr></p></table>
<p>favourite language</p><table bgcolor=" #E8E8E8"><tr><th><p>PHP<input type="radio" name="techno4[]" value="1"> </th></tr></p>
<tr><th><p>English<input type="radio" name="techno4[]" value="2"> </th></tr></p>
<tr><th><p>HTML<input type="radio" name="techno4[]" value="3"> </th></tr></p></table>
<input type="submit" name="sub">
</form></p>
<?php
if(isset($_POST['sub']))
{
$n=$_POST['n'];
$mn=$_POST['mn'];
$checkbox1=$_POST['techno'];
$checkbox2=$_POST['techno1'];
$checkbox3=$_POST['techno2'];
$checkbox4=$_POST['techno3'];
$checkbox5=$_POST['techno4'];
$chk="";
$chkk="";
$chkkk="";
$chkkkk="";
$chkkkkk="";
foreach($checkbox1 as $chk1)
{
$chk .= $chk1.",";
}
foreach($checkbox2 as $chk2)
{
$chkk .= $chk2.",";
}
foreach($checkbox3 as $chk3)
{
$chkkk .= $chk3.",";
}
foreach($checkbox4 as $chk4)
{
$chkkkk .= $chk4.",";
}
foreach($checkbox5 as $chk5)
{
$chkkkkk .= $chk5.",";
}
$a=0;
if($chk1=="1"){
$a=$a+1;
}
else {
$a=$a+0;
}
if($chk2=="2"){
$a=$a+1;
}
else{
$a=$a+0;
}
if($chk3=="3"){
$a=$a+1;
}
else{
$a=$a+0;
}
if($chk4=="2"){
$a=$a+1;
}
else{
$a=$a+0;
}
if($chk5=="1"){
$a=$a+1;
}
else{
$a=$a+0;
}
$dbHost = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbName = "fileupnew";
$conn = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName);
$sql="INSERT into quiz(name,mobilenumber,marks) VALUES('$n','$mn','$a')";
if(mysqli_query($conn,$sql))
{
echo "<script>alert('Thanks for solving quiz')</script>";
}
else
{
echo"error";
}
}
?>