Advertisement
Guest User

Untitled

a guest
Oct 10th, 2017
653
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.78 KB | None | 0 0
  1. <?php if ($_SERVER['REQUEST_METHOD'] === 'GET') { ?>
  2. <!DOCTYPE HTML>
  3. <head>
  4. <title>Email Registration Form</title>
  5. <style>
  6.         li {list-style: none;}
  7. </style>
  8.         <link rel="stylesheet" href="form.css" type="text/css" />
  9. </head>
  10. <body>
  11. <h2>Enter details regarding your email creation</h2>
  12. <ul>
  13. function validateform() {
  14.         var e = document.forms["insert"]["email"].value;
  15.         if (e == "") {
  16.                 alert("Email field is empty");
  17.                 return false;
  18.         }
  19.         var n = document.forms["insert"]["Password"].value;
  20.         if (n == "") {
  21.                 alert("Password cannot be blank");
  22.                 return false;
  23.         }
  24.         var rn = document.forms["insert"]["realname"].value;
  25.         if (rn == "") {
  26.                 alert("Please enter your name");
  27.                 return false;
  28. }
  29. <form name="insert" action="register.php" onsubmit="return validateForm()" method="POST" >
  30.         <li>Email:</li><li><input type="text" name="email" placeholder="example@darkorderofchaos.com" /></li>
  31.         <li>Password:</li><li><input type="text" name="password" placeholder="Password" /></li>
  32.         <li>Name:</li><li><input type="text" name="realname" placeholder="John Doe" /></li>
  33.         <li><input type="submit" value="Create Email" /></li>
  34.         <input type="reset" value="Reset Form">
  35. </form>
  36. </ul>
  37. </body>
  38. </html>
  39. <?php } else
  40. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  41.    $db = pg_connect("host=localhost port=5432 dbname=mail user=mailreader password=**********") or die('pg_last_error()');
  42.    $result = pg_query_params($db, "insert into users(email, password, realname, maildir) values ($1,$2,$3,$1 || '/')",
  43.        array($_POST["email"], hash('SHA512',$_POST["password"]), $_POST["realname"]));
  44.    print($result);
  45. }
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement