Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <?php include("include/header.php"); ?>
- <title></title>
- </head>
- <body>
- <?php include("include/nav.php"); ?>
- <form action="<?php echo htmlentities( $_SERVER[ 'PHP_SELF' ] ); ?>" method="POST">
- <input type="input" name="name" placeholder="Enter Name"/>
- <input type="input" name="gender" placeholder="Enter Gender"/>
- <input type="text" name="testimonial" placeholder="Enter testimonial"/>
- <input type="submit" name="f_submit" value="Submit Testimonial"/>
- </form>
- <?php
- $host = "localhost";
- $username = "root";
- $password = "";
- $db = "testimonial_db";
- $conn = mysqli_connect($host, $username, $password, $db);
- if(isset($POST_["f_submit"])){
- $tName = mysqli_real_escape_string($conn, $_POST["name"]);
- $tGender = mysqli_real_escape_string($conn, $_POST["gender"]);
- $tTestimonial = mysqli_real_escape_string($conn, $_POST["testimonial"]);
- $insert = "INSERT INTO testimonial_tb (gender, name, testimonial) VALUES ('".$tGender."', '".$tName."', '".$tTestimonial."')";
- $sendInsert = mysqli_query($conn, $insert);
- echo "<p>Testimonial Added</p>";
- }
- ?>
- <?php
- $host = "localhost";
- $username = "root";
- $password = "";
- $db = "testimonial_db";
- $conn = mysqli_connect($host, $username, $password, $db);
- if(!$conn){
- echo "<p>Connection failed</p>";
- }
- else{
- $query = "SELECT * FROM testimonial_tb";
- $queryResult = mysqli_query($conn, $query);
- $numRows = mysqli_num_rows($queryResult);
- if($numRows > 0){
- echo "<table>";
- echo "<tr> <th>Name</th> <th>Gender</th> <th>Testimonial</th> </tr>";
- while($row = mysqli_fetch_assoc($queryResult)){
- $gender = $row["gender"];
- $name = $row["name"];
- $testimonial = $row["testimonial"];
- echo "<tr>";
- echo "<td>" . $name . "</td>";
- echo "<td>" . $gender . "<td>";
- echo "<td>" . $testimonial . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- }
- }
- ?>
- <!-- <form action="<?php //echo htmlentities( $_SERVER[ 'PHP_SELF' ] ); ?>" method="POST">
- <input type="input" name="name" placeholder="Enter Name"/>
- <input type="input" name="gender" placeholder="Enter Gender"/>
- <input type="text" name="testimonial" placeholder="Enter testimonial"/>
- <input type="submit" name="f_submit" value="Submit Testimonial"/>
- </form> -->
- <?php
- /*$host = "localhost";
- $username = "root";
- $password = "";
- $db = "testimonial_db";
- $conn = mysqli_connect($host, $username, $password, $db);
- if(isset($POST_["f_submit"])){
- $tName = mysqli_real_escape_string($conn, $_POST["name"]);
- $tGender = mysqli_real_escape_string($conn, $_POST["gender"]);
- $tTestimonial = mysqli_real_escape_string($conn, $_POST["testimonial"]);
- $insert = "INSERT INTO testimonial_tb (gender, name, testimonial) VALUES ('".$tGender."', '".$tName."', '".$tTestimonial."')";
- $sendInsert = mysqli_query($conn, $insert);
- echo "<p>Testimonial Added</p>";
- }
- */
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement