PDA

View Full Version : Need a PHP Expert? - Look in this thread.



Ovae
04-08-2006, 02:59 PM
I Am a PHP Expert, I Can Give You a Code For a USer System, And Much Much More, How about Heres Something You Can USe For Your Site..
User System & DJ Says: [Remember To Code It Through MacroMedia] -



DJ Says: -


<?
ob_start();
include("config.php");
if ($logged['level'] == "3" || $logged['level'] == "5") { // level 3 is my dj level. level 5 is my admin level, change if you want to
echo("
<center><form action=\"?p=djcode.php\" method=\"post\" name=\"form1\" target=\"_self\"><br>
<label><br> DJ Message: <br> <textarea name=\"message\" cols=\"35\" id=\"message\"></textarea></label> </p>
<center><p> <label> <input type=\"submit\" name=\"Submit\" value=\"Update!\"> </label> </p> </form>
"); // the form for the message.
}else{
echo
("You are not a DJ so you cannot access this page!"); // if the person trieng to view this page,
and does not have teh authority, echos a warning
}
?>

[End of the DJ says php]

[New Start of DJ Says PHP]

<?
ob_start(); // starts cookies
include("config.php"); // inclues the config file
if ($logged['level'] == "3" || $logged['level'] == "5") { // level 3 and 5 can view
if (file_exists)"djmessage.txt"; // if djmessage.txt exists
$myFile = "djmessage.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$message = $_POST['message']; // posts the mesage from the form
$user = $logged[username];
$stringData = "DJ <b>".$user."</b> Says: ".$message;
fwrite($fh, $stringData); // updates the message
fclose($fh);
}else{
echo
("You are not a DJ so you cannot access this page!"); // display the "you are not" message
}
?>

Your DJ Message has been send successfully.



[End[]

Flauvo
04-08-2006, 03:00 PM
Ever think about php tags?

Ovae
04-08-2006, 03:04 PM
CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(30) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`email` varchar(40) NOT NULL default '',
`msn` varchar(250) NOT NULL default 'Not Specified',
`aim` varchar(250) NOT NULL default 'Not Specified',
`location` varchar(36) NOT NULL default 'Not Specified',
PRIMARY KEY (`id`)
) TYPE=MyISAM;


[End]



<?
ob_start(); // allows you to use cookies
$conn = mysql_connect("localhost","DATABASE USERNAME","DATABASE PASSWORD");
mysql_select_db(DATABASE NAME) or die(mysql_error());
//fill in the above lines where there are capital letters.
$logged = MYSQL_QUERY("SELECT * from users WHERE id='$_COOKIE[id]' AND password = '$_COOKIE[pass]'");
$logged = mysql_fetch_array($logged);
//the above lines get the user's information from the database.
?>


[end]


<?
ob_start();
include("config.php");
?>

[end]



<?php
ob_start();
// allows you to use cookies
include("config.php");
//gets the config page
if ($_POST[register]) {
// the above line checks to see if the html form has been submitted
$username = $_POST[username];
$password = $_POST[pass];
$cpassword = $_POST[cpass];
$email = $_POST[emai1];
//the above lines set variables with the user submitted information
if($username==NULL|$password==NULL|$cpassword==NUL L|$email==NULL) {
//checks to make sure no fields were left blank
echo "A field was left blank.";
}else{
//none were left blank! We continue...
if($password != $cpassword) {
// the passwords are not the same!
echo "Passwords do not match";
}else{
// the passwords are the same! we continue...
$password = md5($password);
// encrypts the password
$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$checkemail = mysql_num_rows($checkemail);
if ($checkemail>0|$checkname>0) {
// oops...someone has already registered with that username or email!
echo "The username or email is already in use";
}else{
// noone is using that email or username! We continue...
$username = htmlspecialchars($username);
$password = htmlspecialchars($password);
$email = htmlspecialchars($email);
// the above lines make it so that there is no html in the user submitted information.
//Everything seems good, lets insert.
$query = mysql_query("INSERT INTO users (username, password, email) VALUES('$username','$password','$email')");
// inserts the information into the database.
echo "You have successfully registered!";
}
}
}
}
else
{
// the form has not been submitted...so now we display it.
echo ("
<center>
<form method=\"POST\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\"><br />
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"pass\"><br />
Confirm Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"cpass\"><br />
Email: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"emai1\"><br />
<input name=\"register\" type=\"submit\" value=\"Register\">
</form>
</center>
");
}
?>


[end]




<?
oB_start();
// allows you to use cookies.
include("config.php");
if (!$logged[username])
{
if (!$_POST[login])
{
echo("
<center><form method=\"POST\">
<table>
<tr>
<td align=\"right\">
Username: <input type=\"text\" size=\"15\" maxlength=\"25\" name=\"username\">
</td>
</tr>
<tr>
<td align=\"right\">
Password: <input type=\"password\" size=\"15\" maxlength=\"25\" name=\"password\">
</td></tr><tr>
<td align=\"center\">
<input type=\"submit\" name=\"login\" value=\"Login\">
</td></tr><tr>
<td align=\"center\">
<a href=\"register.php\">Register Here</a>
</td></tr></table></form></center>");
}
if ($_POST[login]) {
// the form has been submitted. We continue...
$username=$_POST['username'];
$password = md5($_POST[password]);
// the above lines set variables with the submitted information.
$info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$data = mysql_fetch_array($info);
if($data[password] != $password) {
// the password was not the user's password!
echo "Incorrect username or password!";
}else{
// the password was right!
$query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error());
$user = mysql_fetch_array($query);
// gets the user's information
setcookie("id", $user[id],time()+(60*60*24*5), "/", "");
setcookie("pass", $user[password],time()+(60*60*24*5), "/", "");
// the above lines set 2 cookies. 1 with the user's id and another with his/her password.
echo ("<meta http-equiv=\"Refresh\" content=\"0; URL=http://yoursite.com\"/>Thank You! You will be redirected");
// modify the above line...add in your site url instead of yoursite.com
}
}
}
else
{
// we now display the user controls.
echo ("<center>Welcome <b>$logged[username]</b><br /></center>
- <a href=\"editprofile.php\">Edit Profile</a><br />
- <a href=\"members.php\">Member List</a><br />
- <a href=\"logout.php\">Logout</a>");
}
?>


[end]





[User system code]

craigg.
04-08-2006, 03:16 PM
A php expert? Isn't that just tech tuts? *rolls eyes*

Liam.
04-08-2006, 03:18 PM
yeah it is rofll

Flauvo
04-08-2006, 03:18 PM
Lmao at this guy.

Ovae
04-08-2006, 03:19 PM
Wow, you guys really think its tech tuts?
Check their codes... Are they the same as mine?

No ;l

Liam.
04-08-2006, 04:27 PM
yeh they are;
http://techtuts.com/?view=tutorials&act=tutorial&id=8

Colin-Roberts
04-08-2006, 04:40 PM
ye they are.

Chriš
04-08-2006, 04:47 PM
If your an expert then make some install files
and ill test them

Luckyrare
04-08-2006, 04:52 PM
If your an expert then make some install files
and ill test them

You dont need to be a expert to make a installer :l You just use mysql_query



ALSO! OHMYGOD U ARE UBER PR0 CODA U WISH I WAZ AS GUD AZ U PLS./....

Mentor
04-08-2006, 04:57 PM
0.o Wow such uber coder skill you show with you copy and paste powers...

Chriš
04-08-2006, 05:18 PM
Okay maybee not an expert but installers are hard to make if you dont no how too.

Splinter
04-08-2006, 05:28 PM
no they arent its just basic sql.. ;|

Chriš
04-08-2006, 05:29 PM
Yup that's true but alot of people cant do it

Splinter
04-08-2006, 05:35 PM
because lots of people dont know php but if you do then you can..

Mentor
04-08-2006, 06:07 PM
Okay maybee not an expert but installers are hard to make if you dont no how too.
0.o depends what you mean by installer, usealy for simple mysql ones, u just have to exicute the mysql on the db.. which is under a line of exstra code on top of the normal query, then maybe write a config file to remember the data "/
Its pretty easy, createing the SQL to make the tables is still the most complex part of it, turning that in to an installers easy "/

Jae
04-08-2006, 10:31 PM
Wow, you guys really think its tech tuts?
Check their codes... Are they the same as mine?

No ;l

Rofl yeah they are mate, also the DJ says script is of this forum "/


I Am a PHP Expert, I Can Give You a Code For a USer System, And Much Much More, How about Heres Something You Can USe For Your Site..

User System & DJ Says: [Remember To Code It Through MacroMedia] -








DJ Says: -





<?

ob_start();

include("config.php");

if ($logged['level'] == "3" || $logged['level'] == "5") { // level 3 is my dj level. level 5 is my admin level, change if you want to

echo("

<center><form action=\"?p=djcode.php\" method=\"post\" name=\"form1\" target=\"_self\"><br>

<label><br> DJ Message: <br> <textarea name=\"message\" cols=\"35\" id=\"message\"></textarea></label> </p>

<center><p> <label> <input type=\"submit\" name=\"Submit\" value=\"Update!\"> </label> </p> </form>

"); // the form for the message.

}else{

echo

("You are not a DJ so you cannot access this page!"); // if the person trieng to view this page,

and does not have teh authority, echos a warning

}

?>


[End of the DJ says php]


[New Start of DJ Says PHP]


<?

ob_start(); // starts cookies

include("config.php"); // inclues the config file

if ($logged['level'] == "3" || $logged['level'] == "5") { // level 3 and 5 can view

if (file_exists)"djmessage.txt"; // if djmessage.txt exists

$myFile = "djmessage.txt";

$fh = fopen($myFile, 'w') or die("can't open file");

$message = $_POST['message']; // posts the mesage from the form

$user = $logged[username];

$stringData = "DJ <b>".$user."</b> Says: ".$message;

fwrite($fh, $stringData); // updates the message

fclose($fh);

}else{

echo

("You are not a DJ so you cannot access this page!"); // display the "you are not" message

}

?>



Your DJ Message has been send successfully.




[End[]





The code won't work because some of the comments run through as code on the normal forum post.Put it into a code window Mr.!337 coda!

Ovae
04-10-2006, 05:32 AM
testing to shoort

Liam.1
04-10-2006, 01:28 PM
why bump the thread?

Want to hide these adverts? Register an account for free!