Version: uploader text
Type: Function
Category: Databases
License: Other
Description: this script can help you get your data base up and running, you can upload html and discriptions ,then you can easly edit your script or delete it from your data base!
<html> <head><title></title></head> <body> <!--very good data entry page,with confirmation page!//--><br> <html><br> <head><br> <title>data entry page</title><br> </head><br> <body bgcolor="CCCCCC"><br> <?php include("header.inc"); <br> //header include for data entry page. [not nessesacery you can delete this line #10]<br> $db = mysql_connect("localhost", "Administrator");<br> // might have to change user name and host name.<br> mysql_select_db("test",$db); <br> // data base name <br> <p>//i have used my test data vase here.<br> //you will have to create a table called employees in your test DB in mysql.<br> //with the following mysql query:<br> //mysql>use test;<br> //database changed<br> //mysql>create table employees( id tinyint(4) default '0' not null auto_increment,<br> // ->first varchar (255),<br> // ->last varchar(255),<br> // ->address varchar(255),<br> // ->position mediumtext,<br> // ->primary key (id),<br> // ->unique id (id));<br> //<br> //then go back and view this page and start your data base,<br> //you will need to create a new php page to veiw the info in your site!<br> //to upload images from this form simply type in where you will find the image on you server eg:<img src="C:/images/image.gif"> <br> //and this is alot faster that uploading a image to the data base </p> if ($submit) {<br><br> // here if no ID then adding else we're editing<br><br> if ($id) {<br><br> $sql = "UPDATE employees SET first='$first',last='$last',address='$address',position='$position' WHERE id=$id";<br><br> } else {<br><br> $sql = "INSERT INTO employees (first,last,address,position) VALUES ('$first','$last','$address','$position')";<br><br> }<br><br> // run SQL against the DB<br><br> $result = mysql_query($sql);<br><br> echo "<img src=button1.gif><br><p>Record updated/edited!</p><a href=$PHP_SELF>[ Refresh ]</a>";<br><br> } elseif ($delete) {<br><br> // delete a record<br><br> $sql = "DELETE FROM employees WHERE id=$id"; <br><br> $result = mysql_query($sql);<br><br> echo "<img src=button1.gif><br><p>$sql Record deleted!</p><a href=$PHP_SELF>[ Refresh ]</a>"; } else {<br><br> // this part happens if we don't press submit<br><br> if (!$id) {<br><br> // print the list if there is not editing<br><br> $result = mysql_query("SELECT * FROM employees",$db);<br><br> while ($myrow = mysql_fetch_array($result)) {<br><br> printf("<li><a href="%s?id=%s">%s </a>n", $PHP_SELF, $myrow["id"], $myrow["first"]);<br><br> printf(" <a href="%s?id=%s&delete=yes"><b>[Delete]</b></a><br><br>", $PHP_SELF, $myrow["id"]);<br><br> }<br><br> }<br><br> ?><br><br> <P><br><br> <a href="<?php echo $PHP_SELF?>">[Add a record]</a><br><br> <P><br><br> <form method="post" action="<?php echo $PHP_SELF?>"><br><br> <?php<br><br><br><br> if ($id) {<br><br> // editing so select a record<br><br> $sql = "SELECT * FROM employees WHERE id=$id";<br><br> $result = mysql_query($sql);<br><br> $myrow = mysql_fetch_array($result);<br><br> $id = $myrow["id"];<br><br> $first = $myrow["first"];<br><br> $last = $myrow["last"];<br><br> $address = $myrow["address"];<br><br> $position = $myrow["position"];<br><br> // print the id for editing<br><br><br><br> ?><br><br> <input type=hidden name="id" value="<?php echo $id ?>"><br><br> <?php<br><br> }<br><br><br><br> ?><br><br> <table border="1" cellspacing="1" cellpadding="7"><tr><td><br> Page title!</td><td><input type="Text" name="first" value="<?php echo $first ?>"><br><br> </td></tr><br> <tr><td><br> Header or Images.</td><td><input type="Text" name="last" value="<?php echo $last ?>"><br><br> </td></tr><br> <tr><td><br> Info.</td><td><input type="Text" name="address" value="<?php echo $address ?>"><br><br> </td></tr><br> <tr><td valign="top"><br> HTML content!</td><td><br> <textarea type="input" name="position" value="" rows="20" cols="70"><?php echo $position ?></textarea><br> <br> </td></tr><br> <tr><td valign="top"><br> <input type="Submit" name="submit" value="Enter information"></td><td valign="top"><br> <input type="reset" name="reset" value="clear fields"><br><br> </form><br> </td></tr><br> </table><br><br> <?php<br><br><br><br> }<br><br><br><br> ?><br><br><br><br> </body><br><br> </html><br> </body></html>