Joomla1.5 manually add admin user

Hi ,…
When we work with joomla site… we should have the back end access.. i.e.  super-admin access.

But we don’t have that…. may be client may forgot to give you or given wrong details…

So need to create new one.. or just change the password in database of joomla site.

We  faced the situation where client has given the correct FTP details… but wrong admin details.. & clinet want some urgent changes on the site.. .. so we have just created simple script in PHP .. which create new User for your joomla using PHP & mysql….

<?php
	error_reporting(-1);
	ini_set("display_error",1);	
?>

<html>
<head>
<title>Joomla1.5 User Creater</title>
<style type="text/css">
#user{	
	margin:0 auto;
	width:500px;	
}
#user td{
	height:30px;
}
h1,h2{
	text-align:center;
}
</style>
</head>
<body>
<form name="joomadduser" method="POST">
	<table cellspacing="0" cellpadding="0"  id="user">
	
<?php
	
if(isset($_POST['submit']))
{			
	$host=trim($_POST['hostname']);
	$dbuser=trim($_POST['dbusername']);
	$dbpassword=trim($_POST['dbpassword']);
	$db=trim($_POST['dbname']);
	$tbprefix=trim($_POST['tbprefix']);	
	
	/****Custom Username & Password*****/
	$username=trim($_POST['username']);
	$password=md5(trim($_POST['password']));	
	$email=trim($_POST['email']);
	
	/********User Creation time********/
	$registerDate=@date('Y-m-d H:i:s');
		
	$con=mysql_connect($host,$dbuser,$dbpassword) or die(mysql_error().'Sql error , Connection failed');
	if($con)
	{
		/***insert admin user in table ***/
		mysql_select_db($db) or die(mysql_error()."Not able to connect to Database");
		$sql="insert INTO ".$tbprefix."users (name,username,email,password,usertype,block,sendEmail,gid,registerDate,lastvisitDate,activation,params) "."values ('$username','$username','$email','$password','Super Administrator',0,1,25,'$registerDate','$registerDate','','')";	
		
		mysql_query($sql) or die(mysql_error()."Not able to create admin");
		$adminid=mysql_insert_id($con);				
		
		/***insert admin user id  into usergroup section table ***/		
		$query="insert into ".$tbprefix."core_acl_aro (section_value,value,order_value,name,hidden) VALUES ('users','$adminid',0,'$username',0)";
		mysql_query($query) or die(mysql_error()."Not able to add in section");
		$sectionid=mysql_insert_id($con);
		
		/***insert admin user id  into usergroup ***/
		$query="insert into ".$tbprefix."core_acl_groups_aro_map VALUES (25,'',$sectionid)";
		if(mysql_query($query)  or die(mysql_error()."Not able to add in group"))
		{
			echo "<tr><td align='center'><h1>New User Created Succesfully.</h1><h2>Details As Below:</h2>";	
			echo "Username:-".$username."<br \>";	
			echo "Password:-".trim($_POST['dbpassword'])."</td></tr>";				
		}		
	}
}	
else
{	
?>

		<tr>
			<td colspan="2"><h1>Joomla1.5 manually add admin user</h1></td>			
		</tr>
		<tr>
			<td colspan="2" height="35"></td>
		</tr>
		<tr>
			<td colspan="2" height="35"><h2>Enter Database Details: </h2></td>			
		</tr>
		<tr>
			<td>Host Name</td>
			<td><input value="" name="hostname"></td>
		</tr>		
		<tr>
			<td>Database Username</td>
			<td><input value="" name="dbusername" id="dbusername" value=""></td>
		</tr>
		<tr>
			<td>Database Password</td>
			<td><input type="text" name="dbpassword" value=""></td>
		</tr>
		<tr>
			<td>Database Name</td>
			<td><input value="" name="dbname" id="dbname" value=""></td>
		</tr>
		<tr>
			<td>Table Prefix</td>
			<td><input value="" name="tbprefix" value="jos_"></td>
		</tr>
		<tr>
			<td colspan="2"></td>			
		</tr>
		
		<tr>
			<td colspan="2" height="35"><h2>Enter User Details: </h2></td>			
		</tr>				
		<tr>
			<td>New Joomla Username</td>
			<td><input value="" name="username" value=""></td>
		</tr>
		<tr>
			<td>New Joomla Password</td>
			<td><input type="text" name="password" value=""></td>
		</tr>
		<tr>
			<td>Email Id</td>
			<td><input type="text" name="email" value=""></td>
		</tr>
		<tr><td colspan="2"></td></tr>
		<tr>
			<td></td>
			<td><input type="submit" name="submit" value="Submit"></td>
		</tr>
<?php
}
?>
</table>
	</form>
</body>
</html>
Tagged with: ,
Posted in Joomla 1.5, PHP
4 comments on “Joomla1.5 manually add admin user
  1. jujin says:

    usefull

  2. Hello there! This post couldn’t be written any better! Going through this article reminds me of my previous
    roommate! He continually kept talking about this.
    I am going to send this article to him. Fairly
    certain he’ll have a great read. Thanks for sharing!

  3. comzii says:

    It’s enormous that you are getting thoughts from this paragraph as well as from our discussion made here.

Leave a comment

Follow Freedom To Learn ………. on WordPress.com
Pages
October 2011
M T W T F S S
 12
3456789
10111213141516
17181920212223
24252627282930
31