Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $databaseHost = 'localhost';
- $databaseName = 'test';
- $databaseUsername = 'root';
- $databasePassword = '';
- $mysqli = mysqli_connect($databaseHost, $databaseUsername, $databasePassword, $databaseName);
- ?>
- <?php
- include_once("config.php");
- $result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC");
- ?>
- <html>
- <head>
- <title>Registration</title>
- </head>
- <body>
- <table width='50%' border=0>
- <tr bgcolor='yellow'>
- <td><a href="index.php">Dashboard</a></td>
- <td><a href="reg1.php">Registration Stage-1</a></td>
- <td><a href="reg2.php">Registration Stage-2</a></td>
- <td><a href="reg3.php">Registration Stage-3</a></td>
- <td><a href="view.php">View Report</a></td>
- </tr>
- <table width='50%' border=0>
- <tr bgcolor='#CCCCCC'>
- <td>ID#</td>
- <td>Name</td>
- <td>Age</td>
- <td>Email</td>
- <td>Mobile</td>
- <td>Change</td>
- </br></br>
- </tr>
- <?php
- while($res = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>".$res['id']."</td>";
- echo "<td>".$res['name']."</td>";
- echo "<td>".$res['age']."</td>";
- echo "<td>".$res['email']."</td>";
- echo "<td>".$res['mobile']."</td>";
- echo "<td><a href="edit.php?id=$res[id]">Change</a></td>";
- }
- ?>
- </table>
- </body>
- </html>
- <?php
- include_once("config.php");
- if(isset($_POST['update']))
- {
- $id = mysqli_real_escape_string($mysqli, $_POST['id']);
- $name = mysqli_real_escape_string($mysqli, $_POST['name']);
- $age = mysqli_real_escape_string($mysqli, $_POST['age']);
- $email = mysqli_real_escape_string($mysqli, $_POST['email']);
- $mobile = mysqli_real_escape_string($mysqli, $_POST['mobile']);
- if(empty($name) || empty($age) || empty($email) || empty($mobile)) {
- if(empty($name)) {
- echo "<font color='red'>Name field is empty.</font><br/>";
- }
- if(empty($age)) {
- echo "<font color='red'>Age field is empty.</font><br/>";
- }
- if(empty($email)) {
- echo "<font color='red'>Email field is empty.</font><br/>";
- }
- if(empty($mobile)) {
- echo "<font color='red'>Mobile field is empty.</font><br/>";
- }
- } else {
- $result = mysqli_query($mysqli, "UPDATE users SET name='$name',age='$age',email='$email',mobile='$mobile' WHERE id=$id");
- header("Location: index.php");
- }
- }
- ?>
- <?php
- $id = $_GET['id'];
- $result = mysqli_query($mysqli, "SELECT * FROM users WHERE id=$id");
- while($res = mysqli_fetch_array($result))
- {
- $name = $res['name'];
- $age = $res['age'];
- $email = $res['email'];
- $mobile = $res['mobile'];
- }
- ?>
- <html>
- <head>
- <title>Change Registration Data</title>
- </head>
- <body>
- <table width='50%' border=0>
- <tr bgcolor='yellow'>
- <td><a href="index.php">Dashboard</a></td>
- <td><a href="reg1.php">Registration Stage-1</a></td>
- <td><a href="reg2.php">Registration Stage-2</a></td>
- <td><a href="reg3.php">Registration Stage-3</a></td>
- <td><a href="view.php">View Report</a></td>
- </tr>
- <form name="form1" method="post" action="edit.php">
- <table border="0">
- <tr>
- <td>Name</td>
- <td><input type="text" name="name" value="<?php echo $name;?>"></td>
- </tr>
- <tr>
- <td>Age</td>
- <td><input type="text" name="age" value="<?php echo $age;?>"></td>
- </tr>
- <tr>
- <td>Email</td>
- <td><input type="text" name="email" value="<?php echo $email;?>"></td>
- </tr>
- <tr>
- <td>Mobile</td>
- <td><input type="text" name="mobile" value="<?php echo $mobile;?>"></td>
- </tr>
- <tr>
- <td><input type="hidden" name="id" value=<?php echo $_GET['id'];?>></td>
- <td><input type="submit" name="update" value="Update"></td>
- </tr>
- </table>
- </form>
- <table width='50%' border=0>
- <tr bgcolor='#CCCCCC'>
- <td>Name</td>
- <td>Age</td>
- <td>Email</td>
- <td>Mobile</td>
- </tr>
- <?php
- $result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC"); // using mysqli_query instead
- while($res = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>".$res['name']."</td>";
- echo "<td>".$res['age']."</td>";
- echo "<td>".$res['email']."</td>";
- echo "<td>".$res['mobile']."</td>";
- }
- ?>
- </table>
- </body>
- </html>
- <html>
- <head>
- <title>Registration Stage-1</title>
- </head>
- <body>
- <?php
- include_once("config.php");
- if(isset($_POST['Submit'])) {
- $name = mysqli_real_escape_string($mysqli, $_POST['name']);
- $age = mysqli_real_escape_string($mysqli, $_POST['age']);
- $email = mysqli_real_escape_string($mysqli, $_POST['email']);
- $mobile = mysqli_real_escape_string($mysqli, $_POST['mobile']);
- if(empty($name) || empty($age) || empty($email)) {
- if(empty($name)) {
- echo "<font color='red'>Name field is empty.</font><br/>";
- }
- if(empty($age)) {
- echo "<font color='red'>Age field is empty.</font><br/>";
- }
- if(empty($email)) {
- echo "<font color='red'>Email field is empty.</font><br/>";
- }
- if(empty($mobile)) {
- echo "<font color='red'>Mobile field is empty.</font><br/>";
- }
- echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
- } else {
- $result = mysqli_query($mysqli, "INSERT INTO users(name,age,email,mobile) VALUES('$name','$age','$email','$mobile')");
- echo "<font color='green'>Data added successfully.";
- echo "<br/><a href='index.php'>View Result</a>";
- }
- }
- ?>
- <html>
- <head>
- <title>Registration Stage-1</title>
- </head>
- <body>
- <table width='50%' border=0>
- <tr bgcolor='yellow'>
- <td><a href="index.php">Dashboard</a></td>
- <td><a href="reg1.php">Registration Stage-1</a></td>
- <td><a href="reg2.php">Registration Stage-2</a></td>
- <td><a href="reg3.php">Registration Stage-3</a></td>
- <td><a href="view.php">View Report</a></td>
- </tr>
- <form action="reg1.php" method="post" name="form1">
- <table width="25%" border="0">
- <tr>
- <td>Name</td>
- <td><input type="text" name="name"></td>
- </tr>
- <tr>
- <td>Age</td>
- <td><input type="text" name="age"></td>
- </tr>
- <tr>
- <td>Email</td>
- <td><input type="text" name="email"></td>
- </tr>
- <tr>
- <td>Mobile</td>
- <td><input type="text" name="mobile"></td>
- </tr>
- <tr>
- <td></td>
- <td><input type="submit" name="Submit" value="Add"></td>
- </tr>
- </table>
- </br></br>
- </form>
- <table width='50%' border=0>
- <tr bgcolor='#CCCCCC'>
- <td>Name</td>
- <td>Age</td>
- <td>Email</td>
- <td>Mobile</td>
- </tr>
- <?php
- $result = mysqli_query($mysqli, "SELECT * FROM users ORDER BY id DESC"); // using mysqli_query instead
- while($res = mysqli_fetch_array($result)) {
- echo "<tr>";
- echo "<td>".$res['name']."</td>";
- echo "<td>".$res['age']."</td>";
- echo "<td>".$res['email']."</td>";
- echo "<td>".$res['mobile']."</td>";
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement