5 August 2019

Index Page For Registration Form

<!DOCTYPE html>
<html>
<head>
<title>Index Page</title>
<style>.field{ padding-top:15px; }</style>
</head>
<body>
<?php
if(isset($_POST["submit"])){
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "indrajeet";

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
}
$pqr=implode(",",$_POST['education']);
if($_FILES["file"]["name"])
{
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
  $filename=$_FILES["file"]["name"];
}
$sql = "insert into register set name='".$_POST['name']."',email='".$_POST['email']."',phone='".$_POST['phone']."'
,gender='".$_POST['gender']."',education='".$pqr."',upload='".$filename."',address='".$_POST['address']."'";

if (mysqli_query($conn, $sql)) {
   echo "New record created successfully";
} else {
   echo "Error: " . $sql . "" . mysqli_error($conn);
}
$conn->close();
}
?>
<form action="register.php" method="post" enctype="multipart/form-data">
<table style="border:1px solid #000; padding:40px; margin-top:30px;" width="480px" align="center">
<tr>
    <td align="center" class="field">Name:</td>
    <td class="field"><input type="text" name="name"></td>
</tr>
<tr>
    <td align="center" class="field">Email:</td>
    <td class="field" ><input type="text" name="email"></td>
</tr>
<tr>
    <td align="center" class="field">Phone:</td>
    <td class="field" ><input type="text" name="phone"></td>
</tr>
<tr>
    <td align="center" class="field">Gender:</td>
    <td class="field">
    <input type="radio" name="gender" value="1">Male
        <input type="radio" name="gender" value="2">feMale
</td>
</tr>
<tr>
    <td align="center" class="field">Education:</td>
    <td class="field">
<input type="checkbox" name="education[]" value="10th">10th
<input type="checkbox" name="education[]" value="12th">12th
<input type="checkbox" name="education[]" value="BSC">BSC
<input type="checkbox" name="education[]" value="msc">MSC
    </td>
</tr>
<tr>
    <td align="center" class="field">Upload :</td>
    <td class="field"><input type="file" name="file" id="file"/></td>
</tr>
<tr>
    <td align="center" class="field">Address:</td>
    <td class="field"><textarea name="address"> </textarea></td>
</tr>
<tr>
    <td class="field" align="center" colspan="2">
   <input type="submit" name='submit' value="Submit">
</td>
</tr>
</table>
</body>
</html>