PHP - Open Link/image In Template File
I have a page with links to images. Currently the images open in a blank browser window, and I think this is too plain.
I don't want to create an HTML file for each image. I want to have an 'image display php file' - img_temp.php. Along with the reference to the image file, in the link, I want to also be able to send a <title> to the template file. I think the code below shows kinda' what I'm trying to do, and also shows that I don't quite have a grasp on how to do it. Any tips would be appreciated. Index Page (index.php) Code: [Select] <html> <head> <title>Gallery Links</title> </head> <body> <!-- This is the page with the links to the images --> <ul> <li><a href="img_temp.php?file=images/01.jpg<?php ?title = "This is image 1"?>">Image 01</a></li> </ul> </body> </html> Image Display Template (img_temp.php) Code: [Select] <html> <head> <title><?php echo $title ?></title> </head> <body> <!-- This is the page that displays the sent image and displays the appropriate doc title --> <?php //Output the image $file echo $file; ?> </body> </html> Similar TutorialsNot sure if this relates more to PHP or Javascript/jQuery, but is there a way to attach a file to an email client (i.e Outlook), when user click on a link/button? I have a link that generates a PDF and I want it so that, when someone click on a link, it will open up their email client with the PDF already attached, and subject already fill in. I know, you can use <a href="mailto:..." but that only opens up the mail client. I also need to attach a file with a subject fill in. Is this doable with PHP or Javascript? My images generator comprises
an array of image names extracted form an images table from a database using a select statement
a random number generator,
and a string that builds the correct pathname for the selected file.
To select one of the images for display, i generate a random number between 1 and the length of the array.
Though the generator is working, I noticed one of the random numbers is throwing up this error:
Warning: getimagesize(images/): failed to open stream: No such file or directory in
An inspection of the array reveals 2 array elements (representing my number of images) but one array element is NULL ( the first entry in the banner table
image_generator.php
require_once('connection.inc.php'); $sql = 'SELECT `filename` FROM banner'; $result = $mysqli->query($sql, MYSQLI_STORE_RESULT) or die(mysqli_error()); $row = $result->fetch_array(MYSQLI_ASSOC);//an array of image names $count = $result->num_rows; for ($i = 1; $i <= $count; ++$i) { $row[$i] = $result->fetch_array(MYSQLI_ASSOC); } $i = rand(1, $count); //a random number generator, //The random number is used in the final line to build the correct pathname for the selected file. $selectedImage = "images/{$row[$i]['filename']}"; if (file_exists($selectedImage) && is_readable($selectedImage)) { $imageSize = getimagesize($selectedImage); }var_dump($row) array (size=1) 'filename' => string 'ginsomin2.jpg' (length=13) nullRANDON IMAGE DISPLAY require_once 'image_generator.php'; <div id="banner" class="wrapper clearfix"> <img src="<?php echo $selectedImage; ?>" alt="banner"> </div>Kindly advice how i may proceed from here? Thanks. Hello everyone, Can someone help to add "add to Google Calendar" link referensing booking time, date and location under "Comment" line in this php? <?php $Date=new CHBSDate(); $Length=new CHBSLength(); $Validation=new CHBSValidation(); $BookingFormElement=new CHBSBookingFormElement(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php if(is_rtl()) { ?> <style type="text/css"> body { direction:rtl; } </style> <?php } ?> </head> <body> <table cellspacing="0" cellpadding="0" width="100%" bgcolor="#EEEEEE"<?php echo $this->data['style']['base']; ?>> <tr height="50px"><td></td></tr> <tr> <td> <table cellspacing="0" cellpadding="0" width="600px" border="0" align="center" bgcolor="#FFFFFF" style="border:solid 1px #E1E8ED;padding:50px"> <!-- --> <?php $logo=CHBSOption::getOption('logo'); if($Validation->isNotEmpty('logo')) { ?> <tr> <td> <img style="max-width:100%;height:auto;" src="<?php echo esc_attr($logo); ?>" alt=""/> <br/><br/> </td> </tr> <?php } ?> <!-- --> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('General','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Title','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo $this->data['booking']['booking_title']; ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Status','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['booking_status_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Service type','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['service_type_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Transfer type','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['transfer_type_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Pickup date and time','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($Date->formatDateToDisplay($this->data['booking']['meta']['pickup_date']).' '.$Date->formatTimeToDisplay($this->data['booking']['meta']['pickup_time'])); ?></td> </tr> <?php if(in_array($this->data['booking']['meta']['service_type_id'],array(1,3))) { if((int)$this->data['booking']['meta']['transfer_type_id']===3) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Return date and time','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($Date->formatDateToDisplay($this->data['booking']['meta']['return_date']).' '.$Date->formatTimeToDisplay($this->data['booking']['meta']['return_time'])); ?></td> </tr> <?php } } if((int)$this->data['booking']['meta']['price_hide']===0) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Order total amount','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html(CHBSPrice::format($this->data['booking']['billing']['summary']['value_gross'],$this->data['booking']['meta']['currency_id'])); ?></td> </tr> <?php if($this->data['booking']['meta']['payment_deposit_enable']==1) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php echo sprintf(esc_html('To pay (deposit %s%%)','chauffeur-booking-system'),$this->data['booking']['meta']['payment_deposit_value']); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html(CHBSPrice::format($this->data['booking']['billing']['summary']['pay'],$this->data['booking']['meta']['currency_id'])); ?></td> </tr> <?php } if(in_array($this->data['booking']['meta']['service_type_id'],array(1,3))) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Distance','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>> <?php echo $Length->format($this->data['booking']['billing']['summary']['distance'],$this->data['booking']['meta']['length_unit']); ?> </td> </tr> <?php } } ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Duration','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>> <?php echo esc_html($this->data['booking']['billing']['summary']['duration']); ?> </td> </tr> <?php if($this->data['booking']['meta']['passenger_enable']==1) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Passengers','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html(CHBSBookingHelper::getPassengerLabel($this->data['booking']['meta']['passenger_adult_number'],$this->data['booking']['meta']['passenger_children_number'])); ?></td> </tr> <?php } if($Validation->isNotEmpty($this->data['booking']['meta']['comment'])) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Comment','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['comment']); ?></td> </tr> <?php } ?> </table> </td> </tr> <!-- --> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Route','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <?php if($this->data['booking']['meta']['service_type_id']==3) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Route name','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['route_name']); ?></td> </tr> <?php } if(in_array($this->data['booking']['meta']['service_type_id'],array(1,3))) { if($this->data['booking']['meta']['extra_time_enable']==1) { ?> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Extra time','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($Date->formatMinuteToTime($this->data['booking']['meta']['extra_time_value'])); ?></td> </tr> <?php } } ?> </table> </td> </tr> <!-- --> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Route locations','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td> <ol <?php echo $this->data['style']['list'][1]; ?>> <?php foreach($this->data['booking']['meta']['coordinate'] as $index=>$value) { $address=esc_html($value['address']); if(array_key_exists('formatted_address',$value)) $address='<b>'.esc_html($value['formatted_address']).'</b> '.$address; ?> <li <?php echo $this->data['style']['list'][2]; ?>><a href="https://www.google.com/maps/?q=<?php echo esc_attr($value['lat']).','.esc_attr($value['lng']); ?>" target="_blank"><?php echo $address; ?></a></li> <?php } ?> </ol> </td> </tr> </table> </td> </tr> <!-- --> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Vehicle','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Vehicle name','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['vehicle_name']); ?></td> </tr> </table> </td> </tr> <!-- --> <?php if(count($this->data['booking']['meta']['booking_extra'])) { ?> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Extra','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td> <ol <?php echo $this->data['style']['list'][1]; ?>> <?php foreach($this->data['booking']['meta']['booking_extra'] as $index=>$value) { ?> <li <?php echo $this->data['style']['list'][2]; ?>> <?php echo esc_html($value['quantity']); ?> <?php esc_html_e('x','chauffeur-booking-system'); ?> <?php echo esc_html($value['name']); ?> <?php if((int)$this->data['booking']['meta']['price_hide']===0) { echo ' - '.CHBSPrice::format(CHBSPrice::calculateGross($value['price'],0,$value['tax_rate_value'])*$value['quantity'],$this->data['booking']['meta']['currency_id']); } ?> </li> <?php } ?> </ol> </td> </tr> </table> </td> </tr> <?php } ?> <!-- --> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Client details','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('First name','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_contact_detail_first_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Last name','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_contact_detail_last_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('E-mail address','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_contact_detail_email_address']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Phone number','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_contact_detail_phone_number']); ?></td> </tr> <?php echo $BookingFormElement->displayField(1,$this->data['booking']['meta'],2,array('style'=>$this->data['style'])); ?> </table> </td> </tr> <!-- --> <?php if((int)$this->data['booking']['meta']['client_billing_detail_enable']===1) { ?> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Billing address','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Company name','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_company_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Tax number','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_tax_number']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Street name','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_street_name']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Street number','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_street_number']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('City','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_city']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('State','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_state']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Postal code','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['meta']['client_billing_detail_postal_code']); ?></td> </tr> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Country','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>><?php echo esc_html($this->data['booking']['client_billing_detail_country_name']); ?></td> </tr> <?php echo $BookingFormElement->displayField(2,$this->data['booking']['meta'],2,array('style'=>$this->data['style'])); ?> </table> </td> </tr> <?php } $panel=$BookingFormElement->getPanel($this->data['booking']['meta']); foreach($panel as $panelIndex=>$panelValue) { if(in_array($panelValue['id'],array(1,2))) continue; ?> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php echo esc_html($panelValue['label']); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <?php echo $BookingFormElement->displayField($panelValue['id'],$this->data['booking']['meta'],2,array('style'=>$this->data['style'])); ?> </table> </td> </tr> <?php } ?> <!-- --> <?php if(!empty($this->data['booking']['meta']['payment_id'])) { ?> <tr><td <?php echo $this->data['style']['separator'][2]; ?>><td></tr> <tr> <td <?php echo $this->data['style']['header']; ?>><?php esc_html_e('Payment','chauffeur-booking-system'); ?></td> </tr> <tr><td <?php echo $this->data['style']['separator'][3]; ?>><td></tr> <tr> <td> <table cellspacing="0" cellpadding="0"> <tr> <td <?php echo $this->data['style']['cell'][1]; ?>><?php esc_html_e('Payment','chauffeur-booking-system'); ?></td> <td <?php echo $this->data['style']['cell'][2]; ?>> <?php echo esc_html($this->data['booking']['payment_name']); if($Validation->isNotEmpty($this->data['booking']['woocommerce_payment_url'])) echo '<br><a href="'.esc_url($this->data['booking']['woocommerce_payment_url']).'" target="_blank">'.__('Click to pay for this order','chauffeur-booking-system').'</a>'; ?> </td> </tr> </table> </td> </tr> <?php } ?> </table> </td> </tr> <tr height="50px"><td></td></tr> </table> </body> </html> Many thanks Edited June 30, 2019 by KOTThis topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=316401.0 If I want to open a new tab try target = blank in anchor tab I have a form with action e.g. register.php I also have a Google group API link - https://www.pakainfo.com/ in short... Is there any PHP function for open page in new tab; on page load... Why smarty won't find my template file?
Fatal error: Uncaught --> Smarty: Unable to load template file 'test.tpl' <-- thrown in C:\xampp\htdocs\testing\includes\smarty\sysplugins\smarty_internal_templatebase.php on line 129also did testinstall $smarty->testInstall(); Smarty Installation test... Testing template directory... C:\xampp\htdocs\testing\templates\frontend\default\tpl is OK. Testing compile directory... C:\xampp\htdocs\testing\templates_c\frontend is OK. Testing plugins directory... C:\xampp\htdocs\testing\includes\smarty\plugins is OK. Testing cache directory... C:\xampp\htdocs\testing\cache is OK. Testing configs directory... C:\xampp\htdocs\testing\configs is OK. Testing sysplugin files... ... OK Testing plugin files... ... OK Tests complete.And get template dir var_dump($smarty->getTemplateDir());array(1) { [0]=> string(55) "C:/xampp/htdocs/testing/templates/frontend/default/tpl\" } File schema htdocs -- testing -- incluses -- smarty plugins sysplugins Smarty.class.php SmartyBC.class.php -- configs configs.php -- db connect.php db.php -- configs -- cache -- templates -- frontend -- default -- css -- mages -- js -- tpl test.tpl -- backend -- templates_c -- frontend index.phpindex.php <?php ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('display_startup_errors', TRUE); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL); ob_start(); session_start(); require 'includes/smarty/Smarty.class.php'; require 'includes/db/db.php'; require 'includes/configs/configs.php'; $page = isset($_GET['do']) ? $_GET['do'] : ''; switch($page){ case 'home'; include 'pages/home.php'; break; default: include 'pages/test.php'; break; } ob_flush(); ?>configs.php <?php $smarty = new Smarty(); $smarty->compile_check = true; $smarty->debugging = false; $smarty->cache = 1; $smarty->setTemplateDir('C:/xampp/htdocs/testing/templates/frontend/default/tpl'); $smarty->setCompileDir('C:/xampp/htdocs/testing/templates_c/frontend/default'); $smarty->setCacheDir('C:/xampp/htdocs/testing/cache'); $smarty->setConfigDir('C:/xampp/htdocs/testing/configs'); ?>test.php <?php //$success = 'Success Message'; //$error = 'Error Message'; $errors[] = 'Error one'; $errors[] = 'Error two'; $smarty = new Smarty; //$smarty->assign('success', $success); //$smarty->assign('error', $error); $smarty->assign('errors', $errors); $smarty->display('test.tpl'); ?>test.tpl {if !empty($errors)} <div id="errors"> {section name=i loop=$errors} {$errors[i]}<br /> {/section} </div> {/if} I have hardware setup to preform an action on camera when i enter a url into the address bar. Pretty much you will be able to feed tarantulas. I'd like to setup a button that my user can click that will active the url without being moved off of the current page. I can't figure out how to stop the browser from following the link to a blank page. It messes the whole thing up because the feeder only runs for a second and if you get sent to the blank page and have to navigate back the the live video feed page you could miss the feeding. Thanks for the help hello can i open file with name in another language rather than english. For example торта.jpg. How can i open that kind of file. I've tryed that <meta content="text/html" charset="utf-8" /> <?php $fh = fopen("торта.jpg", 'r'); fclose($fh); ?> but it's don't work. Help me pls! Alright I am so close but can not figure this out, thanks in advance for any help.
So what I am trying to do is take the input variables from a form and have them load a specific PDF .
<html> <body> <?php if( $_GET["startpoint"] || $_GET["endpoint"]) { $a = $_GET["startpoint"]; $b = $_GET["endpoint"]; echo "Your Startpoint is:". $_GET["startpoint"]. "<br />"; echo "Your Endpoint is: ". $_GET["endpoint"]. "<br />"; echo $a,$b,".pdf"; } ?> </body> </html>This is what I have and it works to display what the two points are what the final pdf file should be. The final echo generates the PDF name echo $a,$b,".pdf";How can I get it to load a file using this as a variable or the name it generates, thanks. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317065.0 Hello, I want to do, when someone click on button/link will open this: but not Save As, but Open. I know how to make simple form: <html> <body> <form action="edit.php" method="post" enctype="multipart/form-data"> <label for="file">File:</label> <input type="file" name="file" id="file" /> <br><br> <input type="submit" name="submit" value="Open"/> </form> </body> </html> But here You must click Browse, but I want to do like in photo: if You click on button, then at once will open form like photo. Many thanks, Tadas P.S. Sorry for my really bad English. Hi I've got this database I created with fields ProductId ProductName Image I've managed to get it to list the ID,productname, and Image urls in a list. My next step is to have the image field actually display an image and make it clickable: heres what I've done so far: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("productfeed", $con); $result = mysql_query("SELECT * FROM productfeeds"); echo "<table border='0'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Image</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; echo "<td>" . $row['ImageURL'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Heres what I want to do: Code: [Select] while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; // my changes beneath echo "<td>" . <a href="<?php echo $row['ImageURL'];?>"> <img src="<?php echo $row['LinkURL']; ?>"> </a>. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Can you guys point me in the right direction? Many thanks Hi guys <?php sleep(00); $handle = fopen("http://www.myurl.com/?bla=bla=bla" , "r"); fclose($handle); ?> How do i prevent this from outputing to a file on my server. I only need the url to be accessed to add a new row of data to my DB. Any Ideas? Regards Mark This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=308625.0 Hello all, i am go9090go. Today i made a domains for a jar file people can upload from my website. I made this to make the jar file close source and its easy to update. Now i made a java classloader and everything i made works. The classloader call a php document with the password and username. The pass and name will be checked inside a databse and if its inside i use header() to load the jar file. But when i just go to my main domain i get the index of the site and people can easly download the jar file without have to walk thru the php pass checker. So i want to place the jar file inside a protected folder,and i want that only way you get acces to this jar is by the php file. How can i get a file from a protected folder? here is the php used when the jar file is not inside a protected folder: <?php $DBName = "name";//name database $DBUser = "name";//user $DBPassword = "pass"; //passs $DBHost = "host"; //might be different mysql_connect($DBHost, $DBUser, $DBPassword); mysql_select_db($DBName); $username = $_GET['username']; $password = $_GET['password']; $IP = $_SERVER['REMOTE_ADDR']; $string = "Java"; $pos = strpos($agent, $string); if (!strpos($_SERVER['HTTP_USER_AGENT'], "Java")) { echo("Your Auth has been banned for trying to breach security."); //mysql_query("delete from users where username='$username'"); exit(); } $query = "select * from users where name='$username' and pass='$password'"; mysql_query($query); $num = mysql_affected_rows(); if ($num > 0) { header('Location:script/Script.jar'); } ?> now i want to use the header to a file inside a folder that is protected : so how can i make the header() methode to open script.jar inside a protected folder. The folder haves name and pass: blabla,balbla for exempel thanks for help Hello, this is my first post I hope you guys can help me out here, basically whats going on is I declare a variable "$diree" then I insert it in a function but its not getting recognized, here is the code: $institutea "some directory"; $dire = str_replace(" ","-",$institutea); # SETTINGS $max_width = 110; $max_height = 130; $per_page = 5; $page = $_GET['page']; $has_previous = false; $has_next = false; function getPictures() { global $page, $per_page, $has_previous, $has_next; if ( $handle = opendir($diree.'/') ) { // done changes here $lightbox = rand(); ?><table border="1"><tr><td> <form action="pro.php" method="post"> <?php echo "<ul id='pictures'>"; $count = 1; $skip = $page * $per_page; if ( $skip != 0 ) $has_previous = true; while ( $count < $skip && ($file = readdir($handle)) !== false ) { if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) $count++; } $count = 1; while ( $count < $per_page && ($file = readdir($handle)) !== false ) { if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) { if ( ! is_dir($dire .'/') ) { // done changes here mkdir($dire .'/'); // done changes here } if ( ! file_exists($dire .'/'.$file) ) { makeThumb( $file, $type ); } echo '<li>'; echo '<img src="'.$dire .'/'.$file.'" alt="" / width="110" height="110"><br/><input type="checkbox" name="food[]" value='.$file.'>'; // done changes here echo '</li>'; $count++; } } echo '</ul>'; ?> </td></tr><tr><td><div align="center"><input type="submit" value="Add"></div></td></tr> </tr></table></form> <?php while ( ($file = readdir($handle)) !== false ) { if ( !is_dir($file) && ($type = getPictureType($file)) != '' ) { $has_next = true; break; } } } } function getPictureType($file) { $split = explode($dire .'/', $file); $ext = $split[count($split) - 1]; if ( preg_match('/jpg|jpeg/i', $ext) ) { return 'jpg'; } else if ( preg_match('/png/i', $ext) ) { return 'png'; } else if ( preg_match('/gif/i', $ext) ) { return 'gif'; } else { return ''; } } function makeThumb( $file, $type ) { global $max_width, $max_height; if ( $type == 'jpg' ) { $src = imagecreatefromjpeg($file); } else if ( $type == 'png' ) { $src = imagecreatefrompng($file); } else if ( $type == 'gif' ) { $src = imagecreatefromgif($file); } if ( ($oldW = imagesx($src)) < ($oldH = imagesy($src)) ) { $newW = $oldW * ($max_width / $oldH); $newH = $max_height; } else { $newW = $max_width; $newH = $oldH * ($max_height / $oldW); } $new = imagecreatetruecolor($newW, $newH); imagecopyresampled($new, $src, 0, 0, 0, 0, $newW, $newH, $oldW, $oldH); if ( $type == 'jpg' ) { imagejpeg($new, $dire .'/'.$file); } else if ( $type == 'png' ) { imagepng($new, $dire .'/'.$file); } else if ( $type == 'gif' ) { imagegif($new, $dire .'/'.$file); } imagedestroy($new); imagedestroy($src); } ?> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320945.0 I'm trying to copy an existing file using a php script, run on the command line. I've tried copy() and also a script from the comments on copy() http://www.php.net/manual/en/function.copy.php#102320 No matter how I try to open the file I get " failed to open stream: No such file or directory". I tried changing the name of the file, and the ext, and both. The file does exist, and if I run cp old new, the file gets copied fine. Current code Code: [Select] <?php $source = '/www/documents/myfile.pdf'; $destination = '/www/documents/mypdf.pdf.bak'; copy($source, $destination); ?> Warning: copy(/www/documents/myfile.pdf): failed to open stream: No such file or directory in /www/cron/historic.php on line 3 Code: [Select] ~$ ls /www/hua/compucom113dev/client/documents/ myfile.pdf ~$ cp /www/documents/myfile.pdf /www/documents/myfile.pdf.bak ~$ ls /www/hua/compucom113dev/client/documents/ myfile.pdf myfile.pdf.bak I had chmod in the script at one point to make sure the directory had the permissions needed but it didn't make a difference so I removed it. I can add it back if someone can help explain what to set it to. I was doing 0777 then back to 0755 at the end. Hi, Is it possible to build a PHP Template page that selects and publishes a row of data from a MySQL Database when a linked is clicked? I would design: Template.php Text links (perhaps on homepage of navigation bar): ProductA, ProductB and ProductC If you click link ProductA Template.php would display data for ProductA and likewise for ProductB and ProductC. I would also like search engines for find ProductA, ProductB and ProductC PHP pages. (Not just my single Template.php) Any ideas as to how this could be done without designing individual PHP pages for each product? Kind regards, Matthew. |