Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.05 KB | None | 0 0
  1. [root@forgetful compsoc_man_ac_uk]# cat newmember-new.php
  2. <?php
  3.   $memberuser = $_REQUEST['username'];
  4.   $memberemail = $_REQUEST['email'];
  5.  
  6.   // no email posted, error out
  7.   if(!isset($_REQUEST['email']))
  8.     $state=3;
  9.   else {
  10.     // this is when the user has submitted the form
  11.     if(isset($_REQUEST['username'])){
  12.       $state=1;
  13.  
  14.       $to      = "coopted@compsoc.man.ac.uk";
  15.       $subject = "New sign up";
  16.       $body    = "We just had a new user sign up with the following details:\n\nEmail address: $memberemail\nDesired username: $memberuser\n\nRegards,\n\nQuiet\n";
  17.       if(!mail($to, $subject, $body))
  18.         $state=2;
  19.     }
  20.     else
  21.       $state=0;
  22.   }
  23.  
  24.   // There are four possible states for this page:
  25.   // (a) the user has been sent here by the union website with an email
  26.   //     variable in the address line. Need to ask them for a compsoc username.
  27.   // (b) the user has just submitted a username, so email this information to
  28.   //     admin@compsoc. TODO: automated LDAP?
  29.   // (c) php mail sending fails, get the user to email admin@compsoc.
  30.   // (d) user loads the page without email variable, either union sucks or user
  31.   //     is trying to break things.
  32.   // These correspond to states 0,1,2,3.
  33. ?>
  34.  
  35. <html>
  36.     <head>
  37.     <title>COMPSOC - Member</title>
  38.     <link rel="stylesheet" href="local.css" type="text/css" />
  39. </style>
  40. </head>
  41.     <body>
  42.  
  43. <?php include 'navigation.html';?>
  44.  
  45.     <div class=content>
  46.     <h1>The University of Manchester Computer Society</h1>
  47.     <h2>Thanks for joining</h2>
  48.  
  49. <?php
  50.   if($state==0) {
  51. ?>
  52.     <p>You are now a registered member of compsoc. To sign in to any of our services you will need a username. Please provide your desired username in the box below and click submit. At the moment we still need to enter your details manually, but we will aim to have your account set up in 24 hours.</p>
  53.  
  54.     <form method=post>
  55.       <input type=text name=username />
  56.       <input type=hidden value="<?php echo $memberemail; ?>" name=email />
  57.       <input type=submit />
  58.     </form>
  59.  
  60. <?php } else if($state==1) { ?>
  61.  
  62.     <p>Great! We'll try and have your account active in 24 hours. We'll email you when it's done. If you have any questions in the meantime, don't hesitate to mail us (<a href="mailto:admin@compsoc.man.ac.uk">admin@compsoc.man.ac.uk</a>).</p>
  63.  
  64. <?php } else if($state==2) { ?>
  65.  
  66.     <p>Sorry, but our automated system isn't working at the moment. Please email <a href="mailto:admin@compsoc.man.ac.uk">admin@compsoc.man.ac.uk</a> to request a username and we'll sort your account out as soon as possible.</p>
  67.  
  68. <?php } else if($state==3) { ?>
  69.  
  70.     <p>Hmm, we can't sign you up without an email. If you've reached this page through the union then they've broken something. Please email <a href="mailto:admin@compsoc.man.ac.uk">admin@compsoc.man.ac.uk</a> with your desired compsoc username and let us know this is broken so we can get it fixed.</p>
  71.  
  72. <?php } else { ?>
  73.  
  74.     <p>Some idiot has broken this form. Please email <a href="mailto:admin@compsoc.man.ac.uk">admin@compsoc.man.ac.uk</a>.</p>
  75.  
  76. <?php } ?>
  77.  
  78.     </div>
  79.     </body>
  80. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement