
Grok 🤖
Members-
Posts
41 -
Joined
-
Last visited
Never
Everything posted by Grok 🤖
-
Okay, since earlier i am still stuck with it all. <h2>Current Orders</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); $result = mysql_query("SELECT * FROM order_manager WHERE order_status != 3"); echo "<table border='0' cellpadding='2' cellpadding='2'> <tr> <th>Client ID</th> <th>Client Name</th> <th>Invoice Number</th> <th>Status</th> <th width='300px'>Notes</th> <th>Deadline</th> <th>Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td width='20px'>" . $row['client_id'] . "</td>"; echo "<td width='100px'>" . $row['client_name'] . "</td>"; echo "<td width='100px'>" . $row['invoice_number'] . "</td>"; echo "<td width='200px'>"; echo "<select name='order_status' id='order_status'>"; $result2 = mysql_query("SELECT * FROM order_status"); while($row2 = mysql_fetch_array($result2)) { echo "<option value='$row2[status_id]'"; if($row2['status_id'] === $row['order_status']) { echo "selected='selected'"; } echo "> $row2[order_status] </option>"; } echo "</select></td>"; echo "<td width='300px'><textarea name='notes'>" . $row['notes'] . "</textarea></td>"; echo "<td width='100px'>" . $row['deadline'] . "</td>"; echo "<td><input name='delete' type='checkbox' value='del' /></td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> <input type="submit" name="update" id="button" value="Update Orders" /> </form> This all works but i basically need an update statement so that i can change order_status's and notes within the table. If someone could point me in the right direction of how to go about it, that would be fantastic.
-
Error: Query was empty Thanks,
-
I dab into PHP probably once a year for small projects and i've gone very rusty! <?php if(isset($_POST['update'])) { $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); mysql_query("UPDATE order_manager SET order_status='$_POST[order_status]'"); if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<div id='red'>order updated!</div>"; mysql_close($con); } ?> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <?php $con = mysql_connect("localhost","user","pass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tbl", $con); $result = mysql_query("SELECT * FROM order_manager WHERE active='1'"); echo "<table border='0' cellpadding='2' cellpadding='2'> <tr> <th>Client Name:</th> <th>Invoice Number:</th> <th>Status:</th> <th>Notes:</th> <th>Deadline:</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['client_name'] . "</td>"; echo "<td>" . $row['invoice_number'] . "</td>"; echo "<td>"; echo "<select name='order_status' id='order_status'>"; echo "<option value='" . $row['status'] . "' selected='selected'>Payment Received</option>"; echo "<option value='Payment Received'>Payment Received</option>"; echo " <option value='Awaiting Payment'>Awaiting Payment</option>"; echo " <option value='Stock Ordered'>Stock Ordered</option>"; echo " <option value='Awaiting Digitising'>Awaiting Digitising</option>"; echo " <option value='Processing Order'>Processing Order</option>"; echo " <option value='Waiting for email from client'>Waiting for email from client</option>"; echo "</select></td>"; echo "<td>" . $row['notes'] . "</td>"; echo "<td>" . $row['deadline'] . "</td>"; echo "</tr>"; } echo "</table>"; ?> <input type="submit" name="update" id="button" value="Submit" /> </form> I know my dropdown box isn't ideal, but I'll work on that later on, i'm basically trying to make my table update the status when i hit submit. It's an internal system so it doesn't need to be perfect, but i'm currently just getting errors.
-
I have spent a further 20mins looking online and managed to solve my issue. This website had a good article on how to solve it! http://www.workingwith.me.uk/blog/software/open_source/apache/mod_rewriting_an_entire_site
-
Hi, I am currently writing a code to rename my pages so index.php?page=product becomes /product etc. For this i found a snippet online which seems to work great. RewriteEngine on RewriteRule ^([^/\.]+)/?$ index.php?page=$1 My problem is, i would also like to extend this so that http://url.com/product/t-shirts does not have to be http://url.com/product&product=t-shirts, i have a column in my database called product_seo which has a url friendly version of each products title which is how "t-shirts" is pulling the information on t-shirts etc. Any help would be greatly appreciated! Rik
-
Thanks a lot, i've sorted the issue, the only thing i had to do is put mysql_close($db_handle); after the $emailCount function and it worked.
-
It's always going to 3, it's not adding to database. I changed the code to this since then (to try and self-troubleshoot it); $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $user_name = "db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL2 = "SELECT * FROM newsletter'"; $result = mysql_query($SQL2); mysql_close($db_handle); } if ('$SQL2' == '$_GET[email]') { echo 3; } else { $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO newsletter (email,subscribed) VALUES ('$_GET[email]',1)"; $result = mysql_query($SQL); mysql_close($db_handle);} echo 1; } } else { echo 2; } Now it's getting stuck at 1 (success), but it's not checking if the email address is already in the table, which is 3. Although it is doing error check 2 successfully.
-
Echo 1, 2, 3 is changed when it comes to the page... if (theResponse == 1) { $(".successBalloon").fadeIn("slow"); $(".successBalloon").animate({opacity: 1.0}, 3000); $(".successBalloon").fadeOut(1500); $(".resultText").html(successMessage); } if (theResponse == 2) { $(".errorBalloon").fadeIn("slow"); $(".errorBalloon").animate({opacity: 1.0}, 3000); $(".errorBalloon").fadeOut(1500); $(".resultText").html(invalidMailError); } if (theResponse == 3) { $(".errorBalloon").fadeIn("slow"); $(".errorBalloon").animate({opacity: 1.0}, 3000); $(".errorBalloon").fadeOut(1500); $(".resultText").html(duplicateMailError); }
-
Hi, i'm basically having problems with this code, its for a newsletter script which added the email address into a file, i'm trying to convert it to work with mysql but having a few problems; I've edited the last bit, the code just basically doesn't add it to the database even though i thought i had done it right... any help is very much appreciated! If email is not valid the script is letting me know; if email is valid it says "already added to the list" no matter what. old script <?php /** BY WebResourcesDepot - http://www.webresourcesdepot.com*/ /** YOU CAN EDIT HERE*/ $newsletterFileName = "file.txt"; /** IMPORTANT: EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING*/ function GetField($input) { $input=strip_tags($input); $input=str_replace("<","<",$input); $input=str_replace(">",">",$input); $input=str_replace("#","%23",$input); $input=str_replace("'","`",$input); $input=str_replace(";","%3B",$input); $input=str_replace("script","",$input); $input=str_replace("%3c","",$input); $input=str_replace("%3e","",$input); $input=trim($input); return $input; } /**Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } } return $isValid; } $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $f = fopen($newsletterFileName, 'a+'); $read = fread($f,filesize($newsletterFileName)); If (strstr($read,"@")) { $delimiter = ";"; } if (strstr($read,$email)) { echo 3; } else { fwrite($f, $delimiter . $email); echo 1; } fclose($f); } else { echo 2; } ?> edited script <?php /** BY WebResourcesDepot - http://www.webresourcesdepot.com*/ /** YOU CAN EDIT HERE*/ $newsletterFileName = "file.txt"; /** IMPORTANT: EDIT BELOW UNLESS YOU KNOW WHAT YOU ARE DOING*/ function GetField($input) { $input=strip_tags($input); $input=str_replace("<","<",$input); $input=str_replace(">",">",$input); $input=str_replace("#","%23",$input); $input=str_replace("'","`",$input); $input=str_replace(";","%3B",$input); $input=str_replace("script","",$input); $input=str_replace("%3c","",$input); $input=str_replace("%3e","",$input); $input=trim($input); return $input; } /**Validate an email address. Provide email address (raw input) Returns true if the email address has the email address format and the domain exists. */ function validEmail($email) { $isValid = true; $atIndex = strrpos($email, "@"); if (is_bool($atIndex) && !$atIndex) { $isValid = false; } else { $domain = substr($email, $atIndex+1); $local = substr($email, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { // local part length exceeded $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { // domain part length exceeded $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { // local part starts or ends with '.' $isValid = false; } else if (preg_match('/\\.\\./', $local)) { // local part has two consecutive dots $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { // character not valid in domain part $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { // domain part has two consecutive dots $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { // character not valid in local part unless // local part is quoted if (!preg_match('/^"(\\\\"|[^"])+"$/', str_replace("\\\\","",$local))) { $isValid = false; } } } return $isValid; } $email = GetField($_GET['email']); $pass = validEmail($email); if ($pass) { $user_name = "_db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL2 = "SELECT * FROM newsletter WHERE email = '$_GET[email]'"; $result = mysql_query($SQL2); mysql_close($db_handle); } if (strstr($SQL2,$email)) { echo 3; } else { $user_name = "_db"; $password = ""; $database = "_db"; $server = "localhost"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO newsletter (email,subscribed) VALUES ('$_GET[email]',1)"; $result = mysql_query($SQL); mysql_close($db_handle);} echo 1; } } else { echo 2; } ?>
-
In think from this bit of code you can see what i am trying to achieve, im just not achieving it. $cont = load_template("main-content"); if ($_GET['content_id']="") { $contid = "about"; } else { $contid = $_GET['content_id']; }; thanks in advance for any help!
-
Anyone have any ideas on my original post?
-
Hi, on the upload of an image, im trying to add the image into 2 databases, one needs adding, one needs updating; Im using this; $sql1 = "UPDATE ".TBL_USERS." SET photo = '$pass' WHERE username = '$username'"; $sql2 = "INSERT INTO user_images (photo, username) VALUES ('$pass', '$username'"; mysql_query($sql1); mysql_query($sql2); sql1 works fine, but sql2 is doing nothing, any ideas?
-
I have an image uploader which is causing images to stretch when they are being resized, which i do not want. I need the image to be resized 3 times and moved into 3 different folders, but i do not want the image to be scaled up if it is too big. Here is the code i'm working with; <?php include('include/session.php'); if($session->logged_in){ ini_set("session.gc_maxlifetime","10800"); ini_set("upload_max_size","4194304"); $default = $_POST["default"]; $username = $session->userinfo['username']; if(isset($_FILES)) { $fileName = $_FILES["uploadfile"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ); $uploadedfile = $_FILES["uploadfile"]["tmp_name"]; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=180; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*180; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["uploadfile"]["name"]; }} # $query = "INSERT INTO track9_userphotos (pictureurl, username, caption) VALUES('$pass', '$username', '$caption')"; # mysql_query($query) or die(mysql_error()); if ( $default == 1 ) { mysql_query("UPDATE ".TBL_USERS." SET photo = '$pass' WHERE username = '$username'"); } else { echo ""; } ?> <h8>Your Uploaded Picture</h8><p><div id='header2'> <br><br> <table border="0" width="700" cellspacing="0" cellpadding="0"> <tr> <td width="200" valign="top"> <p align="center"><? echo "<img src='thimg/$pass'>"; ?></p> <p></td> <td> <p align="center"> <p align="center"> </p> </form> <p></td> </tr> </table> </div>
-
I'm currently creating a new site out of old code and came across an old script i need help fixing; Here's what i've got; (code wise) <?php include('include/session.php'); if($session->logged_in){ ini_set("session.gc_maxlifetime","10800"); ini_set("upload_max_size","4194304"); $default = $_POST["default"]; $username = $session->userinfo['username']; if(isset($_FILES)) { $fileName = $_FILES["uploadfile"]["name"]; // get the file extension first $ext = substr(strrchr($fileName, "."), 1); // make the random file name do{ $randName = md5(rand() * time()); $pass = "$randName.$ext"; $Check = (file_exists("upimg/$pass") || file_exists("thimg/$pass") || file_exists("avimg/$pass")); }while( $Check ); $uploadedfile = $_FILES["uploadfile"]["tmp_name"]; list($width,$height)=getimagesize($uploadedfile); $newwidth1=600; $newwidth2=180; $newwidth3=100; $newheight1=($height/$width)*600; $newheight2=($height/$width)*180; $newheight3=($height/$width)*100; switch($_FILES['uploadfile']['type']) { case "image/gif": $src = imagecreatefromgif($uploadedfile);//Create from GIF! $type = "gif"; break; case "image/jpg": case "image/jpeg": $src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $type = "jpg"; break; } #1 //$src = imagecreatefromjpeg($uploadedfile);//Create from JPEG! $tmp1=imagecreatetruecolor($newwidth1,$newheight1); imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height); $filename = "upimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp1,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp1,$filename,100); } imagedestroy($src); #2 $tmp2=imagecreatetruecolor($newwidth2,$newheight2); imagecopyresampled($tmp2,$tmp1,0,0,0,0,$newwidth2,$newheight2,$newwidth1,$newheight1); $filename = "thimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp2,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp2,$filename,100); } imagedestroy($tmp1); #3 $tmp3=imagecreatetruecolor($newwidth3,$newheight3); imagecopyresampled($tmp3,$tmp2,0,0,0,0,$newwidth3,$newheight3,$newwidth2,$newheight2); $filename = "avimg/$pass";// . $_FILES["uploadfile"]["name"]; if($type == "gif") { imagegif($tmp3,$filename,100); }elseif($type == "jpg"){ imagejpeg($tmp3,$filename,100); } imagedestroy($tmp2); imagedestroy($tmp3); $name = $_FILES["uploadfile"]["name"]; }} # $query = "INSERT INTO track9_userphotos (pictureurl, username, caption) VALUES('$pass', '$username', '$caption')"; # mysql_query($query) or die(mysql_error()); if ( $default == 1 ) { # $query = "UPDATE altshop_hocsite SET photo='$pass' WHERE username='$username'"; # mysql_query($query) or die(mysql_error()); } else { echo ""; } ?> <h8>Your Uploaded Picture</h8><p><div id='header2'> <br><br> <table border="0" width="700" cellspacing="0" cellpadding="0"> <tr> <td width="200" valign="top"> <p align="center"><? echo "<img src='thimg/$pass'>"; ?></p> <p></td> <td> <p align="center"> <p align="center"> </p> </form> <p></td> </tr> </table> </div> Here's what i've got; (error wise) Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/altshop/public_html/new/uploader.php on line 47 Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/altshop/public_html/new/uploader.php on line 55 Your Uploaded Picture
-
I'm getting this error; sprintf() [<a href='function.sprintf'>function.sprintf</a>]: Too few arguments in <b>/home/altshop/public_html/new/useredit.php</b> on line <b>132</b><br />
-
Thanks! Just one more error now; With the code you gave me for generating days, How can i make it so that it is always two digits long? 01 02.. ..29 30 31 etc?
-
Hi, i have a very quick problem; I have my selectbox in HTML on an "edit account" page. <select name="mm" id="mm"> <option value="1">January</option> <option value="2">February</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> For normal fields i am doing this; <input type="text" name="email" maxlength="50" value=" <? if($form->value("email") == ""){ echo $session->userinfo['email']; }else{ echo $form->value("email"); } ?>"> How would i work this on a selectbox field?
-
I tried this, as suggested <?php $filename = $_FILES['file']['name']; $dotPos = strpos($file, '.'); $newname = substr($filename, 0, $dotPos) . '-' . rand(10000, 99999) . $ext; $ext = strtolower(substr(strrchr($filename, '.'), 1)); $size = $_FILES['file']['size']; $allowedExt = array('.mp3','.wma','.wav','.mpeg'); $maxSize = 15000000; //very approximate 15MB if(in_array($ext, $allowedExt)){ if($size < $maxSize){ if(move_uploaded_file($_FILES['file']['tmp_name'], $newname)){ echo 'The file was successfuly uploaded'; } else{ echo 'An error occurred while uploading. Please try again.'; } } else{ echo 'Filesize is too big'; } } else{ echo 'Filetype not supported.'; } ?> Made an uploader page, but keep getting "Filetype not supported." on mp3's, any ideas? Also, I really need it to upload it to another directory, like /songs and do a check before uploading..
-
I guess i would need the file to look like; 'original songname_0003293.mp3' So that it can be easily played.
-
Hey, Please don't be put off by the title of this post, it's for unsigned bands to post their music so that they can be played on an online radio. I have a file uploader script currently, but i need a way of renaming the file and making sure it doesn't already exist. It would also be useful to have a size limiter at 15mb. I will make a donation via paypal to the completer. any help is appreciated, here is the code i'm currently using, <?php $uploaddir = "upload/"; //Upload directory: needs write premissions $log = "uploadlog.txt"; // Upload LOG file // what file types do you want to disallow? $blacklist = array(".php", ".phtml", ".php3", ".php4", ".php5", ".exe", ".js",".html", ".htm", ".inc"); // allowed filetypes $allowed_filetypes = array('.mp3','.wma','.wav','.mpeg'); if (!is_dir($uploaddir)) { die ("Upload directory does not exists."); } if (!is_writable($uploaddir)) { die ("Upload directory is not writable."); } if ($_POST['cmdupload']) { $ip = trim($_SERVER['REMOTE_ADDR']); if (isset($_FILES['file'])) { if ($_FILES['file']['error'] != 0) { switch ($_FILES['file']['error']) { case 1: print 'The file is to big.'; // php installation max file size error exit; break; case 2: print 'The file is to big.'; // form max file size error exit; break; case 3: print 'Only part of the file was uploaded'; exit; break; case 4: print 'No file was uploaded</p>'; exit; break; case 6: print "Missing a temporary folder."; exit; break; case 7: print "Failed to write file to disk"; exit; break; case 8: print "File upload stopped by extension"; exit; break; } } else { foreach ($blacklist as $item) { if (preg_match("/$item\$/i", $_FILES['file']['name'])) { echo "Invalid filetype !"; $date = date("m/d/Y"); $time = date("h:i:s A"); $fp = fopen($log,"ab"); fwrite($fp,"$ip | ".$_FILES['file']['name']." | $date | $time | INVALID TYPE"."\r\n"); fclose($fp); unset($_FILES['file']['tmp_name']); exit; } } // Get the extension from the filename. $ext = substr($_FILES['file']['name'], strpos($_FILES['file']['name'],'.'), strlen($_FILES['file']['name'])-1); // Check if the filetype is allowed, if not DIE and inform the user. if(!in_array($ext,$allowed_filetypes)){ $date = date("m/d/Y"); $time = date("h:i:s A"); $fp = fopen($log,"ab"); fwrite($fp,"$ip | ".$_FILES['file']['name']." | $date | $time | INVALID TYPE"."\r\n"); fclose($fp); die('The file you attempted to upload is not allowed.'); } if (!file_exists($uploaddir . $_FILES["file"]["name"])) { // Proceed with file upload if (is_uploaded_file($_FILES['file']['tmp_name'])) { //File was uploaded to the temp dir, continue upload process if (move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . $_FILES['file']['name'])) { // uploaded file was moved and renamed succesfuly. Display a message. echo "Upload successful !"; // Now log the uploaders IP adress date and time $date = date("m/d/Y"); $time = date("h:i:s A"); $fp = fopen($log,"ab"); fwrite($fp,"$ip | ".$_FILES['file']['name']." | $date | $time | OK"."\r\n"); fclose($fp); } else { echo "Error while uploading the file, Please contact the webmaster."; unset($_FILES['file']['tmp_name']); } } else { //File was NOT uploaded to the temp dir switch ($_FILES['file']['error']) { case 1: print 'The file is to big.'; // php installation max file size error break; case 2: print 'The file is to big.'; // form max file size error break; case 3: print 'Only part of the file was uploaded'; break; case 4: print 'No file was uploaded</p>'; break; case 6: print "Missing a temporary folder."; break; case 7: print "Failed to write file to disk"; break; case 8: print "File upload stopped by extension"; break; } } } else { echo "Filename already exists, Please rename the file and retry."; unset($_FILES['file']['tmp_name']); } } } else { // user did not select a file to upload echo "Please select a file to upload."; } } else { // upload button was not pressed header("Location: uploadform.php"); } ?>
-
I am going to use hostname.com as an example in this, I have created a DNS record for all subdomains so they all turn back to the default directory of the domain. I am trying to create a php script which will check the URL, if there is no subdomain, or the subdomain is equal to "www." to set the page header to home.php if it's equivalent to anything else i want it to set the header to another page home2.php, and set "subdomain".hostname.com as a variable.. change the "subdomain" to "id" in mysql.. (this part i can manage..) For example.. hello.hostname.com would header as hostname.com/home2.php?sub=1 (if hello = 1 in the mysql database) www.hostname.com would header as hostname.com/home.php hostname.com would header as hostname.com/home.php
-
Hi cheers, looked further into it and it was dreamweaver uploading the file with the wrong CHMOD, fixed now. Just a further question; How can i make it send this email in HTML so i can include bold tags and an image? Cheers Rik
-
<?php $firstname = $_REQUEST['firstname'] ; $surname = $_REQUEST['surname'] ; $servicerequired = $_REQUEST['servicerequired'] ; $housenumber = $_REQUEST['housenumber'] ; $streetadress = $_REQUEST['streetaddress'] ; $towncity = $_REQUEST['towncity'] ; $county = $_REQUEST['county'] ; $postcode = $_REQUEST['postcode'] ; $mobilenumber = $_REQUEST['mobilenumber'] ; $homenumber = $_REQUEST['homenumber'] ; $worknumber = $_REQUEST['worknumber'] ; $emailaddress = $_REQUEST['emailaddress'] ; $agentdetails = $_REQUEST['agentdetails'] ; $propertyage = $_REQUEST['propertyage'] ; $propertytype = $_REQUEST['propertytype'] ; $bedrooms = $_REQUEST['bedrooms'] ; $extensions = $_REQUEST['extensions'] ; $heatingtype = $_REQUEST['heatingtype'] ; $inspectiondaytime = $_REQUEST['inspectiondaytime'] ; $notes = $_REQUEST['notes'] ; $to = "[email protected]"; $subject = "EPC/HIP Request Form Submission"; $message = "Service Required: $servicerequired Firstname: $firstname Surname: $surname House Number: $housenumber Street Address: $streetaddress Town/City: $towncity County: $county Postcode: $postcode Mobile Number: $mobilenumber Home Number: $homenumber Work Number: $worknumber Email Address: $emailaddress Agent Details: $agentdetails Property Age: $propertyage Property Type: $propertytype Bedrooms: $bedrooms Extensions: $extensions Heating Type: $heatingtype Inspection Day/Time: $inspectiondaytime Notes: $notes"; $headers = "From: $emailaddress"; mail($to, $subject, $message, $headers); ?> <h1>Thank you</h1> <p>Thank you for your contact form submission, someone will be in touch shortly.</p> I can't see a single issue in the above code, but i'm sure there is one as i'm getting server misconfiguration error 500. Any help? appreciated thanks Rik