By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 883 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

How can I manually create an admin?

100+
P: 134
hello,

I want to make my own website, with a login system. So I've downloaded a ready one. But now I had to install it by running the setup.php, which should provide me a admin account. The only problem is that when I full in the form to install it. It can't create an admin account because of a failure. As a solution it says that I have to create an admin account myself manually, but I have to make sure that the password is md5 coded. And now comes the question, how can I do that?
If you have another login system for me which is very safe, and easy to use and easy to install on my website, please tell me and give me the download link.
Thanks in advance.

Here is the code from the setup.php file
Expand|Select|Wrap|Line Numbers
  1. <?
  2. include("config.php");
  3. include("htmltop.php");
  4.  
  5. if(isset($_POST['submit'])) {
  6.  if($_POST['pass'] == $_POST['pass2']) {
  7.   $sql = "DROP TABLE IF EXISTS `gebruikers`;";
  8.   $query = mysql_query($sql);
  9.   if($query == TRUE) {
  10.    echo "Indien er oude tabellen waren met de naam gebruikers, zijn deze verwijderd...<br />\n";
  11.    $sql = "CREATE TABLE `gebruikers` (`id` int(11) NOT NULL auto_increment,`naam` varchar(50) NOT NULL default '',`wachtwoord` varchar(50) NOT NULL default '',`status` char(1) NOT NULL default '0',`email` varchar(100) NOT NULL default '',`actief` char(1) NOT NULL default '0',`actcode` varchar(15) NOT NULL default '',`lastactive` datetime NOT NULL default '0000-00-00 00:00:00',PRIMARY KEY  (`id`)) TYPE=MyISAM AUTO_INCREMENT=1";
  12.    $query = mysql_query($sql);
  13.    if($sql == TRUE) {
  14.     echo "De tabel 'gebruikers' is succesvol aangemaakt...<br />\nAdministrator account met naam '".$_POST['user']."' zal nu worden aangemaakt...<br />\n";
  15.     $md5pass = md5($_POST['pass']);
  16.     $sql = "INSERT INTO gebruikers (naam,wachtwoord,status,email,actief) VALUES ('".$_POST['user']."','".$md5pass."',1,'".$_POST['email']."',1)";
  17.     $query = mysql_query($sql);
  18.     if($query == TRUE) {
  19.      echo "De Administrator is succesvol aangemaakt, de gebruikersnaam van de Administrator is: '".$_POST['user']."'...<br />\n";
  20.      $del = unlink("setup.php");
  21.      if($del == TRUE) {
  22.       echo "Het bestand 'setup.php' is succesvol verwijderd...<br />\n";
  23.       echo "<p />\n";
  24.       echo "Installatie compleet. Je kunt nu gebruik maken van het script. Bedankt voor het gebruik maken van dit script!";
  25.      }else{
  26.       echo "Er is een fout opgetreden bij het verwijderen van het bestand 'setup.php'. Verwijder dit bestand handmatig!<br />\n";
  27.      }
  28.     }else{
  29.      echo "Er is een fout opgetreden bij het aanmaken van de Administrator. je kunt het handmatig proberen met bv. PhpMyAdmin (wachtword moet MD5 coded zijn!)...<br />\n";
  30.     }
  31.    }else{
  32.     echo "Er is een fout opgetreden bij het maken van de tabel. Weet je zeker dat je MySQL-instellingen in config.php kloppen?<br />\n";
  33.    }
  34.   }else{
  35.    echo "Er is een fout opgetreden bij het verwijderen van eventuele oude gebruikers-tabellen. Controleer de MySQL-instellingen in config.php<br />\n";
  36.   }
  37.  }else{
  38.   echo "De twee wachtwoorden komen niet overeen.<br />\n<a href=\"javascript:history.back()\">&laquo; Ga terug</a>";
  39.  }
  40. }else{
  41.  ?>
  42.  <form method="post" action="setup.php">
  43.   <table>
  44.    <tr>
  45.     <td>Administrator naam:</td><td><input type="text" name="user" maxlength="50" /> <small>(de inlognaam voor de administraotr)</small></td>
  46.    </tr>
  47.    <tr>
  48.     <td>Wachtwoord:</td><td><input type="password" name="pass" /></td>
  49.    </tr>
  50.    <tr>
  51.     <td>Herhaal:</td><td><input type="password" name="pass2" /></td>
  52.    </tr>
  53.    <tr> 
  54.     <td>E-mail:</td><td><input type="text" name="email" maxlength="100" /></td>
  55.    </tr>
  56.    <tr>
  57.     <td></td><td><input type="submit" name="submit" value="Installeren" /></td>
  58.    </tr>
  59.   </table>
  60.  </form>
  61.  <?
  62. }
  63. include("htmlbottom.php");
  64. ?> 
  65.  
Jun 16 '11 #1
Share this Question
Share on Google+
1 Reply


Atli
Expert 5K+
P: 5,058
The SQL query on line 16 is what creates you account. To do it manually, just copy it, fill it out by hand, and execute it on your MySQL server.

MySQL has it's own MD5 function, so you can just do MD5('yourpass') where the password should go.

Just to point this out. MD5 is a very very weak algorithm. It really shouldn't be used for password security these days. The SHA-2 family, or Whirlpool, is much more secure. - Not to mention that you should at least be salting the hash, and even re-hashing it a few thousand times.


If you are looking for a decent quality CMS system that you can just plop onto your server and run without having to mess with the code, consider trying something like Drupal or Joomla. WordPress is also good, but requires a bit more coding to be effective.
Jun 17 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.