Advertisement
Guest User

Untitled

a guest
May 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.08 KB | None | 0 0
  1. <br/>
  2. <form action="action_test.php" method="post">
  3.     First Name  <input type="textbox" name="fname"><br/>
  4.     Last Name   <input type="textbox" name="lname"><br/>
  5.     age         <input type="textbox" name=  "age"><br/>
  6.     Username    <input type="textbox" name=  "user"><br/>
  7.     Password    <input type="password" name=  "pass"><br/>
  8.     <input type="submit" value="submit">
  9. </form>
  10. <?php
  11. $user=$_POST['user'];
  12. $pass=$_POST['pass'];
  13. $fname=$_POST['fname'];
  14. $lname=$_POST['lname'];
  15. $age=$_POST['age'];
  16. $con = mysql_connect("localhost",$user,$pass);
  17. if (!$con){
  18.     die("Wrong Password");
  19.  }
  20.  
  21. mysql_select_db("my_db", $con);
  22. mysql_query("INSERT INTO Persons (FirstName, LastName, Age)
  23.     VALUES ($fname, $lname, $age)
  24.     "
  25. );
  26.  
  27. $result = mysql_query("SELECT * FROM Persons");
  28.  
  29. echo "<table border='1'>
  30. <tr>
  31. <th>Firstname</th>
  32. <th>Lastname</th>
  33. <th>Age</th>
  34. </tr>";
  35.  
  36. while($row = mysql_fetch_array($result))
  37.   {
  38.   echo "<tr>";
  39.   echo "<td>" . $row['FirstName'] . "</td>";
  40.   echo "<td>" . $row['LastName'] . "</td>";
  41.   echo "<td>" . $row['Age'] . "</td>";
  42.   echo "</tr>";
  43.   }
  44. echo "</table>";
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement