I need tons of help

Status
Not open for further replies.

salukigirl

New Member
Messages
78
Reaction score
0
Points
0
I need some help. I need a login script. But I also need a script that will run certain things randomly. Anyone know what I'm talking about?

And don't bash me, Im just really new at this. =]
 

Chris73

New Member
Messages
5,356
Reaction score
1
Points
0
A simple login script that you can modify to suit your needs. It use a session to store data in a session file submited by the page. In this example the username and password will be save in the session file created by php.

I introduce the following files.

index.php -script file as name of your protected site.
login.html -script file as your login page.
user -folder
test.txt -account file under folder(user)
test|password -the content of the test.txt, username is test password is password

What you are going to do?
1. In your php.ini, enable session.use_cookies and specify session.save_path
2. Create a folder name "user" under it create an account file example: "test.txt"
3. The content of your test.txt will be like this
test|password
*note
account filename is the same as username.
5.copy the script and place it to your web directory.
4.edit the index.php and change the $root=to the actual full path where folder(user) is located.
5.and insert the code of your protected website as shown in the script.
<!//your script starts here when account is valid--->
<! insert your code here.....---->
Password Protected Website<br>
YOU ARE LOGIN AS <? echo $username ?> <br>

<a href=<?php echo"$SCRIPT_NAME";?>?logout=1>Logout</a>


<!//your script ends here--->
6:login and use test as username and password as password.

