<?php
include "connection.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Student Registration Form | LMS </title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/custom.min.css" rel="stylesheet">

</head>

<br>

<div class="col-lg-12 text-center ">
<h1 style="font-family:Lucida Console">Library Management System</h1>
</div>

<body class="login" style="margin-top: -20px;">

<div class="login_wrapper">

        <section class="login_content" style="margin-top: -40px;">
            <form name="form1" action="" method="post">
                <h2>User Registration Form</h2><br>

                <div>
                    <input type="text" class="form-control" placeholder="FirstName" name="Firstname" required=""/>
                </div>
                <div>
                    <input type="text" class="form-control" placeholder="LastName" name="Lastname" required=""/>
                </div>

                <div>
                    <input type="text" class="form-control" placeholder="Username" name="Username" required=""/>
                </div>
                <div>
                    <input type="password" class="form-control" placeholder="Password" name="password" required=""/>
                </div>
                <div>
                    <input type="text" class="form-control" placeholder="email" name="email" required=""/>
                </div>
                <div>
                    <input type="text" class="form-control" placeholder="contact" name="contact" required=""/>
                </div>
                <div>
                    <input type="text" class="form-control" placeholder="SEM" name="sem" required=""/>
                </div>
                <div>
                    <input type="text" class="form-control" placeholder="Enrollment No" name="enrollment" required=""/>
                </div>
                <div class="col-lg-12  col-lg-push-3">
                    <input class="btn btn-default submit " type="submit" name="submit1" value="Register">
                </div>

            </form>
        </section>
    <?php

    if(isset($_POST["submit1"])) {

        mysqli_query($link, "insert into student_registration values(NULL ,'$_POST[Firstname]','$_POST[Lastname]','$_POST[Username]','$_POST[password]','$_POST[email]','$_POST[contact]','$_POST[sem]','$_POST[enrollment]')",$link);


    ?>
        <div class="alert alert-success col-lg-12 col-lg-push-0">
            Registration successfully, You will get email when your account is approved
        </div>
    <?php

    }
    mysqli_close($link);
    ?>



</div>

</body>
</html>

    The data i insert in form is not getting updated in the database

      So...what exactly is the problem? Are you getting some error message? If so, can you copy/paste it here (removing any sensitive data like database user names and such)? (Your "connection error" in the title would tend to make me think it's in the "connection.php" include file.)

        I would add to NogDog's post that you should ALWAYS check the result of a query. Your code just runs mysqli_query and doesn't bother to check its result. It returns FALSE on failure, TRUE if the insert succeeds:

        Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queries mysqli_query() will return TRUE.

        If it returns false, you should examine the output of mysqli_error($link)

        I would also strongly suggest that you put your PHP code that performs your db operations at the top of your code and make sure everything went according to plan before outputting HTML.

          Write a Reply...