Mac
New Member
- Feb 9, 2011
- 111
- 2
Well , i helped powahcoder with a motto change system , and i wanted to make it OOP so i made it! Anyways i don't have MySQL in my webhost so when i am testing it, it's giving me mysql errors (that's clear!) but i want you to check my code if everything is good , and if there are any other errors (yeah , in PHP doesn't show all errors in 1 time).
My opinion is yes my code is clear.
Anyways here's my code :
My opinion is yes my code is clear.
Anyways here's my code :
PHP:
<?php
mysql_connect("host", "root", "pass"); # Edit this!
mysql_select_db("dbname"); # Edit this!
class Motto {
public $query_cont = "WHERE username = '".$_SESSION["username"]."'";
public static $actual_motto = mysql_query("SELECT motto FROM users ".$query_cont."");
public static $new_motto = strip_tags($_POST["motto"]);
public $isSubmited = $_POST["submit"];
public function startSystem() {
if($this->isSubmited):
if(isset($this->new_motto)):
Mysql_query("UPDATE users SET motto = '".$this->new_motto."'".$query_cont."");
echo "Your motto is changed to ".$this->new_motto;
else:
mysql_query("UPDATE users SET motto = 'No motto entered!'".$query_cont."");
echo "Your motto is changed to No motto entered!";
endif;
else:
?>
<form method='post'>
<b>Please write your new motto : </b> <input type='text' name='motto'> <br />
<input type='submit' name='submit' value='Change my motto!'>
</form>
<?php
endif;
}
}
$motto = new Motto;
$motto->startSystem();
?>