Code:
[COLOR=#000000][COLOR=#0000CC]<?php 
$root[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#CC0000]"c:/inetpub/wwwroot/folder/"[/COLOR][COLOR=#006600]; [/COLOR][COLOR=#FF9900]//full path of folder(user) 
[/COLOR][COLOR=#0000CC]session_start[/COLOR][COLOR=#006600](); 
[/COLOR][COLOR=#0000CC]$_SESSION[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'username'[/COLOR][COLOR=#006600]] = [/COLOR][COLOR=#0000CC]$username[/COLOR][COLOR=#006600]; 
[/COLOR][COLOR=#0000CC]$_SESSION[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'password'[/COLOR][COLOR=#006600]]   = [/COLOR][COLOR=#0000CC]$password[/COLOR][COLOR=#006600]; 
[/COLOR][COLOR=#FF9900]//if (isset($logout)) 
//{ 
[/COLOR][COLOR=#006600]if ([/COLOR][COLOR=#0000CC]$logout[/COLOR][COLOR=#006600]==[/COLOR][COLOR=#0000CC]true[/COLOR][COLOR=#006600]) 
{ 
unset([/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'username'[/COLOR][COLOR=#006600]]); 
unset([/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'password'[/COLOR][COLOR=#006600]]); 
echo[/COLOR][COLOR=#CC0000]"<meta http-equiv=refresh content=\"0;URL=$SCRIPT_NAME\">"[/COLOR][COLOR=#006600]; 
} 
[/COLOR][COLOR=#FF9900]//} 
[/COLOR][COLOR=#006600]if ([/COLOR][COLOR=#0000CC]file_exists[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000CC]$root[/COLOR][COLOR=#006600].[/COLOR][COLOR=#CC0000]"user/"[/COLOR][COLOR=#006600].[/COLOR][COLOR=#0000CC]$username[/COLOR][COLOR=#006600].[/COLOR][COLOR=#CC0000]".txt"[/COLOR][COLOR=#006600])) 
{[/COLOR][COLOR=#FF9900]//1 
[/COLOR][COLOR=#0000CC]$fp[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#0000CC]fopen[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000CC]$root[/COLOR][COLOR=#006600].[/COLOR][COLOR=#CC0000]"user/"[/COLOR][COLOR=#006600].[/COLOR][COLOR=#0000CC]$username[/COLOR][COLOR=#006600].[/COLOR][COLOR=#CC0000]".txt"[/COLOR][COLOR=#006600],[/COLOR][COLOR=#CC0000]"r"[/COLOR][COLOR=#006600]); 
[/COLOR][COLOR=#0000CC]$contents[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#0000CC]fread[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000CC]$fp[/COLOR][COLOR=#006600],[/COLOR][COLOR=#0000CC]filesize[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000CC]$root[/COLOR][COLOR=#006600].[/COLOR][COLOR=#CC0000]"user/"[/COLOR][COLOR=#006600].[/COLOR][COLOR=#0000CC]$username[/COLOR][COLOR=#006600].[/COLOR][COLOR=#CC0000]".txt"[/COLOR][COLOR=#006600])); 
[/COLOR][COLOR=#0000CC]fclose[/COLOR][COLOR=#006600]([/COLOR][COLOR=#0000CC]$fp[/COLOR][COLOR=#006600]); 
[/COLOR][COLOR=#0000CC]$info[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#0000CC]explode[/COLOR][COLOR=#006600]([/COLOR][COLOR=#CC0000]"|"[/COLOR][COLOR=#006600],[/COLOR][COLOR=#0000CC]$contents[/COLOR][COLOR=#006600]); 
[/COLOR][COLOR=#0000CC]$username1[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#0000CC]$info[/COLOR][COLOR=#006600][[/COLOR][COLOR=#0000CC]0[/COLOR][COLOR=#006600]]; 
[/COLOR][COLOR=#0000CC]$password1[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#0000CC]$info[/COLOR][COLOR=#006600][[/COLOR][COLOR=#0000CC]1[/COLOR][COLOR=#006600]]; 
if([/COLOR][COLOR=#0000CC]$password1[/COLOR][COLOR=#006600]==[/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'password'[/COLOR][COLOR=#006600]]) 
{[/COLOR][COLOR=#FF9900]//2 
[/COLOR][COLOR=#0000CC]?> 
[/COLOR]<!//your script starts here when account is valid---> 
<! Insert your code here ----> 
Password Protected Website<br> 
YOU ARE LOGIN AS [COLOR=#0000CC]<? [/COLOR][COLOR=#006600]echo [/COLOR][COLOR=#0000CC]$username ?>[/COLOR]  <br> 

<a href=[COLOR=#0000CC]<?php [/COLOR][COLOR=#006600]echo[/COLOR][COLOR=#CC0000]"$SCRIPT_NAME"[/COLOR][COLOR=#006600];[/COLOR][COLOR=#0000CC]?>[/COLOR]?logout=1>Logout</a> 


<!//your script ends here---> 
[COLOR=#0000CC]<?php 
[/COLOR][COLOR=#006600]}[/COLOR][COLOR=#FF9900]//2 
[/COLOR][COLOR=#006600]else 
{[/COLOR][COLOR=#FF9900]//2 
[/COLOR][COLOR=#0000CC]$err[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#CC0000]"Invalid Password"[/COLOR][COLOR=#006600]; 
include([/COLOR][COLOR=#CC0000]"login.html"[/COLOR][COLOR=#006600]); 
unset([/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'username'[/COLOR][COLOR=#006600]]); 
unset([/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'password'[/COLOR][COLOR=#006600]]); 
[/COLOR][COLOR=#0000CC]session_destroy[/COLOR][COLOR=#006600](); 
}[/COLOR][COLOR=#FF9900]//2 
[/COLOR][COLOR=#006600]}[/COLOR][COLOR=#FF9900]//1 
[/COLOR][COLOR=#006600]else 
{ 
[/COLOR][COLOR=#0000CC]$err[/COLOR][COLOR=#006600]=[/COLOR][COLOR=#CC0000]"Invalid Username"[/COLOR][COLOR=#006600]; 
include([/COLOR][COLOR=#CC0000]"login.html"[/COLOR][COLOR=#006600]); 
unset([/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'username'[/COLOR][COLOR=#006600]]); 
unset([/COLOR][COLOR=#0000CC]$HTTP_SESSION_VARS[/COLOR][COLOR=#006600][[/COLOR][COLOR=#CC0000]'password'[/COLOR][COLOR=#006600]]); 
[/COLOR][COLOR=#0000CC]session_destroy[/COLOR][COLOR=#006600](); 
} 
[/COLOR][COLOR=#0000CC]?> 
[/COLOR] 
login.html 
<html> 
<head><title>login</title></head> 
<body bgcolor=gold> 
<center> 
<form method=post action=[COLOR=#0000CC]<? [/COLOR][COLOR=#006600]echo [/COLOR][COLOR=#CC0000]"$SCRIPT_NAME"[/COLOR][COLOR=#006600]; [/COLOR][COLOR=#0000CC]?>[/COLOR]> 
<table border=1 cellpadding=3 celspacing=3 align=center width=50%> 
<tr><td colspan=2 align=center>Login</td></tr> 
<tr><td colspan=2 align=center>[COLOR=#0000CC]<?php [/COLOR][COLOR=#006600]if (isset([/COLOR][COLOR=#0000CC]$username[/COLOR][COLOR=#006600])){if ([/COLOR][COLOR=#0000CC]$logout[/COLOR][COLOR=#006600]==[/COLOR][COLOR=#0000CC]false[/COLOR][COLOR=#006600]){if(isset([/COLOR][COLOR=#0000CC]$err[/COLOR][COLOR=#006600])){echo [/COLOR][COLOR=#CC0000]"$err"[/COLOR][COLOR=#006600];}}}[/COLOR][COLOR=#0000CC]?>[/COLOR]</td></tr> 
<tr><td>Username:</td><td><input type=text name=username size="20"></td><tr> 
<tr><td>Password:</td><td><input type=password name=password size="20"></td><tr> 
<tr><td colspan=2><input type=submit></td><tr> 
</table> 
</form> 
</body> 
</html>


I would make sure it's not going against the TOS agreement.

As far as the other thing "random events" i have no clue what you are asking.
[/COLOR]
 
Last edited:

alfren

New Member
Messages
207
Reaction score
0
Points
0
well if you want a ready made script like that with more certain features, why don't you try installing a CMS like joomla, phpnuke, wordpress,... there's a lot of CMS in the fantastico in your cpanel it very easy to install and you don't have to make your own script.. ^_^
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
for random events in php:

mt_rand() is fast and does the job sufficently.

Give us a better idea as to what you want randomized !

Should it be a script that returns a object, string ?
Edit:
PHP:
<?php
session_start();

class Object 
{
   var 
     $rnd_num,
     $color,
     $img,
     $image;

     function Object() {
        
        $this->rnd_num = mt_rand(1,3); // rand number 1-3
        $this->doColor();

        $this->doImg();

        $this->image = imagecreatefrompng($img);

        $this->show();
     }

     function doColor () {
        switch ($rnd_num) {
            case 1: $this->color = '0,0,0'; //black
            case 2: $this->color = '1,1,1';
            case 3: $this->color = '256,256,256';
            default: $this->color = '256,0,256';
       } 
     }

     function doImg ($rnd_color) {
        switch ($rnd_num) {
            case 1: $this->img = 'img/pic01.png';
            case 2: $this->img = 'img/pic02.png';
            case 3: $this->img = 'img/pic03.png';
            default: $this->img = 'img/pic04.png';
       }
     }

     function show() {

        Header ("Content-type: image/png");
        //bring in the color here
        imagepng($this->image);
        imagedestroy($this->image);
        
     }

$Obj = new Object();
?>

Another option would be to contract a developer. Only recomendation i can give is post in the offers forum and tell people what you would like out of your page and what your willing to pay.
Edit:
Realising she is new at this(web development i asume).

Telling her to go to her php.ini file without telling here how to setup a localhost is pretty usless.

Giving her this long winded php code, procedral/object orientaited is not going to help at all.

Let me ask you this salukigirl, are you intrested in becoming a developer or just having a web page?
 
Last edited:

Chris73

New Member
Messages
5,356
Reaction score
1
Points
0
Sorry i am used to everyone knowing what needs to be done i do apologize.

I guess i should stop thinking like everyone is a computer pro once in awhile.
 
Last edited:

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
No appologies needed. Specialy not to me man. I am no better in the same respect.

Just when I read over what she posted it seems like she doesn't even know what she wants to do.
 

salukigirl

New Member
Messages
78
Reaction score
0
Points
0
Oh thank you sooooo much. This helps a lot. =]
Edit:
Sorry, Didn't mean to ignore your question. Just to have a web page. =]

I know I look like a total Newb, but I do sorta kinda know what I'm doing, just not how to explain it. Or most of the terms used. =P
Edit:
I wasn't sure if I should make a new thread but I got stuck. i SAVED MY INDEX.PHP Connect.php. login.php and logout.php and register.php in the www place. Is that where they were supposed to go? I made the players table (in my database) and connect.php was supposed to well connect to it. Am I totally wrong? What did I do wrong?
Edit:
I have a local host and my database all set up, I just keep getting stuck and don't know why...
 
Last edited:
Status
Not open for further replies.
Top