PHP MySQL image upload tmp to chosen directory - php

Ok, i want to upload an image from my computer to the host/database, everything works fine and it all uploads to the database (image name VARCHAR as to just be wording not image), except the image doesn't want to move and I get this warning:
Upload: 6285.jpg
Type: image/jpeg
Size: 68.1669921875 kB
Temp file: /tmp/php1Be59N
Warning: move_uploaded_file(/public_html/pages/CMX/images/products/oils/6285.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/littlepe/public_html/pages/CMX/pages/extras/allFunctions.php on line 875
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1Be59N' to '/public_html/pages/CMX/images/products/oils/6285.jpg' in /home/littlepe/public_html/pages/CMX/pages/extras/allFunctions.php on line 875
Stored in: /public_html/pages/CMX/images/products/oils/6285.jpg Upload another? or Go home?
I have been through every type of directory, the first is the absolute path:
/home/public_html/pages/CMX/images/products/oils/6285.jpg
/public_html/pages/CMX/images/products/oils/6285.jpg
/pages/CMX/images/products/oils/6285.jpg
/CMX/images/products/oils/6285.jpg
/images/products/oils/6285.jpg
/products/oils/6285.jpg
/oils/6285.jpg
The directory is writeable and correct (I would show you but cannot post images as of yet).
My Form code:
$user_check=$_SESSION['login_user'];
$sqlCommand = "(SELECT * FROM userAccount WHERE email='$user_check')";
$query = mysqli_query($con,$sqlCommand) or die("Error: ".mysqli_error($con));
$column = mysqli_fetch_array($query);
if($column['admin'] != NULL){
echo "<section class='userName'><h3>".$column['firstName']." ".$column['surname']."</h3></section>";
echo "<section class='address'>".$column['addressLine1']."<br />".$column['addressLine2']."<br />".$column['county']."<br />".$column['country']."<br />".$column['postCode']."</section>";
echo "<section class='email'><h3>".$column['email']."</h3></section>";
echo "<hr />";
echo "<section class='upNewProduct' style='height:400px;overflow:auto;'><h3>Upload New Product</h3>
<form action='extras/uploadProcess.php' method='post' enctype='multipart/form-data'>
Product Name: <input type='text' name='productName' /><br />
Product Image Sub-Catagory: <select name='prodImgCat' id='prodImgCat'>
<option selected>Choose a Sub Catagory for Image</option>
<option value='oils/'>Oil</option>
<option value='chain/'>Chain</option>
<option value='coolant/'>Coolant</option>
<option value='filter/'>Filter</option>
</select><br />
Product Image: <input type='file' name='productImg' /><br />
Description: <textarea type='text' name='shortDesc' value='' maxlength='1500' cols='22' rows='6' tabindex='6' id='shortDesc'></textarea><br />
Features: <textarea type='text' name='longDesc' value='' maxlength='1500' cols='22' rows='6' tabindex='6' id='longDesc'></textarea><br />
Price: <input type='text' name='price' /> <strong style='font-size:8pt;'>(Do <u>NOT</u> enter £ / &dollar; / € currency symbols. <u>ONLY</u> enter numerals. <u>e.g:</u> 99.99 )</strong><br />
Catagory: <select name='catagory' id='catagory'>
<option selected>Choose a Catagory</option>
<option value='Helmets'>Helmets</option>
<option value='Gloves'>Gloves</option>
<option value='Boots'>Boots</option>
<option value='Body Protection'>Body Protection</option>
<option value='Clothing'>Clothing</option>
<option value='Bike Parts'>Bike Parts</option>
<option value='Accessories'>Accessories</option>
</select><br />
Sub-Catagory: <select name='subCat' id='subCat'>
<option selected>Choose a Sub Catagory</option>
<option value='Oil'>Oil</option>
<option value='Chain'>Chain</option>
<option value='Coolant'>Coolant</option>
</select><br />
Brand: <select name='brand' id='brand'>
<option selected>Choose a brand</option>
<option value='100%'>100%</option>
<option value='Acerbis'>Acerbis</option>
<option value='Airoh'>Airoh</option>
<option value='Akrapovic'>Akrapovic</option>
<option value='Alias'>Alias</option>
<option value='Alpinestars'>Alpinestars</option>
<option value='Answer Racing'>Answer Racing</option>
<option value='Apico'>Apico</option>
<option value='Arai'>Arai</option>
<option value='Artrax'>Artrax</option>
<option value='Asterisk'>Asterisk</option>
<option value='Beer Optics'>Beer Optics</option>
<option value='Bell'>Bell</option>
<option value='Blackrock'>Blackrock</option>
<option value='Bolt'>Bolt</option>
<option value='Cycra'>Cycra</option>
<option value='Deft Family'>Deft Family</option>
<option value='DEP'>DEP</option>
<option value='Dragon'>Dragon</option>
<option value='DRC'>DRC</option>
<option value='Dunlop'>Dunlop</option>
<option value='EKS Brand'>EKS Brand</option>
<option value='Engine Ice'>Engine Ice</option>
<option value='EVS'>EVS</option>
<option value='Factory Arme'>Factory Arme</option>
<option value='Factory Effex'>Factory Effex</option>
<option value='Fly Racing'>Fly Racing</option>
<option value='Forcefield Armour'>Forcefield Armour</option>
<option value='Forma'>Forma</option>
<option value='Fro Systems'>Fro Systems</option>
<option value='Gaerne'>Gaerne</option>
<option value='Goldentyre'>Goldentyre</option>
<option value='GoPole'>GoPole</option>
<option value='GoPro'>GoPro</option>
<option value='HiFlo Filtro'>HiFlo Filtro</option>
<option value='JT Braking'>JT Braking</option>
<option value='K-Edge'>K-Edge</option>
<option value='Kryptonite'>Kryptonite</option>
<option value='Lazer'>Lazer</option>
<option value='Leatt'>Leatt</option>
<option value='Matrix Concepts'>Matrix Concepts</option>
<option value='Mechanix Wear'>Mechanix Wear</option>
<option value='Motion Pro'>Motion Pro</option>
<option value='Motorex'>Motorex</option>
<option value='Muc Off'>Muc Off</option>
<option value='No Toil'>No Toil</option>
<option value='Oakley'>Oakley</option>
<option value='ODI Troy Lee'>ODI Troy Lee</option>
<option value='Ogio'>Ogio</option>
<option value='One Industries'>One Industries</option>
<option value='Park Tool'>Park Tool</option>
<option value='POD'>POD</option>
<option value='Polisport'>Polisport</option>
<option value='Pro Clean'>Pro Clean</option>
<option value='Progrip'>Progrip</option>
<option value='Putoline'>Putoline</option>
<option value='Race FX'>Race FX</option>
<option value='Raptor Titanium'>Raptor Titanium</option>
<option value='Renthal'>Renthal</option>
<option value='Rip n Roll'>Rip n Roll</option>
<option value='Risk Racing'>Risk Racing</option>
<option value='RK Chains'>RK Chains</option>
<option value='SBS Brakes'>SBS Brakes</option>
<option value='Science in Sport'>Science in Sport</option>
<option value='Scott'>Scott</option>
<option value='Seven'>Seven</option>
<option value='Shoei'>Shoei</option>
<option value='Shot'>Shot</option>
<option value='Sidi'>Sidi</option>
<option value='SixSixOne'>SixSixOne</option>
<option value='SM Pro Platinum'>SM Pro Platinum</option>
<option value='Smith'>Smith</option>
<option value='Spada'>Spada</option>
<option value='Sunline'>Sunline</option>
<option value='Suomy'>Suomy</option>
<option value='THH'>THH</option>
<option value='Thor'>Thor</option>
<option value='Troy Lee Designs'>Troy Lee Designs</option>
<option value='Twin Air'>Twin Air</option>
<option value='Venhill'>Venhill</option>
<option value='VP Racing'>VP Racing</option>
<option value='Wizard Wash'>Wizard Wash</option>
<option value='Yoshimura'>Yoshimura</option>
<option value='Zeta'>Zeta</option>
</select>
<input id='contactBtn' type='submit' name='submit' value='Submit Product' tabindex='7' />
</form>
</section>";
My PHP code:
if (!$_POST['productName'] | !$_POST['prodImgCat'] | !$_POST['shortDesc'] | !$_POST['longDesc'] | !$_POST['price'] | !$_POST['catagory'] | !$_POST['subCat'] | !$_POST['brand']){
die('You did not complete all of the required fields! Try Again?');
}
$productName = $_POST['productName'];
$prodImgCat = $_POST['prodImgCat'];
$shortDesc = $_POST['shortDesc'];
$longDesc = $_POST['longDesc'];
$price = $_POST['price'];
$catagory = $_POST['catagory'];
$subCat = $_POST['subCat'];
$brand= $_POST['brand'];
$allowedExts = array("gif", "jpeg", "jpg", "png");
$temp = explode(".", $_FILES["productImg"]["name"]);
$extension = end($temp);
if ((($_FILES["productImg"]["type"] == "image/gif")|| ($_FILES["productImg"]["type"] == "image/jpeg")|| ($_FILES["productImg"]["type"] == "image/jpg")|| ($_FILES["productImg"]["type"] == "image/pjpeg")|| ($_FILES["productImg"]["type"] == "image/x-png")|| ($_FILES["productImg"]["type"] == "image/png"))&& ($_FILES["productImg"]["size"] < 200000)&& in_array($extension, $allowedExts)){
if ($_FILES["productImg"]["error"] > 0){
echo "Return Code: " . $_FILES["productImg"]["error"] . "<br>";
}else{
echo "Upload: " . $_FILES["productImg"]["name"] . "<br>";
echo "Type: " . $_FILES["productImg"]["type"] . "<br>";
echo "Size: " . ($_FILES["productImg"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["productImg"]["tmp_name"] . "<br>";
if (file_exists("/public_html/pages/CMX/images/products/".$_POST['prodImgCat'].$_FILES['productImg']['name']."")){
echo $_FILES['productImg']['name']." already exists.";
}else{
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LINE 875 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
move_uploaded_file($_FILES['productImg']['tmp_name'], "/public_html/pages/CMX/images/products/".$_POST['prodImgCat'].$_FILES['productImg']['name']);
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo "Stored in: "."/public_html/pages/CMX/images/products/".$_POST['prodImgCat'].$_FILES['productImg']['name']." <a href='http://www.littlepenguindesigns.co.uk/pages/CMX/pages/userAccount.php'>Upload another?</a> or <a href='http://www.littlepenguindesigns.co.uk/pages/CMX/pages/index.php'>Go home?</a>";
}
}
}else{
echo "Invalid file";
}
$productImgLocation = "".$_POST['prodImgCat']."".$_FILES['productImg']['name']."";
$insertProduct = ("INSERT INTO product (productName, productImg, shortDesc, longDesc, price, catagory, subCat, brand) VALUES ('".$_POST['productName']."', '".$productImgLocation."' '".$_POST['shortDesc']."', '".$_POST['longDesc']."', '".$_POST['price']."', '".$_POST['catagory']."', '".$_POST['subCat']."', '".$_POST['brand']."')");
$add_product = mysqli_query($con,$insertProduct);
mysqli_close($con);
So after all of that my question is this, what the flaming heck am I doing wrong here?, the file and directory are there and yet it doesn't want to move from the tmp folder to the chosen folder, please help as this is really starting to annoy me.
NOTE: My injection,etc. code is going to amended once i have completed the upload form, so please refrain from just posting about injections and the like, thank you.

Related

Performing AJAX search on mysql database using dropdown menus and text input

I work for a group of realtors that have tasked me with designing a property search for their website. I acquired the proper credentials to an IDX feed to grab property information that I then import into my MySQL database and am having trouble grabing specific columns based on the search query. I have only been able to return all fields instead of the ones specified in the search. I have limited knowledge about php, MySQL, mysqli, pdo, ajax, etc. and eventhough the code I am providing is based on AJAX, I am open to any solution that works. Obviously, I am a new user/coder and am happy to add anything I forgot to add. Thank you for taking the time to help me with this problem. I included the html and the separate php file
<!DOCTYPE html>
<html>
<head>
<script>
function showUser(str) {
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("POST","getuser.php?q="+str,true);
xmlhttp.send();
}
}
</script>
</head>
<body>
<form id="fs_quicksearch" name="fs_quicksearch">
<div class="form-container">
<div class="form-row form-row-loc">
<div class="form-left2">
<label>Location:</label>
</div>
<div class="form-right">
<select class="dd-form-long" id="City"
name="City" onchange="showUser(this.value)">
<option value="">
Any City
</option>
<option value="Auburn">
Auburn
</option>
<option value="Baldwin City">
Baldwin City
</option>
<option value="Basehor">
Basehor
</option>
<option value="Berryton">
Berryton
</option>
<option value="Bonner Springs">
Bonner Springs
</option>
<option value="Carbondale">
Carbondale
</option>
<option value="DeSoto">
DeSoto
</option>
<option value="Effingham">
Effingham
</option>
<option value="Eudora">
Eudora
</option>
<option value="Kansas City">
Kansas City
</option>
<option value="Kanwaka Twp">
Kanwaka Twp
</option>
<option value="Lawrence">
Lawrence
</option>
<option value="Leavenworth">
Leavenworth
</option>
<option value="Lecompton">
Lecompton
</option>
<option value="Lenexa">
Lenexa
</option>
<option value="Linwood">
Linwood
</option>
<option value="Louisburg">
Louisburg
</option>
<option value="McLouth">
McLouth
</option>
<option value="Meriden">
Meriden
</option>
<option value="Nortonville">
Nortonville
</option>
<option value="Osage City">
Osage City
</option>
<option value="Oskaloosa">
Oskaloosa
</option>
<option value="Ottawa">
Ottawa
</option>
<option value="Overbrook">
Overbrook
</option>
<option value="Overland Park">
Overland Park
</option>
<option value="Ozawkie">
Ozawkie
</option>
<option value="Paola">
Paola
</option>
<option value="Parker">
Parker
</option>
<option value="Perry">
Perry
</option>
<option value="Pomona">
Pomona
</option>
<option value="Shawnee">
Shawnee
</option>
<option value="Tecumseh">
Tecumseh
</option>
<option value="Tonganoxie">
Tonganoxie
</option>
<option value="Topeka">
Topeka
</option>
<option value="Turner">
Turner
</option>
<option value="Valley Falls">
Valley Falls
</option>
<option value="Wakarusa">
Wakarusa
</option>
<option value="Wellsville">
Wellsville
</option>
<option value="Winchester">
Winchester
</option>
</select><select size="20">
</select><input type="text">
<div>
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="form-left">
<label>Price:</label> <select class=
"dd-form-short" id="AskPrice1" name="AskPrice1"
onchange="showUser(this.value)">
<option value="">
Min Price
</option>
<option value="25000">
$25,000
</option>
<option value="50000">
$50,000
</option>
<option value="75000">
$75,000
</option>
<option value="100000">
$100,000
</option>
<option value="125000">
$125,000
</option>
<option value="150000">
$150,000
</option>
<option value="175000">
$175,000
</option>
<option value="200000">
$200,000
</option>
<option value="225000">
$225,000
</option>
<option value="250000">
$250,000
</option>
<option value="275000">
$275,000
</option>
<option value="300000">
$300,000
</option>
<option value="325000">
$325,000
</option>
<option value="350000">
$350,000
</option>
<option value="375000">
$375,000
</option>
<option value="400000">
$400,000
</option>
<option value="425000">
$425,000
</option>
<option value="450000">
$450,000
</option>
<option value="475000">
$475,000
</option>
<option value="500000">
$500,000
</option>
<option value="550000">
$550,000
</option>
<option value="600000">
$600,000
</option>
<option value="650000">
$650,000
</option>
<option value="700000">
$700,000
</option>
<option value="750000">
$750,000
</option>
<option value="800000">
$800,000
</option>
<option value="850000">
$850,000
</option>
<option value="900000">
$900,000
</option>
<option value="950000">
$950,000
</option>
<option value="1000000">
$1,000,000
</option>
</select>
</div>
<div class="form-right">
<label>To:</label> <select class=
"dd-form-short" id="AskPrice2" name="AskPrice2"
onchange="showUser(this.value)">
<option value="">
Max Price
</option>
<option value="25000">
$25,000
</option>
<option value="50000">
$50,000
</option>
<option value="75000">
$75,000
</option>
<option value="100000">
$100,000
</option>
<option value="125000">
$125,000
</option>
<option value="150000">
$150,000
</option>
<option value="175000">
$175,000
</option>
<option value="200000">
$200,000
</option>
<option value="225000">
$225,000
</option>
<option value="250000">
$250,000
</option>
<option value="275000">
$275,000
</option>
<option value="300000">
$300,000
</option>
<option value="325000">
$325,000
</option>
<option value="350000">
$350,000
</option>
<option value="375000">
$375,000
</option>
<option value="400000">
$400,000
</option>
<option value="425000">
$425,000
</option>
<option value="450000">
$450,000
</option>
<option value="475000">
$475,000
</option>
<option value="500000">
$500,000
</option>
<option value="550000">
$550,000
</option>
<option value="600000">
$600,000
</option>
<option value="650000">
$650,000
</option>
<option value="700000">
$700,000
</option>
<option value="750000">
$750,000
</option>
<option value="800000">
$800,000
</option>
<option value="850000">
$850,000
</option>
<option value="900000">
$900,000
</option>
<option value="950000">
$950,000
</option>
<option value="1000000">
$1,000,000
</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-left">
<label>Beds:</label> <select class=
"dd-form-short" id="Beds" name="Beds" onchange=
"showUser(this.value)">
<option value="">
Any #
</option>
<option value="1">
1 or more
</option>
<option value="2">
2 or more
</option>
<option value="3">
3 or more
</option>
<option value="4">
4 or more
</option>
<option value="5">
5 or more
</option>
<option value="6">
6 or more
</option>
</select>
</div>
<div class="form-right">
<label>Baths:</label> <select class=
"dd-form-short" id="Baths" name="Baths"
onchange="showUser(this.value)">
<option value="">
Any #
</option>
<option value="1">
1 or more
</option>
<option value="2">
2 or more
</option>
<option value="3">
3 or more
</option>
<option value="4">
4 or more
</option>
<option value="5">
5 or more
</option>
</select>
</div>
</div>
<div class="form-row">
<div class="form-left">
<label>Sq.Ft.:</label> <select class=
"dd-form-short" id="TotSQFT" name="TotSQFT"
onchange="showUser(this.value)">
<option value="">
Min SqFt
</option>
<option value="500">
Min 500
</option>
<option value="1000">
Min 1000
</option>
<option value="1500">
Min 1500
</option>
<option value="2000">
Min 2000
</option>
<option value="2500">
Min 2500
</option>
<option value="3000">
Min 3000
</option>
<option value="3500">
Min 3500
</option>
<option value="4000">
Min 4000
</option>
<option value="4500">
Min 4500
</option>
<option value="5000">
Min 5000
</option>
<option value="6000">
Min 6000
</option>
<option value="7000">
Min 7000
</option>
</select>
</div>
<div class="form-right">
<label>MLS#:</label> <input class=
"form-field-short" id="MLSNo" name="MLSNo"
onchange="showUser(this.value)" type="text">
</div>
</div>
<div class="form-row">
<input alt="Lawrence" class="search-button" id=
"Submit" name="Submit" value="Submit">
</div>
</div>
</form>
</div>
</div>
<div id="txtHint">
<b>Property Info Will Be Listed Here...</b>
</div>
</body>
</html>
-----------Now My GetUser.php----------------
<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, td, th {
border: 1px solid black;
padding: 5px;
}
th {text-align: left;}
</style>
<title></title>
</head>
<body>
<?php
$q = intval($_POST['q']);
$con = mysqli_connect('localhost','root','pw','properties');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"properties");
$sql= (need help here-table called `listings`) or die(mysql_error());
$result = mysqli_query($con,$sql);
echo "<table>
<tr>
<th>Address</th>
<th>City</th>
<th>Zip</th>
<th>Beds</th>
<th>Baths</th>
<th>AskPrice</th>
<th>MLSNo</th>
<th>TotSQFT</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['Address'] . "</td>";
echo "<td>" . $row['City'] . "</td>";
echo "<td>" . $row['Zip'] . "</td>";
echo "<td>" . $row['Beds'] . "</td>";
echo "<td>" . $row['Baths'] . "</td>";
echo "<td>" . $row['AskPrice'] . "</td>";
echo "<td>" . $row['MLSNo'] . "</td>";
echo "<td>" . $row['TotSQFT'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
Something like this should be the solution. Because of the potential number of variables, the code to build the SQL ended up being fairly complicated. Apologies if there are any errors in there, I haven't got the tools to do any sort of testing available to me at the moment. But hopefully you see the pattern where we build up the WHERE clause of the SQL based on whether the user chose a value for each parameter or not (if they didn't, we allow any value in that column, so no need for a WHERE restriction on it)
The javascript submits the entire form via ajax (using jQuery's ajax functions, which are much easier to use than the raw XmlHTTP object) when the user clicks the "submit" button. I've done some very rudimentary validation, just to ensure the user selects at least one option to restrict the query, otherwise you could end up with a query just selecting everything from the database, which might be problematic.
Firstly, your HTML page:
<!DOCTYPE html>
<html>
<head>
<script type="Text/JavaScript" src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<script type="text/javascript" language="javascript">
$(function() {
//adds an event listener to handle the form's "submit" event
$("#fs_quicksearch").submit(function(event) {
event.preventDefault(); //prevent the default postback behaviour
//make ajax request to the server
$.ajax({
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
dataType: 'text/html',
type: 'POST',
url: 'getuser.php',
data: $(this).serialize(), //automatically picks up all the form fields and translates them into a valid format for a POST request
success: function(response) { //runs when the request succeeeds (no HTTP errors)
$("#divResults").html(response);
},
error: function (jQXHR, textStatus, errorThrown) { //runs when the request fails with a HTTP error
alert("An error occurred whilst trying to contact the server: " + jQXHR.status + " " + textStatus + " " + errorThrown);
}
});
});
</script>
</head>
<body>
<form id="fs_quicksearch" name="fs_quicksearch">
<div class="form-container">
<div class="form-row form-row-loc">
<label for="City">Location:</label>
<select class="dd-form-long" id="City" name="City">
<option value="">Any City</option>
<option value="Auburn">Auburn</option>
<option value="Baldwin City">Baldwin City</option>
<option value="Basehor">Basehor</option>
<option value="Berryton">Berryton</option>
...rest of your options here
</select>
</div>
<div class="form-row">
<div class="form-left">
<label for="AskPrice1">Price:</label>
<select class="dd-form-short" id="AskPrice1" name="AskPrice1">
<option value="">Min Price</option>
<option value="25000">$25,000</option>
<option value="50000">$50,000</option>
...rest of your options here
</select>
</div>
<div class="form-right">
<label for="AskPrice2">To:</label>
<select class="dd-form-short" id="AskPrice2" name="AskPrice2">
<option value="">Max Price</option>
<option value="25000">$25,000</option>
<option value="50000">$50,000</option>
...rest of your options here
</select>
</div>
</div>
<div class="form-row">
<div class="form-left">
<label for="Beds">Beds:</label>
<select class="dd-form-short" id="Beds" name="Beds">
<option value="">Any #</option>
<option value="1">1 or more</option>
<option value="2">2 or more</option>
...rest of your options here
</select>
</div>
<div class="form-right">
<label for="Baths">Baths:</label>
<select class="dd-form-short" id="Baths" name="Baths">
<option value="">Any #</option>
<option value="1">1 or more</option>
<option value="2">2 or more</option>
...rest of your options here
</select>
</div>
</div>
<div class="form-row">
<div class="form-left">
<label for="TotSQFT">Sq.Ft.:</label>
<select class="dd-form-short" id="TotSQFT" name="TotSQFT">
<option value="">Min SqFt</option>
<option value="500">Min 500</option>
<option value="1000">Min 1000</option>
<option value="1500">Min 1500</option>
...rest of your options here
</select>
</div>
<div class="form-right">
<label for="MLSNo">MLS#:</label>
<input class="form-field-short" id="MLSNo" name="MLSNo" type="text">
</div>
</div>
<div class="form-row">
<input alt="Lawrence" class="search-button" id="Submit" value="Submit">
</div>
</div>
</form>
<br/>
<div id="divResults">
<b>Property Info Will Be Listed Here...</b>
</div>
</body>
Secondly, the PHP (there's no need for any of the raw HTML you had in getuser, you only want to return the table snippet, which will get added to the rest of the first page):
<?php
$city = $_POST['City'];
$askprice1 = $_POST['AskPrice1'];
$askprice2 = $_POST['AskPrice2'];
$beds = $_POST['Beds'];
$baths = $_POST['Baths'];
$totsqft = $_POST['TotSQFT'];
$mlsno = $_POST['MLSNo'];
//this is just some very crude validation, you should probably make it more sophisticated
if ($city == "" && $askprice1 == "" && $askprice2 == "" && $beds == "" && $baths == "" && $totsqft == "" && $mlsno == "")
{
echo "Validation error: Please choose at least one option";
}
else
{
$con = mysqli_connect('localhost','root','pw','properties');
if (mysqli_connect_errno())
{
echo "Failed to connect: " . mysqli_connect_error();
}
mysqli_select_db($con, "properties") or die('ERROR! Could not select database');
//build the sql based on what the user selected
$sql = "select * from `listings` where ";
$paramArr = array(); //will contain the query parameters.
$paramTypes = ""; //will indicate the data type of each parameter
$sqlwhere = "";
if ($city != "") { $sqlwhere .= " City = ?"; $paramArr[] = $city; $paramTypes .= "s";}
if ($askPrice1 != "") { $sqlwhere .= ($sqlwhere == "" ? "" : " and ")." AskPrice >= ?"; $paramArr[] = &$askPrice1; $paramTypes .= "i";}
if ($askPrice2 != "") { $sqlwhere .= ($sqlwhere == "" ? "" : " and ")." AskPrice <= ?"; $paramArr[] = &$askPrice2; $paramTypes .= "i";}
if ($beds != "") { $sqlwhere .= ($sqlwhere == "" ? "" : " and ")." Beds >= ?"; $paramArr[] = &$beds; $paramTypes .= "i";}
if ($baths != "") { $sqlwhere .= ($sqlwhere == "" ? "" : " and ")." Baths >= ?"; $paramArr[] = &$baths; $paramTypes .= "i";}
if ($totsqft != "") { $sqlwhere .= ($sqlwhere == "" ? "" : " and ")." TotSQFT >= ?"; $paramArr[] = &$totsqft; $paramTypes .= "i";}
if ($mlsno != "") { $sqlwhere .= ($sqlwhere == "" ? "" : " and ")." MLSNo = ?"; $paramArr[] = &$mlsno; $paramTypes .= "s";} //if the MLSNo column in the DB is actually an integer, you'll need to change "s" to "i" here
$sql .= $sqlwhere;
$initialParams = array(&$stmt, &$paramTypes);
$callbackParams = array_merge($initialParams, $paramArr);
$statement = mysqli_prepare($con, $sql); //use prepared statements to guard against SQL injection
call_user_func_array("mysqli_stmt_bind_param", $callbackParams)); //bind the parameters to the statement
$result = mysqli_query($con, $sql) or die(mysqli_error($con));
echo "<table>
<tr>
<th>Address</th>
<th>City</th>
<th>Zip</th>
<th>Beds</th>
<th>Baths</th>
<th>AskPrice</th>
<th>MLSNo</th>
<th>TotSQFT</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['Address'] . "</td>";
echo "<td>" . $row['City'] . "</td>";
echo "<td>" . $row['Zip'] . "</td>";
echo "<td>" . $row['Beds'] . "</td>";
echo "<td>" . $row['Baths'] . "</td>";
echo "<td>" . $row['AskPrice'] . "</td>";
echo "<td>" . $row['MLSNo'] . "</td>";
echo "<td>" . $row['TotSQFT'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
}
?>
Lastly, one other small recommendation: Don't use the "root" account to log in to mysql from your web application. It can do anything, and you run a small risk that a malicious user could either steal the credentials, or manage to otherwise inject some malicious sql and then destroy your server, or steal data from your app. Set up a user specifically for this app, and give it permission only to the tables, procedures etc that it actually needs. That way you minimise the risk. I've used mysqli prepared statements as well which also minimises the risk of sql injection in the first place.

keeping values in drop down lists after form submittion

I am trying to retain the value which is selected in my drop down list, I am currently using:
<?php if ($_POST['day']==1) {echo "selected='selected'"; } ?>
to achieve this, I am just wondering if there is a more effective way of doing this because in my day drop down list I have 32 values including default, month 13 including default and year 51 including default. any suggestions would be appreciated.
Use a for loop.
For example, using a month with 31 days:
for($i=1; $i<32; $i++){
echo "<option value='$i'".($i==$_POST["day"] ? " selected" : null).">$i</option>";
}
If $_POST["day"]==1, this will output:
<option value='1' selected>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
Completed:
//Days
echo "<select name='day'><option value='default' disabled>Select a day</option>";
for($i=1; $i<32; $i++){
echo "<option value='$i'".($i==$_POST["day"] ? " selected" : null).">$i</option>";
}
echo "</select>";
//Months
echo "<select name='month'><option value='default' disabled>Select a month</option>";
for($i=0; $i<30; $i++){
echo "<option value='$i'".($i==$_POST["month"] ? " selected" : null).">$i</option>";
}
echo "</select>";
//Years
echo "<select name='year'><option value='default' disabled>Select a year</option>";
for($i=2016; $i<2056; $i++){
echo "<option value='$i'".($i==$_POST["year"] ? " selected" : null).">$i</option>";
}
echo "</select>";

header(Location) not working [duplicate]

This question already has answers here:
How to fix "Headers already sent" error in PHP
(11 answers)
Closed 9 years ago.
I'm aware of the fact that for header(Location) to work, no output must be sent before. The problem is that I've checked my code so many times but can't find what is actually being sent as output, thus preventing my header(Location) from working.
Can anyone spot the error?
<div id="content">
<h2>Lägg till</h2>
<p>Fyll i fälten och klicka på Lägg till för att skapa en ny kontakt i listan.</p>
<?php
$editid = $_GET['contact_id'];
$query = "SELECT *, Persons.p_id FROM Persons INNER JOIN Pictures ON (Pictures.p_id = Persons.p_id) WHERE Persons.p_id = " . $editid;
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$name = $row['name'];
$address = $row['address'];
$birthday = $row['birthday'];
$picture = $row['source'];
$p_id = $row['p_id'];
}
?>
<form action="" id="addressForm" method="post">
<ul>
<li><label for="name"><strong>Namn</strong></label><input type="text" name="name" id="name"/></li>
<li><label for="address"><strong>Adress</strong></label><input type="text" name="address" id="address"/></li>
<li><label for="year"><strong>Födelsedag</strong></label>
<select id="year" name="year">
<option value="2013">2013</option>
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
<option value="2009">2009</option>
<option value="2008">2008</option>
<option value="2007">2007</option>
<option value="2006">2006</option>
<option value="2005">2005</option>
<option value="2004">2004</option>
<option value="2003">2003</option>
<option value="2002">2002</option>
<option value="2001">2001</option>
<option value="2000">2000</option>
<option value="1999">1999</option>
<option value="1998">1998</option>
<option value="1997">1997</option>
<option value="1996">1996</option>
<option value="1995">1995</option>
<option value="1994">1994</option>
<option value="1993">1993</option>
<option value="1992">1992</option>
<option value="1991">1991</option>
<option value="1990">1990</option>
</select>
<select name="month">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
</select>
<select name="day">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
<option value='11'>11</option>
<option value='12'>12</option>
<option value='13'>13</option>
<option value='14'>14</option>
<option value='15'>15</option>
<option value='16'>16</option>
<option value='17'>17</option>
<option value='18'>18</option>
<option value='19'>19</option>
<option value='20'>20</option>
<option value='21'>21</option>
<option value='22'>22</option>
<option value='23'>23</option>
<option value='24'>24</option>
<option value='25'>25</option>
<option value='26'>26</option>
<option value='27'>27</option>
<option value='28'>28</option>
<option value='29'>29</option>
<option value='30'>30</option>
<option value='31'>31</option>
</select>
</li>
<li><label for="picture"><strong>Bild (URL)</strong></label><input type="text" name="picture" id="picture"/></li>
<li><input type="submit" id="submit" name="submit" value="Lägg till"/></li>
</ul>
</form>
<?php
if(isset ($_POST['submit']))
{
$editname = mysql_real_escape_string(htmlspecialchars($_POST['name']));
$editaddress = mysql_real_escape_string(htmlspecialchars($_POST['address']));
$editpicture = mysql_real_escape_string(htmlspecialchars($_POST['picture']));
$year = $_POST['year'];
$month = $_POST['month'];
$day = $_POST['day'];
if ($month < 10)
{
$month = "0$month";
}
if ($day < 10)
{
$day = "0$day";
}
$editbirthday = $year . "-" . $month . "-" . $day;
if (!empty($name) && !empty($address)){
$update = "UPDATE Persons SET name = '$editname', address = '$editaddress', birthday = '$editbirthday' WHERE p_id = '$editid'";
$result = mysql_query($update);
$query = "SELECT * FROM Persons WHERE p_id = '$editid' LIMIT 1";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$p_id = $row['p_id'];
$update = "UPDATE Pictures SET source = '$editpicture' WHERE p_id = '$editid'";
$result = mysql_query($update);
header('Location: index.php');
}
}
}
?>
</div>
Remember that an output could be:
Whitespace before <?php or after ?>
UTF-8 Byte Order Mark
Error messages or notices
print, echo
Raw <html> areas before <?php code.
So you're hitting the final point of this list...
You must put the header ABOVE any HTML output. You can just put it at the top of your document in this case. So just put all the PHP at the top.
Put the whole if statement from the following, to the top of the PHP file. I don't think this will cause any issues.
if(isset ($_POST['submit']))
I hope this helps
You already have output. Headers MUST be set before any output is sent.
"Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP."
Refer to the documentation about it. Hope this helps.
no output
no whitespace
save file without BOM

How do i edit registered users information via PHP and MySQL?

Am not sure how to ask this question but for most of you more experienced php programmers this is going to sound trivial... So I have successfully set up a register and login system and also an admin section where the administrator can see all the users that are currently registered. What I am wanting is for the admin to be able to edit the user's details, and also have the capability to delete/block them. Actually I have just successfully implemented a delete function.
This code here is of the page where the admin can see the users:
<?php
require('admin_sessions.php');
require("../includes/dbconnect.php");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Admin - iTrade Users Details</title>
<meta name="robots" content="NOFOLLOW,NOINDEX">
<link rel="stylesheet" href="../stylesheet.css" type="text/css">
<!--[if IE 7]>
<link rel="stylesheet" href="../ie7.css" type="text/css">
<script type="text/javascript">
document.createElement('nav');
document.createElement('article');
document.createElement('aside');
document.createElement('header');
document.createElement('footer');
</script>
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" href="../ie8.css" type="text/css">
<script type="text/javascript">
document.createElement('nav');
document.createElement('article');
document.createElement('aside');
document.createElement('header');
document.createElement('footer');
</script>
<![endif]-->
<style type="text/css">
table{
border:1px solid black;
width:2508px;
}
table th{
border-bottom:1px solid black;
border-left:1px solid black;
border-top:1px solid black;
border-right:1px solid black;
}
.header_tables{
background-color:black;
color:white;
text-align:center
}
</style>
</head>
<body>
<header style="width:2570px;"><span class="header_img"><img src="../img/itradeheader.png" width="465" height="200" alt="iTrade - The Leading Online Trading Portal"></span></header>
<nav style="width:2470px;">
<ul>
<li><p>Home</p></li>
<li><p>About iTrade</p></li>
<li><p>Browse Auctions</p></li>
<li><p>F.A.Q's</p></li>
<li><p>Support</p></li>
<?php if($_SESSION['authorisation'] != 'knownuser'){
echo("<li class=\"spacer\"><p class=\"loginlogoutregister\">User Log In</p></li><li><p class=\"loginlogoutregister\">User Register</p></li>");
}
else{
echo("<li class=\"spacer\"><p class=\"loginlogoutregister\">User Logout</p></li>");
$loggedin = "<p>You are logged in.</p>";
}
if($_SESSION['authorisation'] != 'known_admin_user'){
echo("<li><p class=\"loginlogoutregister\">Admin</p></li>");
}
else{
echo("<li><p class=\"loginlogoutregister\">Admin</p></li><li><p class=\"loginlogoutregister\">Admin Logout</p></li>");
}
?>
</ul>
</nav>
<article style="width:2550px; height:100%;">
<h1>Admin - iTrade Users Details</h1>
<p>« Back to main admin page</p>
<ul>
<li>Users on iTrade</li>
<li>Admin Users on iTrade</li>
<li>Register a New Admin User</li>
</ul>
<p>Here is a table containing details about the currently registered users on iTrade:</p>
<fieldset style="width:2480px; height:100%; margin:0 auto;">
<legend style="font-size:30px; color:#000000; background-color:inherit;">A record of users on iTrade</legend>
<table>
<tr class="header_tables">
<th><u>User I.D</u></th>
<th><u>User Level</u></th>
<th><u>User-name</u></th>
<th><u>First Name</u></th>
<th><u>Last Name</u></th>
<th><u>Email</u></th>
<th><u>Password</u></th>
<th><u>Gender</u></th>
<th><u>Birthday</u></th>
<th><u>Landline Number</u></th>
<th><u>Mobile Number</u></th>
<th><u>Street Address</u></th>
<th><u>Suburb</u></th>
<th><u>City/Town</u></th>
<th><u>Province</u></th>
<th><u>Postcode</u></th>
<th><u>Closest Town</u></th>
<th><u>Confirmed?</u></th>
<th><u>Date Registered</u></th>
</tr>
<?php
$query = "SELECT * FROM user_list;";
$result = mysql_query($query, $connection) or die(mysql_error());
$users_on_itrade = " ";
while($row = mysql_fetch_array($result)){
echo("<tr>");
echo('<td>' . $row['user_id'] . '</td>');
echo('<td>' . $row['user_level'] . '</td>');
echo('<td>' . $row['user_username'] . '</td>');
echo('<td>' . $row['firstname'] . '</td>');
echo('<td>' . $row['lastname'] . '</td>');
echo('<td>' . $row['user_email'] . '</td>');
echo('<td>' . $row['user_pass'] . '</td>');
echo('<td>' . $row['gender']. '</td>');
echo('<td>' . $row['birthdate_day'] . $row['birthdate_month'] . $row['birthdate_year'] . '</td>');
echo('<td>' . $row['phoneNumber'] . '</td>');
echo('<td>' . $row['mobileNumber'] . '</td>');
echo('<td>' . $row['addressline1'] . '</td>');
echo('<td>' . $row['addressline2'] . '</td>');
echo('<td>' . $row['addressline3'] . '</td>');
echo('<td>' . $row['stateprovince'] . '</td>');
echo('<td>' . $row['postcode'] . '</td>');
echo('<td>' . $row['closest_town'] . '</td>');
echo('<td>' . $row['confirmed'] . '</td>');
echo('<td>' . $row['user_date'] . '</td>');
echo('<td>Edit</td>');
echo('<td>Delete</td>');
echo("<tr>");
}
?>
</table>
</fieldset>
</article>
<footer style="width:2550px;"><p>© Copyright 2011 iTrade LTD. Website design and development by InterKiwi Web Developers. Special thanks to the Computer Science department at the University of Otago, and the lecturers and lab administrators/demonstrators of the universities' Advanced Web Development paper.</p></footer>
</body>
</html>
This code is for the "edit" page link in "<td>Edit</td>":
<?php
require('admin_sessions.php');
require("../includes/dbconnect.php");
require('../includes/itradeuser.php');
?>
<?php
/*
This php script allows the administrator to edit a specific itrade user in the database.
*/
// creates the edit record form
// since this form is used multiple times in this file, I have made it a function that is easily reusable
function renderForm($user_id, $user_email, $user_pass, $user_pass_confirm, $user_username, $firstname, $lastname, $gender, $birthdate_day, $birthdate_month, $birthdate_year, $phoneNumber, $mobileNumber, $addressline1, $addressline2, $addressline3, $stateprovince, $postcode, $closest_town, $error)
{
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Edit Record</title>
</head>
<body>
<?php
// if there are any errors, display them
if ($error != '')
{
echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>';
}
?>
<form action="" method="post">
<input type="hidden" name="id" value="<?php echo $user_id; ?>"/>
<fieldset class="userdetails">
<legend>User Credentials</legend>
<p><strong>ID:</strong> <?php echo $user_id; ?></p>
<ul>
<li><label for="user_email">Email Address:</label><input name="user_email" maxlength="50" id="user_email" size="40" type="text" value="<?php echo $user_email; ?>"><br></li>
<li><label for="user_pass">Your Password:</label><input name="user_pass" maxlength="50" id="user_pass" size="30" type="password" value="<?php echo $user_pass; ?>"><br></li>
<li><label for="user_pass_confirm">Password Again:</label><input name="user_pass_confirm" maxlength="50" id="user_pass_confirm" size="30" type="password" value="<?php echo $user_pass_confirm; ?>"><br></li>
<li><label for="user_username">Your Username:</label><input name="user_username" maxlength="50" id="user_username" size="30" type="text" value="<?php echo $user_username; ?>"></li>
</ul>
</fieldset>
<fieldset>
<legend>Contact Details</legend>
<ul>
<li><label for="firstname">First Name:</label><input name="firstname" type="text" id="firstname" size="25" maxlength="200" value="<?php echo $firstname; ?>" /><br></li>
<li><label for="lastname">Last Name:</label><input name="lastname" type="text" id="lastname" size="25" maxlength="200" value="<?php echo $lastname; ?>" /><br></li>
<li><label for="gender">Gender:</label>
<select name="gender" id="gender">
<option selected="" value=""> </option>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="unspecified">Unspecified</option>
</select><br></li>
<li><label for"birthdate_day">Date of birth:</label>
<select name="birthdate_day" id="birthdate_day">
<option selected="selected" value=""></option>
<option value="1st">1</option>
<option value="2nd">2</option>
<option value="3rd">3</option>
<option value="4th">4</option>
<option value="5th">5</option>
<option value="6th">6</option>
<option value="7th">7</option>
<option value="8th">8</option>
<option value="9th">9</option>
<option value="10th">10</option>
<option value="11th">11</option>
<option value="12th">12</option>
<option value="13th">13</option>
<option value="14th">14</option>
<option value="15th">15</option>
<option value="16th">16</option>
<option value="17th">17</option>
<option value="18th">18</option>
<option value="19th">19</option>
<option value="20th">20</option>
<option value="21st">21</option>
<option value="22nd">22</option>
<option value="23rd">23</option>
<option value="24th">24</option>
<option value="25th">25</option>
<option value="26th">26</option>
<option value="27th">27</option>
<option value="28th">28</option>
<option value="29th">29</option>
<option value="30th">30</option>
<option value="31st">31</option>
</select>
<select name="birthdate_month" id="birthdate_month">
<option selected="selected" value=""></option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select><br></li>
<li><label for="birthdate_year">Birth Year:</label><input name="birthdate_year" type="number" maxlength="4" id="birthdate_year" size="4" value="<?php echo $birthdate_year; ?>"><br>
</li>
<li>
<label for="phoneNumber">Home Phone:</label>
<input name="phoneNumber" type="number" maxlength="9" id="phoneNumber" size="9" value="<?php echo $phoneNumber; ?>"><br></li>
<li><label for="mobileNumber">Mobile Number:</label>
<input name="mobileNumber" type="number" maxlength="11" id="mobileNumber" size="11" value="<?php echo $mobileNumber; ?>"><span class="informational">e.g: 0276123456</span><br></li>
<li><label for="addressline1">Street Address:</label>
<input name="addressline1" maxlength="100" id="addressline1" size="40" type="text" value="<?php echo $addressline1; ?>"><br></li>
<li><label for="addressline2">Suburb:</label>
<input name="addressline2" maxlength="100" id="addressline2" size="40" type="text" value="<?php echo $addressline2; ?>"><br></li>
<li><label for="addressline3">City:</label>
<input name="addressline3" maxlength="100" id="addressline3" size="40" type="text" value="<?php echo $addressline3; ?>"><br></li>
<li><label for="stateprovince">State/Province:</label>
<select name="stateprovince" id="stateprovince">
<option selected="selected" value="<?php echo $stateprovince; ?>"></option>
<option value="northland">Northland</option>
<option value="auckland">Auckland</option>
<option value="waikato">Waikato</option>
<option value="bayofplenty">Bay of Plenty</option>
<option value="eastcoast">East Coast</option>
<option value="hawkesbay">Hawkes Bay</option>
<option value="taranaki">Taranaki</option>
<option value="kingcountry">King Country</option>
<option value="wanganui">Wanganui</option>
<option value="manawatu">Manawatu</option>
<option value="wairarapa">Wairarapa</option>
<option value="wellington">Wellington</option>
<option value="nelsonbays">Nelson Bays</option>
<option value="marlborough">Marlborough</option>
<option value="buller">Buller</option>
<option value="westland">Westland</option>
<option value="northcanterbury">North Canterbury</option>
<option value="canterbury">Canterbury</option>
<option value="midcanterbury">Mid Canterbury</option>
<option value="southcanterbury">South Canterbury</option>
<option value="northotago">North Otago</option>
<option value="otago">Otago</option>
<option value="southland">Southland</option>
<option value="chathamisl">Chatham Islands</option>
</select><br></li>
<li><label for="postcode">Post Code:</label>
<input name="postcode" type="number" maxlength="4" id="postcode" size="4" value="<?php echo $postcode; ?>"><span class="informational">Find your post code</span><br></li>
<li><label for="closest_town">Closest Town:</label>
<select name="closest_town" id="closest_town">
<option selected="selected" value=""></option>
<option value="dargaville">Northland - Dargaville</option>
<option value="kaikohe">Northland - Kaikohe</option>
<option value="kaitaia">Northland - Kaitaia</option>
<option value="kawakawa">Northland - Kawakawa</option>
<option value="kerikeri">Northland - Kerikeri</option>
<option value="maungaturoto">Northland - Maungaturoto</option>
<option value="paihia">Northland - Paihia</option>
<option value="whangarei">Northland - Whangarei</option>
<option value="0"> </option>
<option value="aucklandcity">Auckland - Auckland City</option>
<option value="franklin">Auckland - Franklin</option>
<option value="greatbarrierisland">Auckland - Great Barrier Island</option>
<option value="helensville">Auckland - Helensville</option>
<option value="hibiscuscoast">Auckland - Hibiscus Coast</option>
<option value="manukaucity">Auckland - Manukau City</option>
<option value="northshore">Auckland - North Shore</option>
<option value="papakuracity">Auckland - Papakura City</option>
<option value="waihekeisl">Auckland - Waiheke Island</option>
<option value="waitakerecity">Auckland - Waitakere City</option>
<option value="warkworth">Auckland - Warkworth</option>
<option value="wellsford">Auckland - Wellsford</option>
<option value="0"> </option>
<option value="cambridge">Waikato - Cambridge</option>
<option value="coromandel">Waikato - Coromandel</option>
<option value="hamilton">Waikato - Hamilton</option>
<option value="huntly">Waikato - Huntly</option>
<option value="matamata">Waikato - Matamata</option>
<option value="morrinsville">Waikato - Morrinsville</option>
<option value="otorohanga">Waikato - Otorohanga</option>
<option value="paeroa">Waikato - Paeroa</option>
<option value="raglan">Waikato - Raglan</option>
<option value="taumarunui">Waikato - Taumarunui</option>
<option value="teawamutu">Waikato - Te Awamutu</option>
<option value="tekuiti">Waikato - Te Kuiti</option>
<option value="thames">Waikato - Thames</option>
<option value="tokoroa_putaruru">Waikato - Tokoroa/Putaruru</option>
<option value="waihi">Waikato - Waihi</option>
<option value="waihi_beach">Waikato - Waihi Beach</option>
<option value="whangamata">Waikato - Whangamata</option>
<option value="0"> </option>
<option value="katikati">Bay of Plenty - Katikati</option>
<option value="mt_maunganui">Bay of Plenty - Mt. Maunganui</option>
<option value="opotiki">Bay of Plenty - Opotiki</option>
<option value="rotorua">Bay of Plenty - Rotorua</option>
<option value="taupo">Bay of Plenty - Taupo</option>
<option value="tauranga">Bay of Plenty - Tauranga</option>
<option value="te_puke">Bay of Plenty - Te Puke</option>
<option value="turangi">Bay of Plenty - Turangi</option>
<option value="whakatane">Bay of Plenty - Whakatane</option>
<option value="0"> </option>
<option value="gisborne">Gisborne - Gisborne</option>
<option value="ruatoria">Gisborne - Ruatoria</option>
<option value="0"> </option>
<option value="dannevirke">Hawkes Bay - Dannevirke</option>
<option value="hastings">Hawkes Bay - Hastings</option>
<option value="napier">Hawkes Bay - Napier</option>
<option value="waipukurau">Hawkes Bay - Waipukurau</option>
<option value="wairoa">Hawkes Bay - Wairoa</option>
<option value="0"> </option>
<option value="hawera">Taranaki - Hawera</option>
<option value="mokau">Taranaki - Mokau</option>
<option value="new_plymouth">Taranaki - New Plymouth</option>
<option value="opunake">Taranaki - Opunake</option>
<option value="stratford">Taranaki - Stratford</option>
<option value="0"> </option>
<option value="ohakune">Wanganui - Ohakune</option>
<option value="taihape">Wanganui - Taihape</option>
<option value="waiouru">Wanganui - Waiouru</option>
<option value="wanganui">Wanganui - Wanganui</option>
<option value="0"> </option>
<option value="bulls">Manawatu - Bulls</option>
<option value="fielding">Manawatu - Feilding</option>
<option value="levin">Manawatu - Levin</option>
<option value="manawatu">Manawatu - Manawatu</option>
<option value="marton">Manawatu - Marton</option>
<option value="palmerston_north">Manawatu - Palmerston North</option>
<option value="0"> </option>
<option value="carterton">Wairarapa - Carterton</option>
<option value="featherston">Wairarapa - Featherston</option>
<option value="greytown">Wairarapa - Greytown</option>
<option value="martinborough">Wairarapa - Martinborough</option>
<option value="masterton">Wairarapa - Masterton</option>
<option value="paihiatua">Wairarapa - Pahiatua</option>
<option value="woodville">Wairarapa - Woodville</option>
<option value="0"> </option>
<option value="kapiti">Wellington - Kapiti</option>
<option value="lower_hutt">Wellington - Lower Hutt City</option>
<option value="porirua">Wellington - Porirua</option>
<option value="upper_hutt">Wellington - Upper Hutt City</option>
<option value="wellington">Wellington - Wellington City</option>
<option value="0"> </option>
<option value="golden_bay">Nelson Bays - Golden Bay</option>
<option value="motueka">Nelson Bays - Motueka</option>
<option value="murchison">Nelson Bays - Murchison</option>
<option value="nelson">Nelson Bays - Nelson</option>
<option value="picton">Nelson Bays - Picton</option>
<option value="0"> </option>
<option value="blenheim">Marlborough - Blenheim</option>
<option value="marlborough_sounds">Marlborough - Marlborough Sounds</option>
<option value="0"> </option>
<option value="greymouth">West Coast - Greymouth</option>
<option value="hokitika">West Coast - Hokitika</option>
<option value="westport">West Coast - Westport</option>
<option value="0"> </option>
<option value="akaroa">Canterbury - Akaroa</option>
<option value="amberley">Canterbury - Amberley</option>
<option value="ashburton">Canterbury - Ashburton</option>
<option value="cheviot">Canterbury - Cheviot</option>
<option value="christchurch">Canterbury - Christchurch City</option>
<option value="darfield">Canterbury - Darfield</option>
<option value="fairlie">Canterbury - Fairlie</option>
<option value="geraldine">Canterbury - Geraldine</option>
<option value="hamnersprings">Canterbury - Hanmer Springs</option>
<option value="kaiapoi">Canterbury - Kaiapoi</option>
<option value="kaikoura">Canterbury - Kaikoura</option>
<option value="mtcook">Canterbury - Mt Cook</option>
<option value="rangiora">Canterbury - Rangiora</option>
<option value="0"> </option>
<option value="timaru_oamaru_kurow">Timaru - Oamaru - Kurow</option>
<option value="timaru_oamaru_oamaru">Timaru - Oamaru - Oamaru</option>
<option value="timaru_oamaru_timaru">Timaru - Oamaru - Timaru</option>
<option value="timaru_oamaru_twizel">Timaru - Oamaru - Twizel</option>
<option value="timaru_oamaru_waimate">Timaru - Oamaru - Waimate</option>
<option value="0"> </option>
<option value="alexandra">Otago - Alexandra</option>
<option value="balclutha">Otago - Balclutha</option>
<option value="cromwell">Otago - Cromwell</option>
<option value="dunedin">Otago - Dunedin</option>
<option value="lawrence">Otago - Lawrence</option>
<option value="milton">Otago - Milton</option>
<option value="palmerston">Otago - Palmerston</option>
<option value="queenstown">Otago - Queenstown</option>
<option value="ranfurly">Otago - Ranfurly</option>
<option value="roxburgh">Otago - Roxburgh</option>
<option value="wanaka">Otago - Wanaka</option>
<option value="0"> </option>
<option value="bluff">Southland - Bluff</option>
<option value="edendale">Southland - Edendale</option>
<option value="gore">Southland - Gore</option>
<option value="invercargill">Southland - Invercargill</option>
<option value="lumsden">Southland - Lumsden</option>
<option value="otautau">Southland - Otautau</option>
<option value="riverton">Southland - Riverton</option>
<option value="stewart_island">Southland - Stewart Island</option>
<option value="te_anau">Southland - Te Anau</option>
<option value="tokanui">Southland - Tokanui</option>
<option value="winton">Southland - Winton</option>
<option value="0"> </option>
<option value="chathamisl">Chatham Islands</option>
</select><br></li>
</ul>
</fieldset>
<input type="submit" name="submit" value="Submit">
</div>
</form>
</body>
</html>
<?php
}
// check if the form has been submitted. If it has, process the form and save it to the database
if (isset($_POST['submit'])){
if (is_numeric($_POST['user_id'])){
// get form data, making sure it is valid
$user_id = $_POST['user_id'];
$user_email = mysql_real_escape_string($_POST['user_email']);
$user_pass = mysql_real_escape_string($_POST['user_pass']);
$user_pass_confirm = mysql_real_escape_string($_POST['user_pass_confirm']);
$user_username = mysql_real_escape_string($_POST['user_username']);
$firstname = mysql_real_escape_string($_POST['firstname']);
$lastname = mysql_real_escape_string($_POST['lastname']);
$gender = mysql_real_escape_string($_POST['gender']);//optional field
$birthdate_day = mysql_real_escape_string($_POST['birthdate_day']);
$birthdate_month = mysql_real_escape_string($_POST['birthdate_month']);
$birthdate_year = mysql_real_escape_string($_POST['birthdate_year']);
$phoneNumber = mysql_real_escape_string($_POST['phoneNumber']);
$mobileNumber = mysql_real_escape_string($_POST['mobileNumber']);
$addressline1 = mysql_real_escape_string($_POST['addressline1']);
$addressline2 = mysql_real_escape_string($_POST['addressline2']); // optional field
$addressline3 = mysql_real_escape_string($_POST['addressline3']);
$stateprovince = mysql_real_escape_string($_POST['stateprovince']);
$postcode = mysql_real_escape_string($_POST['postcode']); // optional field
$closest_town = mysql_real_escape_string($_POST['closest_town']); //optional field
$date = time();
// check that firstname/lastname fields are both filled in
if ($firstname == '' || $lastname == '' || $user_email =='' || $user_pass == '' || $user_pass_confirm == '' || $user_username == '' || $firstname =='' || $lastname == '' || $gender == '' || $birthdate_day == '' || $birthdate_month == '' || $birthdate_year == '' || $phoneNumber == '' || $mobileNumber == '' || $addressline1 == '' || $addressline2 == '' || $addressline3 == '' || $stateprovince == '' || $postcode == '' || $closest_town == ''){
// generate error message
$error = 'ERROR: Please fill in all required fields!';
//error, display form
renderForm($user_id, $user_email, $user_pass, $user_pass_confirm, $user_username, $firstname, $lastname, $gender, $birthdate_day, $birthdate_month, $birthdate_year, $phoneNumber, $mobileNumber, $addressline1, $addressline2, $addressline3, $stateprovince, $postcode, $closest_town, $error);
}
else{
// save the data to the database
mysql_query("UPDATE user_list SET user_email='$user_email', user_pass=sha1('$user_pass.$salt'), user_pass_confirm=sha1('$user_pass_confirm.$salt'), user_username='$user_username', firstname='$firstname', lastname='$lastname', gender='$gender', birthdate_day='$birthdate_day, birthdate_month='$birthdate_month', birthdate_year='$birthdate_year', phoneNumber='$phoneNumber', mobileNumber='$mobileNumber', addressline1='$addressline1', addressline2='$addressline2', addressline3='$addressline3', stateprovince='$stateprovince', postcode='$postcode', closest_town='$closest_town' WHERE user_id='$user_id'")
or die(mysql_error());
// once saved, redirect back to the view page
header("Location: itradeusers.php");
}
}
else
{
// if the 'id' isn't valid, display an error
echo 'Error! ID not valid.';
}
}
else
// if the form hasn't been submitted, get the data from the db and display the form
{
// get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) && $_GET['user_id'] > 0)
{
// query db
$user_id = $_GET['user_id'];
$result = mysql_query("SELECT * FROM user_list WHERE user_id=$user_id")
or die(mysql_error());
$row = mysql_fetch_array($result);
// check that the 'id' matches up with a row in the databse
if($row)
{
// get data from db
$user_id = $row['user_id'];
$user_email = $row['user_email'];
$user_pass = $row['user_pass'];
$user_pass_confirm = $row['user_pass_confirm'];
$user_username = $row['user_username'];
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$gender = $row['gender'];
$birthdate_day = $row['birthdate_day'];
$birthdate_month = $row['birthdate_month'];
$birthdate_year = $row['birthdate_year'];
$phoneNumber = $row['phoneNumber'];
$mobileNumber = $row['mobileNumber'];
$addressline1 = $row['addressline1'];
$addressline2 = $row['addressline2'];
$addressline3 = $row['addressline3'];
$stateprovince = $row['stateprovince'];
$postcode = $row['postcode'];
$closest_town = $row['closest_town'];
// show form
renderForm($user_id, $user_email, $user_pass, $user_pass_confirm, $user_username, $firstname, $lastname, $gender, $birthdate_day, $birthdate_month, $birthdate_year, $phoneNumber, $mobileNumber, $addressline1, $addressline2, $addressline3, $stateprovince, $postcode, $closest_town, $error);
}else
// if no match, display result
{
echo "No results!";
}
}
else
// if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
{
echo 'Error! the \'id\' is not valid.';
}
}
?>
If someone could tell me what I have done wrong, or even explain to me a better way of doing something like this, please let me know... Thanks in advance!
First of all, it looks like you're storing passwords in plain text. That is a big no no!
For updating user info have a look at the UPDATE command for mysql: http://dev.mysql.com/doc/refman/5.0/en/update.html
For the delete/block issue, you could add another column that stores the user status (deleted, blocked, active, etc). You could then check the status of this column when the user logs in or visits a page.

Signature generator with upload does not work

Hey, i just wanted to know if you guys know why this does not work.
http://www.anitard.org/siggen/siggen_stripes/
When you've uploaded an image the script gets the file path from the form and then when you press create a signature is supposed to appear with the image you uploaded, but it doesn't!
If anyone know what the problem is, please let me know.
this is my code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Signature Generator</title>
</head>
<body>
<div style="float:left; width: 280px; margin-right: 3px;">
<form name="frm" method="post">
<p></p>
<p>Enter Text:
<input name="user" type="text" size="20" class="textbox">
<br /><br />
<p> Color:
<select name="color2">
<option value="color_standard">Standard</option>
<option value="color_blue">Blue</option>
<option value="color_lightblue">Light blue</option>
<option value="color_red">Red</option>
<option value="color_yellow">Yellow</option>
<option value="color_green">Green</option>
<option value="color_purple">Purple</option>
</select>
<br /><br />
<i><font size="1" face="verdana">Choose if your going to use one of our "anime" pictures or upload your own image.</font></i>
<br />
<script type="text/javascript">
function annClick()
{
document.getElementById('butta').disabled = true;
document.getElementById('strup').disabled = true;
document.getElementById('namez').disabled = false;
}
function ownClick()
{
document.getElementById('butta').disabled = false;
document.getElementById('strup').disabled = false;
document.getElementById('namez').disabled = true;
}
</script>
<input type="radio" name="checktype" id="ann" onclick="javascript:annClick();" value="1"> Anime<br>
<input type="radio" name="checktype" id="own" onclick="javascript:ownClick();" value="2"> Upload<br>
<br />
<u>Anime</u><br />
<select name="anime" id="namez" size="9" disabled="true" onclick="document.getElementById( 'imgUpload' ).src=this.value+'.png';" />
<option value="hack_twillight">.hack//Legend of the Twilight Bracelet</option>
<option value="hack_roots">.hack//Roots</option>
<option value="hack_sign">.hack//SIGN</option>
<option value="07_ghost">07-Ghost</option>
<option value="12_kingdoms">12 kokuki ( 12 kingdoms )</option>
<option value="afro_samurai">Afro Samurai</option>
<option value="ah_my_goddess">Ah! My Goddess</option>
<option value="ai_yori_aoshi">Ai yori Aoshi</option>
<option value="ai_yori_aoshi_enishi">Ai yori Aoshi ~enishi~</option>
<option value="air_gear">Air Gear </option>
<option value="air_tv">Air TV</option>
<option value="aishiteru_ze_baby">Aishiteru ze Baby</option>
<option value="akagi">Akagi</option>
<option value="akikan">Akikan!</option>
<option value="allison_to_lillia">Allison to Lillia</option>
<option value="amaenaideyo">Amaenaideyo</option>
<option value="amaenaideyo_katsu">Amaenaideyo Katsu</option>
<option value="amatsuki">Amatsuki</option>
<option value="angel_heart">Angel heart</option>
<option value="angelic_layer">Angelic layer</option>
<option value="antique_bakery">Antique bakery</option>
<option value="aria_the_animation">ARIA The animation</option>
<option value="aria_the_natural">ARIA The natural</option>
<option value="aria_the_origination">ARIA The origination</option>
<option value="asu_no_yoichi">Asu no yoichi</option>
<option value="ayakashi">Ayakashi</option>
<option value="azumanga_daioh">Azumanga daioh</option>
<option value="baccano">Baccano</option>
<option value="bakuretsu_tenshi">Bakuretsu Tenshi</option>
<option value="bamboo_blade">Bamboo blade</option>
<option value="basilisk">Basilisk</option>
<option value="berserk">Berserk</option>
<option value="basquash">Basquash</option>
<option value="beck">Beck</option>
<option value="black_cat">Black Cat</option>
<option value="black_lagoon">Black Lagoon</option>
<option value="black_lagoon_the_second_barrage">Black Lagoon the second barrage</option>
<option value="bleach">Bleach</option>
<option value="blood">Blood+</option>
<option value="bokura_ga_ita">Bokura ga ita</option>
<option value="bokura_no">Bokura no</option>
<option value="bokusatsu_tenshi_dokuro_chan">Bokusatsu tenshi dokuro chan</option>
<option value="bokusatsu_tenshi_dokuro_chan_second.png">Bokusatsu tenshi dokuro chan 2</option>
<option value="bounen_no_xamd">Bounen no xamd</option>
<option value="busou_renkin">Busou renkin</option>
<option value="canvas2">Canvas 2</option>
<option value="capeta">Capeta</option>
<option value="card_captor_sakura">Card captor sakura</option>
<option value="casshern_sins">Casshern sins</option>
<option value="chaos_head">Chaos head</option>
<option value="chis_sweet_home">Chi's sweet home</option>
<option value="chobits">Chobits</option>
<option value="chocotto_sister">Choccotto_sister</option>
<option value="chrno_crusade">Chrno crusade</option>
<option value="clannad">Clannad</option>
<option value="claymore">Claymore</option>
<option value="cluster_edge">Cluster edge</option>
<option value="code_geass">Code geass</option>
<option value="code_geass_r2">Code geass R2</option>
<option value="cosplay_complex">Cosplay complex</option>
<option value="cowbow_bebop">Cowboy bebop</option>
<option value="crayon_shin_chan">Crayon shin chan</option>
<option value="cross_game">Cross game</option>
<option value="d_gray_man">D.Gray Man</option>
<option value="dn_angel">DN Angel</option>
<option value="da_capo">Da capo</option>
<option value="da_capo_ii">Da capo II</option>
<option value="darker_than_black">Darker than black</option>
<option value="dears">DearS</option>
<option value="death_note">Death note</option>
<option value="dennou_coil">Dennou coil</option>
<option value="desert_punk">Desert punk</option>
<option value="devil_may_cry">Devil may cry</option>
<option value="doujin_work">Doujin work</option>
<option value="dragon_ball">Dragon ball</option>
<option value="dragon_ball_gt">Dragon ball GT</option>
<option value="dragon_ball_z">Dragon ball Z</option>
<option value="dragonaut_the_resonance">Dragonaut -the resonance-</option>
<option value="fate_stay_night">Fate/stay night</option>
<option value="final_approach">Final approach</option>
<option value="flame_of_recca">Flame of recca</option>
<option value="flcl">FLCL</option>
<option value="fruits_basket">Fruits basket</option>
<option value="full_metal_panic">Full metal panic</option>
<option value="full_metal_panic_second_raid">Full metal panic secondn raid</option>
<option value="full_metal_panic_fumoffu">Full metal panic fumoffu</option>
<option value="full_moon_wo_sagashite">Full moon wo sagashite</option>
<option value="fullmetal_alchemist">Fullmetal alchemist</option>
<option value="fullmetal_alchemist_brotherhood">Fullmetal alchemist brotherhood</option>
<option value="fushigi_yuugi">Fushigi yuugi</option>
<option value="h20">H2O ~footprints in the sand~</option>
<option value="haibane_renmei">Haibane renmei</option>
<option value="hajime_no_ippo">Hajime no ippo</option>
<option value="hana_yori_dango">Hana yori dango</option>
<option value="hanasakeru_seishonen">Hanasakeru seishonen</option>
<option value="hanaukyo_maids">Hanaukyo maids</option>
<option value="hanaukyo_maids_le_verite">Hanaukyo maids le verite</option>
<option value="hanbun_no_tsukai">Hanbun no tsukai</option>
<option value="hand_maid_may">Hand maid may</option>
<option value="happiness">Happiness</option>
<option value="happy_lesson">Happy lesson</option>
<option value="hatsukoi_limited">Hatsukoi limited</option>
<option value="hayate_no_gotoku">Hayate no gotoku</option>
<option value="hayate_no_gotoky_2">Hayate no gotoku 2</option>
<option value="he_is_my_master">He is my master</option>
<option value="hellsing">Hellsing</option>
<option value="heroic_age">Heroic Age</option>
<option value="hetalia_axis_powers">Hetalia axis powers</option>
<option value="hidamari_sketch">Hidamari sketch</option>
<option value="hidamari_sketch_x365">Hidamari sketch x365</option>
<option value="high_school_girls">High school girls ( Girls high )</option>
<option value="higurashi_no_naku_koro_ni">Higurashi no naku koro ni</option>
<option value="higurashi_no_naku_koro_ni_kai">Higurashi no naku koro ni kai</option>
<option value="higurashi_no_naku_koro_ni_rei">Higurashi no naku koro ni rei</option>
<option value="hikaru_no_go">Hikaru no go</option>
<option value="himawari">Himawari</option>
<option value="himitsu_the_revelation">Himitsu the revelation</option>
<option value="honey_and_clover">Honey and clover</option>
<option value="honey_and_clover2">Honey and clover 2</option>
<option value="hunter_x_hunter">Hunter x hunter</option>
<option value="hyakko">Hyakko</option>
<option value="k_on">K-on</option>
<option value="kaiba">Kaiba</option>
<option value="kaleido_star">Kaleido star</option>
<option value="kamen_no_maid_guy">Kamen no maid guy</option>
<option value="kamisama_kazoku">Kamisama kazoku</option>
<option value="kannagi">Kannagi</option>
<option value="kanokon">Kanokon</option>
<option value="kanon">Kanon</option>
<option value="karin">Karin</option>
<option value="kasimasi">Kasimasi</option>
<option value="katekyo_hitman_reborn">Katekyo hitman reborn</option>
<option value="kaze_no_stigma">Kaze no stigma</option>
<option value="kekkaishi">Kekkaishi</option>
<option value="kemono_no_souja_erin">Kemono no souja erin</option>
<option value="kenichi">Kenichi</option>
<option value="kiba">Kiba</option>
<option value="kiddy_grade">Kiddy grade</option>
<option value="kimi_ga_nozomu_eien">Kimi ga nozomu eien</option>
<option value="kimikiss_pure_rouge">Kimikiss pure rouge</option>
<option value="kirarin_revolution">Kirarin revolution</option>
<option value="kodomo_no_jikan">Kodomo no jikan</option>
<option value="koharu_biyori">Koharu biyori</option>
<option value="koihime_musou">Koihime Musou</option>
<option value="kurenai">Kurenai</option>
<option value="kurogane_no_linebarrel">Kurogane no linebarell</option>
<option value="kurokami">Kurokami</option>
<option value="kuroshitsuji">Kuroshitsuji</option>
<option value="kyo_kara_maoh">Kyo kara maoh</option>
<option value="kurozuka">Kurozuka</option>
<option value="kyouran_kazoku_nikki">Kyouran kazoku nikki</option>
<option value="nabari_no_ou">Nabari no ou</option>
<option value="nana">Nana</option>
<option value="naruto">Naruto</option>
<option value="naruto_shippuuden">Naruto shippuuden</option>
<option value="natsu_no_arashi">Natsu no arashi</option>
<option value="natsume_yuujinchou">Natsume yuujinchou</option>
<option value="zoku_natsume_yuujinchou">Zoku natsume yuuijinchou</option>
<option value="negima">Negima!?</option>
<option value="neo_angelique_abyss">Neo angelique abyss</option>
<option value="neon_genesis_evangelion">Neon genesis evangelion</option>
<option value="nhk_ni_youkoso">Nhk ni youkoso</option>
<option value="night_head_genesis">Night head genesis</option>
<option value="ninja_scroll">Ninja scroll</option>
<option value="nodame_cantabile">Nodame cantabile</option>
<option value="nodame_cantabile_paris">Nodame cantabile paris</option>
<option value="noein">Noein</option>
<option value="noir">Noir</option>
<option value="queens_blade">Queens blade</option>
<option value="ragnarok">Ragnarok</option>
<option value="rahxephon">RahXephon</option>
<option value="ranma">Ranma ½</option>
<option value="real_drive">RD sennou chosashitsu</option>
<option value="read_or_die">Read or die</option>
<option value="rec">REC</option>
<option value="rental_magica">Rental magica</option>
<option value="ristorante_paradiso">Ristorante paradiso</option>
<option value="rizelmine">Rizelmine</option>
<option value="romeo_x_juliet">Romeo x juliet</option>
<option value="rosario_to_vampire">Rosario to vampire</option>
<option value="rozen_maiden">Rozen maiden</option>
<option value="rurouni_kenshin">Rurouni kenshin</option>
<option value="tactical_roar">Tactical roar</option>
<option value="tale_of_abyss">Tale of abyss</option>
<option value="tales_of_symphonia">Tales of symphonia</option>
<option value="tears_to_tiara">Tears to tiara</option>
<option value="gurren_lagann">Tengen toppa gurren lagann</option>
<option value="tenjou_tenge">Tnjou tenge</option>
<option value="tenshi_na_konamaiki">Tenshi na konamaiki</option>
<option value="birdy">Tetsuwan birdy decode</option>
<option value="tsukiyomi_moon_phase">Tsukiyomi moon phase</option>
<option value="index">To aru majutsu no index</option>
<option value="to_love_ru">To love ru</option>
<option value="today_in_class_5_2">Today in class 5-2</option>
<option value="toshokan_sensou">Toshokan sensou</option>
<option value="tokyo_mew_mew">Tokyo mew mew</option>
<option value="toradora">Toradora</option>
<option value="touch">Touch</option>
<option value="trigun">Trigun</option>
<option value="trinity_blood">Trinity blood</option>
<option value="true_tears">True tears</option>
<option value="tsubasa_chronicles">Tsubasa chronicles</option>
<option value="utawarerumono">Utawarerumono</option>
</select>
<br />
<br /><br />
<input type="submit" class="button" value="Create">
<br />
</p>
</form>
<br />
<table width="364" height="112" border="0" cellpadding="3">
<tr>
<td width="350">
<?php
if (isset($_REQUEST['anime']) && !empty($_REQUEST['anime'])) {
echo "<img type=\"image\" width=\"350\" height=\"100\" border=\"0\" src=\"sig.php?user=".$_REQUEST['user']."&anime=".$_REQUEST['anime']."&color2=".$_REQUEST['color2']."\" />";
} elseif (isset($_REQUEST['animeinput']) && !empty($_REQUEST['animeinput'])) {
echo "<img type=\"image\" width=\"350\" height=\"100\" border=\"0\" src=\"sig.php?user=".$_REQUEST['user']."&anime=".substr($_REQUEST['animeinput'],0,15)."&color2=".$_REQUEST['color2']."\" />";
}
?>
</td>
</tr>
</table>
</div>
<div style="float:left;">
<script type="text/javascript">
// description : upload the image to the server
// notes : 1. open a new window
// 2. submit the form to it
function UploadImage()
{
window.open("","upload_image");
document.getElementById( 'frmUpload' ).target="upload_image";
document.getElementById( 'frmUpload' ).submit();
}
// description : set the src of the image to the uploaded one
function SetImageFile( pImgSrc )
{
document.getElementById( 'imgUpload' ).src=pImgSrc;
}
function setInputFile( pSRC )
{
document.frm.animeinput.value=pSRC;
}
</script>
<form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm">
<input name="new_image" id="new_image" size="20" type="file" class="fileUpload" />
<button name="submit" type="submit" class="submitButton">Upload</button>
<br />
<br />
<table>
<tr>
<td>
<em><font size="1" face="verdana">Preview of your picture/anime picture </font></em><br />
</td>
</tr>
</table>
<table width="270" height="67" style="border:1px solid;">
<tr>
<td width="270" height="67">
<img src="loading.gif" name="imgUpload" width="270" height="67" border="0" id="imgUpload">
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])){
if (isset ($_FILES['new_image'])){
$imagename = $_FILES['new_image']['name'];
$source = $_FILES['new_image']['tmp_name'];
$target = "temporary_images/".$imagename;
move_uploaded_file($source, $target);
$imagepath = $imagename;
$save = "temporary_images/" . $imagepath; //This is the new file you saving
$file = "temporary_images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 350;
$modheight = 100;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
$save = "temporary_images/sml_" . $imagepath; //This is the new file you saving
$file = "temporary_images/" . $imagepath; //This is the original file
list($width, $height) = getimagesize($file) ;
$modwidth = 80;
$modheight = 100;
$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
imagejpeg($tn, $save, 100) ;
echo "Large image: <img src='temporary_images/".$imagepath."'><br>";
echo "<form>";
echo '<input type="text" value="' .$imagepath. '" name="animeinput" id="animeinput" size="20" class="textbox">';
echo "</form>";
}
}
?>
<?php
// Define the folder to clean
// (keep trailing slashes)
$captchaFolder = 'temporary_images/';
// Filetypes to check (you can also use *.*)
$fileTypes = '*.jpg';
// Here you can define after how many
// minutes the files should get deleted
$expire_time = 1;
// Find all files of the given file type
foreach (glob($captchaFolder . $fileTypes) as $Filename) {
// Read file creation time
$FileCreationTime = filectime($Filename);
// Calculate file age in seconds
$FileAge = time() - $FileCreationTime;
// Is the file older than the given time span?
if ($FileAge > ($expire_time * 60)){
// Now do something with the olders files...
print "The file $Filename is older than $expire_time minutes\n";
unlink($Filename);
// For example deleting files:
//unlink($Filename);
}
}
?>
</div>
</body>
</html>
Try this:
<form name="frm" method="post" action="urlhere.php" enctype="multipart/form-data">

Categories