-
Posts
9,409 -
Joined
-
Last visited
-
Days Won
1
Everything posted by MadTechie
-
the following doesn't make sense } echo "»<a href='".$_SERVER['PHP_SELF']."'>back</a>"; //////////////////////////////////////////////////////////////////////////////// //else if the form didn't submitted then show it. else{ what are you trying to do here ?
-
WooHoo, happy to help
-
Hummmm try PID(Do not Edit) <input id="id" value="' . $row['pid'] . '"/> to PID(Do not Edit) <input name="id" value="' . $pid . '"/> i assume when you use the ?pid=123 it displays 123 in the form!
-
try this <?php ########################################### #----------Upload Multiple Files----------# #----------Multi-files Uploader-----------# #-------------Multi-Uploader -------------# ########################################### /*========================================= Author : Mohammed Ahmed(M@@king) Version : 1.0 Date Created: Aug 20 2005 ---------------------------- Last Update: Aug 31 2005 ---------------------------- Country : Palestine City : Gaza E-mail : m@maaking.com MSN : m@maaking.com AOL-IM : maa2pal WWW : http://www.maaking.com Mobile/SMS : 00972-599-622235 =========================================== ------------------------------------------*/ //Get data $name=$_POST['name']; $Author=$_POST['author']; //upload directory. //change to fit your need eg. files, upload .... etc. $upload_dir = "images/"; //number of files to upload. $num_files = 2; //the file size in bytes. $size_bytes =1151200; //51200 bytes = 50KB. //Extensions you want files uploaded limited to. $limitedext = array(".gif",".jpg",".jpeg",".png",".txt",".nfo",".doc",".rtf",".htm",".dmg",".zip",".rar",".gz",".exe"); //check if the directory exists or not. if (!is_dir("$upload_dir")) { die ("Error: The directory <b>($upload_dir)</b> doesn't exist"); } //check if the directory is writable. if (!is_writeable("$upload_dir")){ die ("Error: The directory <b>($upload_dir)</b> is NOT writable, Please CHMOD (777)"); } //if the form has been submitted, then do the upload process //infact, if you clicked on (Upload Now!) button. if (isset($_POST['upload_form'])){ echo "<h3>Upload results:</h3>"; //do a loop for uploading files based on ($num_files) number of files. for ($i = 1; $i <= $num_files; $i++) { //define variables to hold the values. $new_file = $_FILES['file'.$i]; $file_name = $new_file['name']; //to remove spaces from file name we have to replace it with "_". $file_name = str_replace(' ', '_', $file_name); $file_tmp = $new_file['tmp_name']; $file_size = $new_file['size']; #-----------------------------------------------------------# # this code will check if the files was selected or not. # #-----------------------------------------------------------# if (!is_uploaded_file($file_tmp)) { //print error message and file number. echo "File $i: Not selected.<br>"; }else{ #-----------------------------------------------------------# # this code will check file extension # #-----------------------------------------------------------# $ext = strrchr($file_name,'.'); if (!in_array(strtolower($ext),$limitedext)) { echo "File $i: ($file_name) Wrong file extension. <br>"; }else{ #-----------------------------------------------------------# # this code will check file size is correct # #-----------------------------------------------------------# if ($file_size > $size_bytes){ echo "File $i: ($file_name) Faild to upload. File must be <b>". $size_bytes / 1024 ."</b> KB. <br>"; }else{ #-----------------------------------------------------------# # this code check if file is Already EXISTS. # #-----------------------------------------------------------# if(file_exists($upload_dir.$file_name)){ echo "File $i: ($file_name) already exists.<br>"; }else{ #-----------------------------------------------------------# # this function will upload the files. cool # #-----------------------------------------------------------# // Connects to your Database mysql_connect("", "imrieimag", "") or die(mysql_error()) ; mysql_select_db("imrieimag") or die(mysql_error()) ; //Writes the information to the database $query = "INSERT INTO `".$_POST['options']."` (title, author, file_name, Image_file) VALUES ('".$_POST['title']."', '".$_POST['author']."', '".$_POST[$file_name]."', '".$_POST[$file_name]."')"; mysql_query($query); if (move_uploaded_file($file_tmp,$upload_dir.$file_name)) { echo "File $i: ($file_name) Uploaded.<br>"; }else{ echo "File $i: Faild to upload.<br>"; }#end of (move_uploaded_file). }#end of (file_exists). }#end of (file_size). }#end of (limitedext). }#end of (!is_uploaded_file). }#end of (for loop).; } echo "»<a href='".$_SERVER['PHP_SELF']."'>back</a>"; //////////////////////////////////////////////////////////////////////////////// //else if the form didn't submitted then show it. else{ echo " <h3>Select files to upload!.</h3> Max file size = ". $size_bytes / 151024 ." KB"; echo ' <form method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">'; echo ' <select name="options"> <option value="CLAAS_Cougar ">CLAAS_Cougar </option> <option value="CLAAS_Disco ">CLAAS_Disco </option> <option value="CLAAS_Round Baler ">CLAAS_Round Baler </option> <option value="CLAAS_Xerion">CLAAS_Xerion</option> <option value="Delvano_Sprayer">Delvano_Sprayer</option> <option value="Disc_Harrow">Disc_Harrow</option> <option value="Forage_Harvester ">Forage_Harvester </option> <option value="Grain_Cart">Grain_Cart</option <option value="Grain_Trailer">Grain_Trailer</option> <option value="Header_Trailer ">Header_Trailer </option> <option value="John_Deere_7810">John_Deere_7810</option> <option value="John_Deere_7920 ">John_Deere_7920 </option> <option value="John_Deere_8310">John_Deere_8310</option> <option value="John_Deere_8310t">John_Deere_8310 T </option> <option value="John_Deere_Corn_Header">John_Deere_Corn_Header </option> <option value="John_Deere_Corn_Seeder">John_Deere_Corn_Seeder</option> <option value="John_Deere_Front_Loader">John_Deere_Front_Loader </option> <option value="John_Deere_Machine_40">John_Deere_Machine_40 </option> <option value="John_Deere_Seeder">John_Deere_Seeder </option> <option value="John_Deere_Square_Baler">John_Deere_Square_Baler </option> <option value="John_Deere_STS">John_Deere_STS </option> <option value="John_Deere_Telehandler">John_Deere_Telehandler </option> <option value="John_Deere_Tiller">John_Deere_Tiller </option> <option value="Lexion">Lexion</option> <option value="Livestock_Trialer">Livestock_Trialer</option> <option value="Manure_spreader">Manure_spreader </option> <option value="Manure_Tanker">Manure_Tanker</option> <option value="Miscellaneous">Miscellaneous</option> <option value="New_Holland_NCR">New_Holland_NCR</option> <option value="New_Holland_TG">New_Holland_TG </option> <option value="Plough">Plough</option> <option value="Truck">Truck</option> </select>'; echo 'Title: <input type="text" name = "Title">'; echo 'Title: <input type="text" name="Author">'; // show the file input field based on($num_files). for ($i = 1; $i <= $num_files; $i++) { echo "File $i: <input type='file' name='file".$i."'><br>"; } echo " <input type='hidden' name='MAX_FILE_SIZE' value='$size_bytes'> <input type='submit' name='upload_form' value='Upload Now!'> </form>"; } } //print copyright ;-) echo"<p align='right'><br>Script by: <a href='http://www.maaking.com'>maaking.com</a></p>"; ?>
-
add print_r($_POST); at the top also you make want to change <input id="id" value="' . $row['pid'] . '"/> to <input id="id" name="id" value="' . $row['pid'] . '"/>
-
heres a little update. what are the errors ? maybe try changing it to upload_tmp_dir = "c:/temp/php/uploads/" (what ever the upload path is) your need to restart apache <?php echo "<pre>"; print_r($_FILES); //Make New Folder $baseFolder = "../../Photos/".$RandomKey; mkdir($baseFolder); chmod($baseFolder, 0777); //Upload Files for ($i=0; $i<=$MaxFileCount; $i++) { if ($_FILES["file".$i]["name"]!="") { if ($_FILES["file".$i]["error"] > 0) { $UploadFileReadyFlag=2; echo "<br />File Error Return Code: " . $_FILES["file".$i]["error"] . "<br /><br />"; } else { $FileCount=$FileCount+1; move_uploaded_file($_FILES["file".$i]["tmp_name"],$baseFolder."/" .$_FILES["file".$i]["name"]); rename($baseFolder."/" .$_FILES["file".$i]["name"],$baseFolder.$UploadFileNameLeader.$FileCount.".jpg"); /*Check for Width & Height*/ list($width, $height)=getimagesize($baseFolder."/" .$UploadFileNameLeader.$FileCount.".jpg"); if (($width>100)||($height>100)) { $UploadFileReadyFlag=2; echo "File (".$_FILES["file".$i]["name"].") - Is ( ".$width." Width X ".$height." Heigth ) Pixels!<br />"; } } } } ?>
-
i have added some comments <?php require("dbconnect.php"); mysql_select_db("runecrypt", $sql); if (isset($_POST['name'])) { //assume its an int $pid = (int)$_POST["id"]; echo "POST: pid=".$pid; $name = $_POST["name"]; $pictureurl = $_POST["pictureurl"]; $exinfo = $_POST["exinfo"]; $dsc = $_POST["dsc"]; $location = $_POST["location"]; $quest = $_POST["quest"]; $membonly = $_POST["membonly"]; $contributors = $_POST["contributors"]; $lastupdate = date("F j, Y, g:i a"); //SQL injections problmes here please filter the above code mysql_query("UPDATE pdatabase SET name='$name' , pictureurl='$pictureurl' , exinfo='$exinfo' , dsc='$dsc', location='$location' , quest='$quest' , membonly='$membonly' , contributors='$contributors' , lastupdate='$lastupdate' WHERE pid='$pid'") or die("Mysql error"); } if (isset($_GET['pid'])) { //assume its an int $pid = (int)$_GET['pid']; echo "GET: pid=".$pid; //$pid = mysql_real_escape_string($_GET["pid"]); $result = mysql_query("SELECT * FROM pdatabase WHERE pid='$pid'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { //<h2><span style=\"color: rgb(255, 0, 0);\"><a href="editperson.php">Refresh Page</a></span></h2> echo '<html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>Add Person to Database</title> </head> <body> <div style="text-align: center;"> <form method="post" name="edit2" action="editperson2.php"> Edit Person in Database<br> PID(Do not Edit) <input id="id" value="' . $row['pid'] . '"/> <table style="text-align: left; margin-left: auto; margin-right: auto; height: 374px; width: 661px;" border="1" cellpadding="2" cellspacing="2"> <tbody> <tr> <td style="width: 140px; text-align: center;">Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['name'] . '" input maxlength="40" size="40" name="name"></td> </tr> <tr> <td style="width: 140px; text-align: center;">Picture Name</td> <td style="width: 415px; text-align: center;"><input value="' . $row['pictureurl'] . '" input maxlength="255" size="40" name="pictureurl"><span style="text-decoration: underline;"><br> </span><span style="font-family: monospace;">full link please(http://draftx.net/test/pictures/nopic.png)<br> nopic.png if none</span></td> </tr> <tr> <td style="width: 140px; text-align: center;">Examine Info</td> <td style="width: 415px; text-align: center;"><input value="' . $row['exinfo'] . '" textarea cols="40" rows="5" name="exinfo"></textarea><br> What it says when you examine the person</td> </tr> <tr> <td style="width: 140px; text-align: center;">Description</td> <td style="width: 415px; text-align: center;"><input value="' . $row['dsc'] . '" textarea cols="40" rows="5" name="dsc"></textarea><br> About the person, any extra information</td> </tr> <tr> <td style="width: 140px; text-align: center;">Location</td> <td style="width: 415px; text-align: center;"><input value="' . $row['location'] . '" input maxlength="50" size="40" name="location"><br> <pre><a href="AreaURL">AreaName</a></pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Quests</td> <td style="width: 415px; text-align: center;"><input value="' . $row['quest'] . '" textarea cols="40" rows="5" name="quest"></textarea><br> <pre><a href="QuestURL">QuestName</a><br>Put <br> after every line<br>None if person is involved in no quests</pre> </td> </tr> <tr> <td style="width: 140px; text-align: center;">Members Only</td> <td style="width: 415px; text-align: center;"><input value="' . $row['membonly'] . '" input maxlength="5" size="5" name="membonly"><br> Yes/No</td> </tr> <tr> <td style="text-align: center;">Contributors</td> <td style="text-align: center;"><input value="' . $row['contributors'] . '" textarea cols="40" rows="5" name="contributors"></textarea><br> <pre><a href="ContibutorForumURL">ContributorName</a></pre> </td> </tr> </tbody> </table> <input value="Submit" type="submit"></form> </div> </body> </html>'; } } ?>
-
it might be an idea to get some free webspace which supports php or install WAMP5.. just a suggection ALSO if this is related to this post please click solved on that thread or post in their....
-
method="get" to method="post" as lemmin said
-
can you post the compleate code
-
not a great fix really but a ok work around.. wouldn't SELECT COUNT(*) work better ?
-
for the script i posted the base_path would have to be $base_path = "../../Photos/"; to fit your upload if thats what you were asking
-
replace echo "»<a href="$_SERVER[php_SELF]">back</a>"; with echo "»<a href='".$_SERVER[php_SELF]."'>back</a>"; or echo "»<a href='{$_SERVER[php_SELF]}'>back</a>"; Note the single quotes
-
It didn't work.. well that helps.. download from here http://us.php.net/downloads.php
-
$_FILES['MyFiles']['tmp_name'] Is the temporary filename of the file in which the uploaded file was stored on the server. this will have a name like "/var/tmp/phpie5H7A" and will should be unique, as the server sets this name for you.. the problem will be the $target_path name.. as this will be the name of the file being uploaded.. so if 2 members upload "myFile.doc" then the last one will over write the previous file.. you can get around this by prefixing the users name/id. ie $target_path = $base_path . basename( $_FILES['MyFiles']['name'][$FN]); to $UserName = 10;//the username or id. $target_path = $base_path.$UserName."_".basename( $_FILES['MyFiles']['name'][$FN]);
-
as far as i know WAMP does not come with support for ssl
-
can you post the select statement your using (code always helps) it maybe a bad statement
-
Humm can you post the form please, as normally i would create an array ie <?php $base_path = "uploads/"; foreach($_FILES['MyFiles']['tmp_name'] as $FN => $File) { $target_path = $base_path . basename( $_FILES['MyFiles']['name'][$FN]); if(move_uploaded_file($_FILES['MyFiles']['tmp_name'][$FN], $target_path)) { echo "The file ". basename( $_FILES['MyFiles']['name'][$FN])." has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } } ?> <form method="post" enctype="multipart/form-data"> <input name="MyFiles[]" type="file" /><br /> <input name="MyFiles[]" type="file" /><br /> <input name="MyFiles[]" type="file" /><br /> <input name="MyFiles[]" type="file" /><br /> <input name="MyFiles[]" type="file" /><br /> <input name="Done" type="submit" value="Upload" /> </form> **UNTESTED and can be improved but you get the idea
-
your need to run Window script directly from cscript.exe or wscript.exe using the php //E:PHPScript what are you trying to do ? as a side note this will only work from a server that has been setup with php5activescript.. learn the basics first..
-
Timestamp the signup date.. then Timestamp+(6*24*60*60) (6 being the number of days) post some code, for the link selection and a basic DB schema
-
to redirect when NOT valid use the code below if (!isset($_POST['email'])) { header("Location: http://www.diveadventures.com.au/pages/no_email.html"); } infact heres some improved code, this check the address is a valid address (this does NOT mean the email exists but it is a valid format) if (!isset($_POST['email'])) { header("Location: http://www.diveadventures.com.au/pages/no_email.html"); }else{ if (!preg_match('/\b[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}\b/i', $_POST['email'])) { header("Location: http://www.diveadventures.com.au/pages/no_email.html"); } }
-
[SOLVED] quote marks in output file, removal?
MadTechie replied to macinslaw's topic in PHP Coding Help
See comments <?php $fp = fopen("DCS.txt","w"); // $fp is now the file pointer to file $filename if($fp){ //filter (the magic) //OK the data is about to be written to the file, so the 1st line below finds ' and replaces it with nothing //and the 2nd line below finds " and replaces it with nothing.. then the data is written.. //NOTE: the ' is enclosed with " and the 2nd lines " is enclosed with ' $data= str_replace("'", "", $data); $data= str_replace('"', "", $data); fwrite($fp,$data); // Write information to the file fclose($fp); // Close the file echo "File saved successfully"; } else { echo "Error saving file!"; } ?> hope that helps -
maybe this http://www.solitude.dk/filethingie/download.php
-
[SOLVED] Please explain why this error is coming up..
MadTechie replied to chronister's topic in PHP Coding Help
try $date[]=$row['d']; $question[]=$row['question']; // line 13 $answer[]=$row['answer']; // line 14 -
2nd if you add ?> to the end!