Jump to content

can you help me , i want to know any thing


mo_ib_bmw

Recommended Posts

i hope you can code HTML for i dont have time to do everything for you but i can code the PHP..registrer.php :

<script type="text/javascript"> function DispTakenUser() //If the username is taken we display a alert box...{alert("Username is taken. Pleace try another one.")}</script><?phpif(isset($_POST['reg'])){ //name the submit button reg$user=$_POST['user']; //name the User textfield for user$pass=$_POST['pass']; //name the password textfield pass $email=$_POST['email']; //name the email textfield email$ip=$_SERVER['REMOTE_ADDR']; //get the ip address.$seluser=mysql_num_rows(mysql_query("SELECT user FROM users WHERE user='$user'")); //select usernameif(!$seluser=0){ //check the selected usernameecho"<script type=\"text/javascript\">history.back(); DispTakenUser();</script>"; //if the username is taken}else //if the username is avalible{mysql_query("INSERT INTO users( //insert the user to the MySQL database...id,user,password,email,ip,level)VALUES('','$user','$pass','$email','$ip','User')") or die("Error : " .mysql_error()); //show error if it comes upecho"Your account has been created. Login with your username and password"; //user created}?>

make a login.php with textfield for username and password named user and pass, and a submit form button named login and the form action must be login_do.php and method postlogin_do.php :

<script type=\"text/javascript\">function DispWronguserOrpass(){alert("The username or password is incorrect. Pleace try again")}</script><?phpif(isset($_POST['login'])){$user=$_POST['user'];$pass=$_POST['pass'];$seluser=mysql_query("SELECT user FROM users WHERE user='$user'"); //check user$check=mysql_num_rows($seluser);//check userif(!$check > 0){//check userecho"<script type=\"text/javascript\">history.back(); DispWronguserOrpass();</script>";//Display a message if user dont exist}$selpass=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE user='$user'")); //check passif($selpass!=$pass){ //checkpassecho"<script type=\"text/javascript\">history.back(); DispWronguserOrpass();</script>"; //Display a message if password is wrong}else //if everything is right{setcookie(user,$user,time()+3600);  //he/she will now be online for 1hour$deltime=time()+3500;mysql_query("UPDATE users SET online='Yes' WHERE user='$user'"); //set user onlinemysql_query("UPDATE users SET delonline='$deltime' WHERE user='$user'"); //set the time when we will make the user to be automaticly logget out and set offlineheader("Location: your_user_protected_site.php"); //get the user to your site}} //login = done....?>

now we need a little script for all pages :

<?php$user=$_COOKIE['user']; //Get the cookie$usere=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE user='$user'")); //select things from userif($usere->delonline <= time()){ //if the user has been online for 3500secondsmysql_query("UPDATE users SET online='No' WHERE user='$user'");setcookie(user,$user,time()-3600); //set the cookie to be "gone" so the user can be set offline and logged out..header("Location: the_site_where_you_want_him_to_go.php");}?>

So the only thing you need now is to set up the table users :id int(30) auto_increment primary key the user iduser varchar(15) the user namepass varchar(40) the passwordemail varchar(60) the emailip varchar(20) the ip addressonline enum('No','Yes') onlinedelonline varchar(30) delete online level enum('User','Moderator','Administrator') // userlevelthink that was everything, hope this will help you... if not im sure some other guys can help you more :).. so now you can set the userlevel direct from the MySQL db, or you can read abit about the $_POST[] functions and mysql_update / select in the wonderful world of w3schools.com-Kristian_C

Link to comment
Share on other sites

what kind of groups do you think about?, added userlevel there, as in user, mod, admin... do change level on urself you can go to the MySQL database and insert you or edit ur user and set userlevel to Administrator..to set others :admin.php

<?php//insert the code i said you had to have on all sites...if(!$users->userlevel="Administrator"){ //block user if user aint adminecho"Only admins here mate";}else //if user is admin{?>//your html code here<?phpif(isset($_POST['makeadmin'])){$userto=$_POST['userto']; //make a textfield with the name userto here you insert the name of the users you want to make adminmysql_query("UPDATE users SET userlevel='Administrator' WHERE user='$userto'");echo"$userto is now admin";}//just duplicate the code to make users Moderator, just remember to change the userto and Administrator...} //end of code?>

Hope thats what you need :)-Kristian_C

Link to comment
Share on other sites

Basically if you have a database with the users' details you can just create an extra column with the user's type.

Link to comment
Share on other sites

And what sort of format are you storing the user's details in? E.g. in a database, or in a flat file?

Link to comment
Share on other sites

Well what kind of site are you creating?....
And what sort of format are you storing the user's details in? E.g. in a database, or in a flat file?
hi,i want to do script upload and i want do 3 group's in it :visitor -> don't have control panel , and can be upload file to 1 Mbuser -> he have control panel to save his file in it , and can be uploaded to 10 Mbadmin -> he have control panel , he can edit setting of user's and file's , and he can uploaded to 25 Mb thanx...
Link to comment
Share on other sites

ok, just change the max file upload value to $max frist, then you add this code right afther the code i gave you :

if($usere->userlevel=="User"){  // if User$max="1000000"; //think it is 10mb :p.}		  elseif($usere->userlevel=="Administrator"){ //if Admin$max ="2500000";}		   else{$max="100000"; //if visitor.}

to be able to change stuff for users, just read about post and get functions and some MySQL...-Kristian_C.

Link to comment
Share on other sites

Uh... 2500000 is 2.5 MB, 1000000 bytes is 1 megabyte, and 100000 is 100 kb... the code should be

if($usere->userlevel=="User"){  // if User$max="10000000"; //THIS is 10mb :D}		  elseif($usere->userlevel=="Administrator"){ //if Admin$max ="25000000";}		   else{$max="1000000"; //if visitor.}

:)

Link to comment
Share on other sites

thanx Diegar....Kristian_C... while i use your step to do online and remmember the user by cookies i filed !!i mean with filed : don't remmember the user after do login !!
I am actually having similar issues with the script, but i am gonna keep plugging away at it for a while.Mine is telling me upon registration that the name is already taken, when it isn't, and when i enter one in manually, then try to log in with it, it hits the cookie code at the top of the member page, but go immediately to the 'logged out' page in the code. Seems that the cookie isn't taking, so the user always stays logged out.
Link to comment
Share on other sites

Okay... i have added some html into the script in hopes of finding where it went wrong during login.

<script type=\"text/javascript">function DispWronguserOrpass(){alert("The username or password is incorrect. Pleace try again")}</script><?phprequire("dbconfig.php");?><table>	<tr>		<td>			<font>Step 1</font>		</td>	</tr></table><?if(isset($_POST['login'])){?><table>	<tr>		<td>			<font>Step 2</font>		</td>	</tr></table><?$user=$_POST['user'];$pass=$_POST['pass'];

When i try to login, it now says Step 1, which it should, but never shows Step 2... So this line "if(isset($_POST['login'])){" is messing things up, but it might be something i am doing wrong in the form. Anyone have any clues to why this line would be messing me up?

Link to comment
Share on other sites

<script type=\"text/javascript"> - Remove the \ in it.Do you have some HTML element like the submit button named 'login'?
It only seems to get to the register.php page script if i name the form login, and not the submit button. If i name the form "log" and the submit button "login" (reverse), then when i try to login, i hit submit and it just refreshes the login screen. It doesn't go any further than that.let me know if i need to include more info, cause i am lost in this.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...