[PHP Service] Coding scripts for you ! [MyScripts V2]

Status
Not open for further replies.

Mac

New Member
Feb 9, 2011
111
2
Well i am bored and i wanna code your requests in PHP , HTML and SQL.

Limited things :
  • You may request one-file script.
  • Only based on Objects , classes and functions.
  • No CSS.

Requested things :
  • Script name.
  • SQL or non-SQL

Thank you.
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Thinking about it, there you can't do much with one file other than some checking and a form(boring) or get some info, or add info. I think you should Code an actual script other than a file.
Anyways, how about a forum software file, which has a class, functions, then anyone can code from this functions.
And of course then add an object (class = new class;)
 

Mac

New Member
Feb 9, 2011
111
2
What you mean ? A file that you put your code on , and when your run it , shows the code result ?
 

Jonty

Active Member
Aug 7, 2010
194
65
I'm sorry but the code in your signature is ugly so I doubt you can even code, you use capitals on your Ifs and Echos? o.o
 

Coder

Member
Jan 4, 2011
34
0
Makes code more interesting?

wow.

ok, make the following script.

Register and Login [Name, Password, Email, DOB]
Upon logging in, users are given a referral link that they can give others to register and mark them as referrer.
Users can then see a list of all the users who they have referred (Name, Email, Birthday [without the year]).
Then there is an "admin section" where an "admin" can login and view all referrals, or search referrals by user.

I don't need this, it is just to test you. Someone gave me that for a test before and I finished it in an hour and a half (I forgot a session_start(); and I didn't notice for like 30 minutes of debugging -_____-).

Go.
 

Mac

New Member
Feb 9, 2011
111
2
Okay. I will do that on one file only , its easy. Also No CSS.

@Jonty {
Well , i code that way . I like coding with grammar . "Echo" is same as "echo" same function so doesn't matter. For me it makes the code more interesting . Anyway using grammar is same as not using grammar . "echo" is same as "Echo" or "EcHo" .

Also.. using caps on Ifs and Echos doesn't mean i can't code.
}

@Kryptos {
Well , its more stats but still a script ..
PHP:
<?php
/* MyScripts V2 Script *\
*- Script for Kryptos
*- Script made by Mac
\* MyScripts V2 Script */
Include("/config.php");
Class Forum {
	Function getUserDetails() {
		$GetUsersOnline = MySQL_Query("SELECT * FROM users WHERE online = '1'") ;
		$GetLastUser = MySQL_Query("SELECT MAX(id) FROM users LIMIT '1'") ;
	}

	Function getForumDetails() {
		$Members = MySQL_Query("SELECT * FROM users ORDER BY id DESC") ;
		$Posts = MySQL_Query("SELECT * FROM posts ORDER BY id DESC") ;
	}
}
$Forum = new Forum;

$Forum->getUserDetails();
While( $echoUser = mysql_fetch_array( $GetUsersOnline ) ) {
	Echo "<p>Users online are: ".$echoUser['username']." , </p>";
}

While( $echoUser2 = mysql_fetch_array( $GetLastUser ) ) {
	Echo "<p>Last registred user : ".$echoUser2['username']."</p>";
}

$Forum->getForumDetails();
While( $echoForum = mysql_fetch_array($Members) ) {
	Echo "<p>There are ".$echoForum['id']." members registred</p>";
}

While( $echoForum2 = mysql_fetch_array($Posts) ) {
	Echo "<p>There are totaly ".$echoForum2['id']." posts</p>";
}
?>

And okay... I will stop using capitals .. I will code as i did before .:)

@Coder {
PHP:
<?php
session_start();
$pg = $_GET['pg'];
$host = "localhost";
$username = "root";
$password = "bess123";
$database = "PHPRetain";
class MySQL {
	function connect() {
		Global $host, $username, $password, $database;
		mysql_connect($host, $username, $password);
	}
	function selectdb() {
		Global $host, $username, $password, $database;
		mysql_select_db($database);
	}
	function query($string) {
		return mysql_query($string);
	}
}
$mysql = new MySQL;
$mysql->connect();
$mysql->selectdb();
if(!$pg) {
?>
	<form action='?pg=login'>
		<b>Username:</b> <input type='text' name='username'>
		<br /><br />Password:</b> <input type='password' name='password'>
		<input type='submit' value='Log in!'>
	</form>
<?php
}
if($pg == "login") {
	$username = mysql_real_escape_string($_POST['username']);
	$password = mysql_real_escape_string($_POST['password']);
	$sql = $mysql->query("SELECT * FROM users WHERE username='$username' and password='$password'");
	$check = mysql_num_rows($sql);
	if($check == 1) {
		session_register("username");
		session_register("password");
		header("location: ?pg=Home");
	}
	else {
		echo "Wrong username or password";
	}
}
if($pg == "Home") {
	$selectrank = $mysql->query("SELECT * FROM users WHERE username='$_SESSION[username]'");
	while($var = mysql_fetch_array($selectrank)) {
		if($var['rank'] == "2") {
			echo "<a href='?pg=Home&pg2=hk'>Housekeeping</a>";
		}else{
			echo "<p>You dont have acess of housekeeping</p>";
		}
	}
?>
	<fieldset>
		<legend>Welcome....</legend>
		Bla bla bla... ?
	</fieldset>
<?php
	$pg2 = $_GET['pg2'];
	if($pg2 == "hk") {
		while($var2 = mysql_fetch_array($selectrank)) {
			if($var2['rank'] == "2") {
				$users = $mysql->query("SELECT * FROM users");
				while($var3 = mysql_fetch_array($users)) {
					echo $var3['username']." invited by ";
					if(empty($refferedby)) {
						echo "None<br />";
					}
					else {
						echo $var3['refferedby']."<br />";
					}
				}
			}else{
				echo "<p>You dont have acess of housekeeping</p>";
			}
		}
	}
}
if($pg == "Register") {
	echo "<form method='post'>";
	echo "<b>Your username:</b> <input type='text' name='username'><br />";
	echo "<b>Your password:</b> <input type='password' name='password'><br />";
	echo "<b>You are reffered by:</b> <input type='text' name='refferedby'><br />";
	echo "<input type='submit' value='Register' name='Register'>";
	echo "</form>";
	if($_POST['Register']) {
		$error = "";
		if($_POST['username'] < 3) {
			$error .= "<p>Please post a username with more than 3 lenghts.</p>";
		}
		if($_POST['password'] < 3) {
			$error .= "<p>Please post a password with more than 3 lenghs.</p>";
		}
		$username_taken = $mysql->query("SELECT * FROM users");
		while($var5 = mysql_fetch_array($username_taken)) {
			if($_POST['username'] == $var5['username']) {
				$error .= "<p>Username is already taken.</p>";
			}
		}
		if(!$error) {
			$mysql->query("INSERT INTO users VALUES('$_POST[username]', '$_POST[password]', '$_POST[refferedby]', '1'");
		}
		else {
			echo $error;
		}
	}
}
?>>
there ya go...
 
Status
Not open for further replies.

Users who are viewing this thread

Top