Advertisement
Guest User

Untitled

a guest
May 4th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use CGI qw(:standard);
  4. use DBI;
  5. use Mysql;
  6.  
  7. my $fname = param('fname') || '<i>(No input)</i>';
  8. my $lname = param('lname') || '<i>(No input)</i>';
  9. my $dob = param('dob') || '<i>(No input)</i>';
  10. my $uname = param('uname') || '<i>(No input)</i>';
  11. my $pword = param('pword') || '<i>(No input)</i>';
  12. my $middle = param('middle') || '<i>(No input)</i>';
  13. my $maiden = param('middle') || '<i>(No input)</i>';
  14. my $address = param('address') || '<i>(No input)</i>';
  15. my $address2 = param('address2') || '<i>(No input)</i>';
  16. my $city = param('city') || '<i>(No input)</i>';
  17. my $state = param('state') || '<i>(No input)</i>';
  18. my $zip = param('zip') || '<i>(No input)</i>';
  19. my $email = param('email') || '<i>(No input)</i>';
  20. my $phone = param('phone') || '<i>(No input)</i>';
  21.  
  22. # MYSQL CONFIG VARIABLES
  23. my $host = "localhost";
  24. my $database = "alumni";
  25. my $tablename = "reg";
  26. my $user = "username";
  27. my $pw = "password";
  28.  
  29. # PERL MYSQL CONNECT()
  30. my $connect = Mysql->connect($host, $database, $user, $pw);
  31.  
  32. # SELECT DB
  33. $connect->selectdb($database);
  34.  
  35. # DEFINE A MySQL QUERY
  36. my $myquery = "SELECT * FROM $tablename WHERE uname LIKE \'$uname\'";
  37. my $addquery = "INSERT INTO $tablename VALUES(\'$fname\',\'$middle\',\'$lname\',\'$maiden\',$dob,\'$email\',\'$uname\',\'$pword\')";
  38.  
  39. &checkUserID;
  40.  
  41. sub checkUserID{
  42.  
  43. # EXECUTE THE QUERY FUNCTION
  44. my $execute = $connect->query($myquery);
  45.  
  46. while (@results = $execute->fetchrow()) {
  47. if(@results > 0){
  48. &noconfirm;
  49. }
  50. else{
  51. my $execute = $connect->query($addquery);
  52. &confirm;
  53. }
  54. }
  55. }
  56.  
  57. sub noconfirm{
  58.  
  59. print <<NOCONFIRM;
  60. Content-type: text/html
  61.  
  62.  
  63. <html>
  64. <head>
  65. <title>Username Taken</title>
  66. </head>
  67. <body>
  68. <center>
  69. <h1>Username Taken</h1>
  70. Go back and use a different username $results[6]
  71. </center>
  72. </body>
  73. </html>
  74. NOCONFIRM
  75. }
  76.  
  77. sub confirm{
  78.  
  79.  
  80. print <<CONFIRM;
  81. Content-type: text/html
  82.  
  83.  
  84.  
  85. <html>
  86. <head>
  87. <title>Reg Check</title>
  88. </head>
  89. <body>
  90. First Name: $fname<br>
  91. Middle Name: $middle<br>
  92. Last Name: $lname<br>
  93. Maiden Name: $maiden<br>
  94. D.O.B.: $dob<br>
  95. Address:&nbsp &nbsp $address<br>
  96. &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp $address2<br>
  97. &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp $city, $state $zip<br>
  98. Email: $email<br>
  99. Phone: $phone<br>
  100. username: $uname - <br>
  101. password: $pword<br>
  102. Results:
  103. </body>
  104. </html>
  105. CONFIRM
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement