--post.php-- <?php #change localhost to the sql server, user to the correct username, and pass to the correct password $con = mysql_connect("localhost","user","pass") or die("Unable to establish a connection to the database.");
#change database to the database name $database = "database"; $db = mysql_select_db("$database") or die("Couldn't select database $database.");
$query = "INSERT INTO tagboard(name,http,msg) VALUES('$name,$http,$msg')";
$result = mysql_query($query) or die("Data couldn't be entered into the database.");
echo "Click <a href='view.php'>here</a>."; ?>
--view.php-- <?php #change localhost to the sql server, user to the correct username, and pass to the correct password $con = mysql_connect("localhost","user","pass") or die("Unable to establish a connection to the database.");
#change database to the database name $database = "database"; $db = mysql_select_db("$database") or die("Couldn't select database $database.");
$query = "SELECT id,name,http,msg FROM tagboard ORDER BY id DESC"; selects all the rows from the table tagboard and orders them in descending order
} else { /*Function used to connect to sql server and choose database*/ function connect(){ #change localhost to the sql server, user to the correct username, and pass to the correct password $con = mysql_connect("localhost","user","pass") or die("Unable to establish a connection to the database.");
#change database to the database name $database = "database";
$query = "UPDATE tagbard WHERE id='$id' SET name='$name' http='$http' msg='$msg'"; $result = mysql_query($query); echo "ID # $id has been edited successfully."; } } ?>
--sql syntax-- CREATE TABLE tagboard (id TINYINT (4) not null AUTO_INCREMENT, name VARCHAR (32), msg VARCHAR (50), http VARCHAR (32) , PRIMARY KEY (id))
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.