Advertisement
Guest User

Untitled

a guest
Jan 13th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. $username=$_POST['username'];
  3. $password=$_POST['password'];
  4. $gender=$_POST['gender'];
  5. $reference=$_POST['reference'];
  6. $mailing_list=$_POST['mailinglist'];
  7.  
  8. if($mailing_list=='yes')
  9. $mailing_list=1;
  10. elseif($mailing_list==null)
  11. $mailing_list=0;
  12.  
  13.  
  14. $db=mysqli_connect('localhost','root','','userregistration');
  15. $sql="INSERT INTO user_information
  16. (username,password,gender,reference,mailing_list)
  17. VALUES ('$username', '$password', '$gender', '$reference','$mailing_list');";
  18.  
  19. mysqli_query($db,$sql);
  20. echo 'USER SUCCESSFULLY ADDED';
  21. header('Location:display.php');
  22.  
  23. ?>
  24.  
  25.  
  26.  
  27. <html>
  28. <head>
  29. <title>USER RECORDS</title>
  30. <link rel="stylesheet" type="text/css" href="exer2Style.css"></head>
  31. <body>
  32. <table border=1>
  33. <?php
  34. $ths=array('USERNAME','PASSWORD','GENDER','REFERENCE','MAILING LIST');
  35. foreach($ths as $data){
  36. ?>
  37. <th><?php echo $data;
  38. }?></th>
  39. <?php
  40. $db=mysqli_connect('localhost','root','','userregistration');
  41. $sql="SELECT * FROM user_information";
  42. $result=mysqli_query($db,$sql);
  43. while($row=mysqli_fetch_array($result)){;
  44. echo "<tr><td>".$row['username']."</td>".
  45. "<td>".$row['password']."</td>".
  46. "<td>".$row['gender']."</td>".
  47. "<td>".$row['reference']."</td>".
  48. "<td>".$row['mailing_list']."</td></tr>";
  49. }
  50. ?>
  51. </table>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement