Jump to content

obaluba

Members
  • Posts

    7
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

obaluba's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your reply. Is there nothing simple I can add into the script i have to enable it to stop running and only run through the pdf form? thanks again
  2. Hi all, I'm hoping someone can help me with something I think or hope is pretty simple. I have an editable pdf form which people fill out on a website. when the user clicks submit the script emails the completed pdf to an email address and stores a copy on the server. however, if i go directly to the script on the server i.e.: www.domain.com/script.php and press enter it will email me a pdf file with nothing in it to my address what I want to do is try and stop this as its causing issues with the form.. I was hoping there was something that could go in the header that could help.. when the user clicks submit the path from the submit button is directly to the code below the code is here <?php require("class.phpmailer.php"); /////////////////////////////////////////////////// ////////////////////////////////////////////////// /////////////////////////////////////////////////// ////////////////////////////////////////////////// /* $folder = "";*/ $folder = "/home/account/public_html/path/pdf/"; $fn = $folder . date("d-m-Y-His").'.pdf'; # make unique filename copy('php://input',$fn); # copy raw post data to file /////////////////////////////////////////////////// ////////////////////////////////////////////////// // use for Upload folder >>>>>>>>>>>>>>>>> $mail = new PHPMailer(); $mail->MsgHTML($body); $mail->AddAddress("email@gmail.com"); $mail->From = "address@email.com"; $mail->FromName = 'PDF Form enquiry'; $mail->Subject = 'Completed Form'; $mail->Body = 'Attached is a user submitted form'; $thankyouurl = "www.domain.com/thanks" ; if(!$mail->AddAttachment($fn)) { echo "There was a problem attaching the pdf form."; echo $mailer->ErrorInfo; } $dataResponse_1 = "passed"; if(!$mail->Send()) { print("&response=error"); } else { header( "Location: $thankyouurl" ); } ?> thanks so much for looking!
  3. Thanks for your reply, although I am still having issues, In the latest version I'm getting 'Fatal error: No such file or directory in /home/public_html/images/add.php on line 10' I'm not sure if the function is in the wrong place or even if it will work like I want it to, Is it possible for the random name created when the image is saved to be passed to the thumbnail function and saved with the same name in a different location? thanks so much for your replys & looking! The code is below: <?php $dest_pict = "imagesrob/thumbs/$ran2.jpg"; $pict = "$ran$ext"; $size_in_pixel_x = "100"; $size_in_pixel_y = "100"; function resize ( $pict, $dest_pict, $size_in_pixel_x, $size_in_pixel_y ) { if ( !file_exists ( $pict ) ) { die ( trigger_error ( 'No such file or directory', E_USER_ERROR ) ); } $path = pathinfo($pict); switch ( strtolower ( $path["extension"] ) ) { case "jpeg": case "jpg": $handle = imagecreatefromjpeg ( $pict ); break; case "gif": $handle = imagecreatefromgif ( $pict ); break; case "png": $handle = imagecreatefrompng ( $pict ); break; default: die ( trigger_error ( 'Supplied file is not a valid image resource (' . $path['basename'] . ')', E_USER_ERROR ) ); break; } if ( empty ( $handle ) ) { die ( trigger_error ( 'Unable to create image (' . $path['basename'] . ')', E_USER_ERROR ) ); } $x = imagesx ( $handle ); $y = imagesy ( $handle ); if ( $x / $size_in_pixel_x > $y / $size_in_pixel_y ) { $rate = $x / $size_in_pixel_x; } else { $rate = $y / $size_in_pixel_y; } $final_x = $x / $rate; $final_y = $y / $rate; if ( $final_x > $x ) { $final_x = $x; $final_y = $y; } $final_x = ceil ( $final_x ); $final_y = ceil ( $final_y ); $black_picture = imageCreatetruecolor ( $final_x, $final_y ); imagefill ( $black_picture, 0, 0, imagecolorallocate ( $black_picture, 255, 255, 255 ) ); imagecopyresampled ( $black_picture, $handle, 0, 0, 0, 0,$final_x, $final_y, $x, $y ); if ( !@imagejpeg ( $black_picture, $dest_pict.'/mini_'.$pict, $size_in_pixel_x ) ) { imagejpeg ( $black_picture, $dest_pict, '100' ); imagedestroy ( $handle ); imagedestroy ( $black_picture ); } } //This is the directory where images will be saved $target = "imagesrob/"; $target = $target . basename( $_FILES['photo']['name']); // Connects to your Database $host = "localhost"; $name = "dbpw"; $pass = "pw"; $dbname = "dbname"; $dbi = mysql_connect($host,$name,$pass) or die("I cannot connect to the database. Error :" . mysql_error()); mysql_select_db($dbname,$dbi); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); //random file stuff //This function separates the extension from the rest of the file name and returns it function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['photo']['name']) ; //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $ran = rand () ; //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $ran2 = $ran."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = "imagesrob/"; //This combines the directory, the random file name, and the extension $target = $target . $ran2.$ext; if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { resize('$ran2$ext', '$ran2$ext', 100, 100); echo "The file has been uploaded as ".$ran2.$ext; //{ //echo "Sorry, there was a problem uploading your file."; //} //endofrandom } ?>
  4. Hi, I was wondering if anyone would be able to advise me, I have a script which a user can fill out some simple fields and upload an image to the server the name of which is put into a mysql db. The script also generates a random name for the file (to avoid the same filename twice!) What I am trying to make it do is generate a thumbnail of the same random name it generates for the larger image and store it in a subdirectory on the server.. Which is the bit that is confusing me.. Could someone perhaps take a look at my code and see what I'm doing wrong!? <?php //This is the directory where images will be saved $target = "imagesr/"; $target = $target . basename( $_FILES['photo']['name']); // Connects to your Database $host = "localhost"; $name = "name"; $pass = "pass"; $dbname = "dbname"; $dbi = mysql_connect($host,$name,$pass) or die("I cannot connect to the database. Error :" . mysql_error()); mysql_select_db($dbname,$dbi); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); //random file stuff //This function separates the extension from the rest of the file name and returns it function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //This applies the function to our file $ext = findexts ($_FILES['photo']['name']) ; //This line assigns a random number to a variable. You could also use a timestamp here if you prefer. $ran = rand () ; //This takes the random number (or timestamp) you generated and adds a . on the end, so it is ready of the file extension to be appended. $ran2 = $ran."."; //This assigns the subdirectory you want to save into... make sure it exists! $target = "imagesrob/"; //This combines the directory, the random file name, and the extension $target = $target . $ran2.$ext; if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { echo "The file has been uploaded as ".$ran2.$ext; } else { echo "Sorry, there was a problem uploading your file."; } //endofrandom //resizing image //Name you want to save your file as $save = '$ran2$ext'; $file = '$ran2$ext'; echo "Creating file: $save"; $size = 0.45; //header('Content-type: image/jpeg') ; list($width, $height) = getimagesize($file) ; $modwidth = $width * $size; $modheight = $height * $size; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; // Here we are saving the .jpg, you can make this gif or png if you want //the file name is set above, and the quality is set to 100% imagejpeg($tn, $save, 100) ; ?> Thanks
  5. could i use some javascript on my php page (the one i posted a bit of above) to get it to open in the parent window do you think? does PHP and JS work together in that way? thanks, sorry for the novice questions!
  6. Is there no way it can be done in the PHP posted, nothing that can be put in the header section? I'm a total novice at PHP, so my knowledge is primative at best!! :)
  7. Hi, I think this is fairly simple although I have been tearing my hair out all day! Basically.. I have a html page which has an iframe on it which loads a php page which contains a form. Once the form is filled out I have this code to return it to another html page. currently the html page is loading in the iframe, I need to find a way to make it load in the parent of the iframe if you like... The code I have is below for this section... $ThankYou = $_GET['ThankYou']; if ($ThankYou != "") {     $message    = "Thankyou, you will now be forwarded to the technical section."; header("HTTP/1.1 301 Moved Permanently"); header ("Location: http://www.google.com"); } I tried adding this having found it on another site: header("target_parent"); but didnt seem to work any help would be greatly appreciated  :) thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.