PHP - Prevent Window From Clipping Vertically & Horizontally Positioned Image
I have a vertically and horizontally centered image within a window. The layout as is perfect. The only issue is that when the window is resized, the image is clipped by the browser window. I wanted the image to remain 100% within the scroll bars of the window, so the page can be scrolled, so you can access any part of the image with the scroll bars.
Development URL: http://www.tinasguitar.com/develop/
(Resize the window and you'll see what I mean.
CSS and HTML follow:
article, aside, figure, footer, header, hgroup, main, menu, nav, section{display: block;} body{ padding: 0; margin: 0; margin: 0 auto; text-align: center; background-color: #dcdcdc; } #wrapper { top: 50%; left: 50%; margin-top: -333px; /* Half the height */ ; /* Half the width */ position: absolute; } #bgImage { width: 960px; height: 667px; background: url("http://www.tinasguitar.com/bg.jpg"); } #socialBar { position: absolute; top: 80px; left: 100px; } #socialBar img { width: 33px; height: 33px; background-image: url("http://www.tinasguitar.com/social.png"); background-repeat: no-repeat; margin-left: 10px; } #twitter { background-position: -34px 0px; } #fb { background-position: -102px 0px; } #yt { background-position: -68px 0px; } #gp { background-position: 0px 0px; } <!DOCTYPE html> <html lang="en-US"> <head> <base href="http://www.tinasguitar.com/" /> <title>Tina S.</title> <meta charset="utf-8" /> <meta content="" name="keywords" /> <meta content="" name="description" /> <meta content="index, follow" name="robots" /> <link href="/develop/style.css" rel="stylesheet" type="text/css" /> </head> <body> <section id="wrapper"> <img src="transparent.png" id="bgImage" name="bgImage" usemap="#vigierguitars"> <div id="note">This is an unofficial fan site that links to Tina's official social networking pages. The owner of this site has no affiliation with Tina.</div> <div id="socialBar"> <a href="https://twitter.com/Tina_S__"><img alt="Twitter" id="twitter" name="twitter" src="transparent.png" title="Twitter" /></a> <a href="https://www.facebook.com/pages/Tina-S/181555232026760"><img alt="FaceBook" id="fb" name="fb" src="transparent.png" title="FaceBook" /></a> <a href="https://plus.google.com/+TinaS"><img alt="Google+" id="gp" name="gp" src="transparent.png" title="Google+" /></a> <a href="https://www.youtube.com/user/malabar777"><img alt="YouTube" id="yt" name="yt" src="transparent.png" title="YouTube" /></a> </div> </section> <map name="vigierguitars"> <area shape="rect" coords="700,520,865,620" href="http://www.vigierguitars.com/" alt="Vigier Guitars" target="_blank"> </body> </html>Basically I need to some how create a hard border that the browser window observes as the definitive borders of the page, so the browser window can't clip off portions of the image. Similar TutorialsHi, On a website, there are products nicely listed with name, description, product code, price and a thumbnail etc. Now, if you click on a picture thumbnail, a new page called prodwin.php in a new window opens with the product code and for some reason, there is a "no picture available" alt image for every product. The line of code in it: <td colspan="2"><?php if(file_exists("../pics_p/".$HTTP_GET_VARS["PCode"].".jpg")){?><img src="../pics_p/<?php echo $HTTP_GET_VARS["PCode"] ?>.jpg" alt="Product Picture" galleryimg="no"><?php }else{?><img src="../imgz/nopic.jpg" alt="No Picture Available" width="306" height="200" galleryimg="no"><?php }?></td> The URL of that page looks like this: http://www.lock-tech.co.uk/scrptz/prodwin.php?SCode=CHL8K119S&PCode=CHL8K119S&PDescription=+DOOR%20PATIO%20LOCK&KEY%20SATIN&thePrice=%A328.52%20/%20EA On the other hand, when you click on the product name, it loads a different page called g_browse.php and the product image is nicely there. The line of code in it: <td height="366" colspan="2" valign="top"><?php if(file_exists("pics_p/".$array[$getVars["index"]]["PCode"].".jpg")){?><img src="pics_p/<?php echo $array[$getVars["index"]]["PCode"] ?>.jpg" alt="Product Picture" galleryimg="no"><?php }else{?><img src="imgz/nopic.jpg" alt="No Picture Available" width="306" height="200" galleryimg="no"><?php }?></td> Code: [Select] $HTTP_GET_VARS["PCode"].".jpg" - Product code + .jpg will give the image name in pics_p folder. a JavaScript block which might also be relavant: Code: [Select] function prodWindow(SCode, PCode, PDescription, thePrice) { var xPos=(screen.availWidth/2)-490; var yPos=(screen.availHeight/2)-116; var s=",top="+yPos+",left="+xPos; var win=open("scrptz/prodwin.php?SCode="+SCode+"&PCode="+PCode+"&PDescription="+PDescription+"&thePrice="+thePrice,'product', "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,height=414,width=316"+s); win.focus(); } Hope someone spots the problem. Regards, laanes This sounds stupid, i know. I want to create a foreach loop that will display 3 records per row. For example when you go on play.com and you query something you get a tile view of items. Can anyone help me? Hi, sincerely hope i can get some help here. im pulling some images from my database but i want to display them horizontally for example 3 or 4 images in a row then it moves to a new row. so far i have only being able to display the images vertically. I am not sure if i should be using css or there is a way to do it with php. would appreciate any assistance. I have been tryin to get this done for sometime now and i need to complete this project. I'm new at this I'm realitivly new to PHP and was hoping somebody could help. I have a mysql database that stores information about books. I am currently using the code below to query the database and extract the 3 most recent entries and showing them in a dynamic list: Code: [Select] $sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 3"); $productCount = mysql_num_rows($sql); if ($productCount > 0) { // ensure a book exists while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $title = $row["title"]; $author = $row["author"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamiclist .= //My table showing the products } } else { $dynamicList = "There are currently no Books listed in this store"; } This works well when showing the most recent books 1 below the other. However, I would like to show these products side by side, horizontally across the page. Can somebody please point me in the right direction? Many thanks I have implemented this slider http://kgperazim.com/test/film2 , however I'd like my header and footer to stay on screen whenever I'm scrolling horizontally.
What would be the best solution to do that with css?
Thx for any advice.
Hi Guys! Trying to display data in 3 rows horizontally and 25 vertiacally Code: [Select] // Print out result while($row = mysql_fetch_array($result)){ echo "There are ". $row['COUNT(biddersId)'] ." bidders logged."; echo "<br />"; } $query = "SELECT * FROM bidders ORDER BY biddersId"; $result = mysql_query($query) or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Bidders</th>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo"<font face= \"calibri\" size=\"3\">"; echo $row['biddersId']; echo "</br>"; echo "</td><td>"; } echo "</table>"; ?> I´ve reached to
<?php require_once('Connections/conexxion.php'); ?> <?php mysql_select_db($database_conexxion, $conexxion); $query_consulta = "SELECT venta,compra,taller,regula_mas,regula_menos,movimiento.id_item,sum(compra+regula_mas-venta-taller-regula_menos) as stock, cilindro, esfera FROM movimiento join item on item.id_item=movimiento.id_item join rx on rx.id_rx=item.id_rx join cilindro on cilindro.id_cil=rx.id_cil join esfera on esfera.id_esf=rx.id_esf GROUP BY movimiento.id_item ORDER BY esfera desc, cilindro desc"; $consulta = mysql_query($query_consulta, $conexxion) or die(mysql_error()); $row_consulta = mysql_fetch_assoc($consulta); $totalRows_consulta = mysql_num_rows($consulta); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>test</title> </head> <body> <?php echo "<table align=center>"; $columnes = 10; # Número de columnas (variable) if (($rows=mysql_num_rows($consulta))==0) { echo "<tr><td colspan=$columnes>No hay resultados en la BD.</td></tr> "; } else { echo "<tr><td colspan=$columnes>$rows Resultados </td></tr>"; } for ($i=1; $row = mysql_fetch_row ($consulta); $i++) { $resto = ($i % $columnes); # Número de celda del <tr> en que nos encontramos if ($resto == 1) {echo "<tr>";} # Si es la primera celda, abrimos <tr> echo "<td>$row[1]</td>"; if ($resto == 0) {echo "</tr>";} # Si es la última celda, cerramos </tr> } if ($resto <> 0) { # Si el resultado no es múltiple de $columnes acabamos de rellenar los huecos $ajust = $columnes - $resto; # Número de huecos necesarios for ($j = 0; $j < $ajust; $j++) {echo "<td> </td>";} echo "</tr>"; # Cerramos la última línea </tr> } mysql_close($connexion); echo "</table>"; ?> </body> </html> <?php mysql_free_result($consulta); ?>it "works", but results doesn´t start at number 1 but number 2 anyways, The intent of this table is to show the stock of a product, a lens, that has a range of Rx, we use to see this range this way, and show the stock this way would be very productive, but I can´t figure out how to achive it, any sugestion?? Edited by gralfitox, 16 December 2014 - 06:45 AM. Scenario :
I would like to open the main program window and at the same time, if a condition is met, open a second - popup window to alert the user of previous information stored in the database.
This is an easy exercise if I use a hyperlink to open th second (popup) window but this is not the process required .
Can someone point me in the right direction ?
Cheers and thanks
I'm wondering what makes a pop-up login window run differently than inside a webpage. I can't seem to get my login system to bring the user back to the page (brings them to a page can't be found) when clicking a form submit button when it is included in the webpage. But if your in the popup page that I'm trying to include, it works no problem so I was wondering if it changes anything. Or if there is some sort of work around (such as embedding a popup window into the webpage). Thanks a lot! Hello Guys, Iam making a new ad serving script. In that site every publisher can register & they will get a url to serve ads. When a user click on that url the publisher will get earnings. But my problem is someone using something like this <iframe src="http://my-site.com/adserve.php" width = "100" height = "100"></iframe> & it will helps to get earnings without clicking on that url. I want to prevent this type of cheating & how it can be possible ?? I hope a expert will replay for me. Hi is there any way we can prevent suppose <textarea></textarea> when page reload it refresh and set default text i wanted to know is there any way to prevent certain things not to get refreshed is there any method in php which prevent to reload this ! <?php echo "<textarea > Enter your favorite quote!</textarea> \n" ; Code: [Select] if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate'){ } <a href= \"{$_SERVER['PHP_SELF']}?page=1&edit=textupdate \" >Click</a>?> Is this a correct approach to prevent email injection? $to: me@mydomain.com, myPartner@mydomain.com, $emailer; //then the rest of the stuff. $emailCheck = $_POST["emailer"]; if (eregi("(\r|\n)", $emailCheck)) { die("Why ?? "); } mail($to, $subject, "", $headers); As the title says, I would like to know how exactly CSRF can be 100% (or close to it) prevented.
One of the most recommended solutions is to create a token and insert it into a hidden field, but I've tested it on another domain and you can just do a cURL request and retrieve the token then make another request with it included. Proof:
<?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "URL"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $response = curl_exec($ch); curl_close($ch); $exploded = explode('type="hidden" name="token" value="', $response); $token = substr($exploded[1], 0, 64); echo $token; // ebd9ab96d40bdb21bbaa2e1a18d657be2e413105ae86ecc14def6137f38a1571 ?>I would hate to include captcha on all my forms, so how exactly does one prevent CSRF? Based on the comments on my previous question, took some tutorials on how to avoid injections on query. Does the code below prevents against it in any way.? Secondly, can you recommend a good article that writes well in how to secure input data by users. Please be kind with your comments.😉😉. Thankks in advance.
The code works fine. <?php include 'db.php'; error_reporting(E_ALL | E_WARNING | E_NOTICE); ini_set('display_errors', TRUE); if(isset($_POST['submit'])) { $username = $_POST['username']; $password = ($_POST['password']); $sql = "SELECT * FROM customer WHERE username = ?"; $stmt = $connection->prepare($sql); $stmt->bind_param('s', $username); $stmt->execute(); $result = $stmt->get_result(); $count = $result->num_rows; if($count == 1) { while ($row = $result->fetch_assoc()) { if ($row['status'] == 'blocked') { echo'your account is suspended' session_destroy(); exit(); } else if($row['status'] == 'active') { if($username !== $row['username']) { echo '<script>swal.fire("ERROR!!", " Username is not correct. Check Again", "error");</script>'; } if($password !== $row['password']) { echo'<script>swal.fire("ERROR!!!", "Your Password is Incorrect. Check Again.", "error");</script>'; } if($username == $row['username'] && $password == $row['password']) { header('Location:cpanel/'); else { } }//if count }//while loop }//submit ?>
Will this prevent a SQL injection? I am guessing the answer is no because it is too simple. // retrieve form data ========================================== $ama = $_POST['ama']; // Check for alphanumeric characters ===================================== $string = "$ama"; $new_string = preg_replace("/[^a-zA-Z0-9\s]/", "", $string); // echo $new_string; // Send query =========================================================== $query = "SELECT * FROM members WHERE ama='$new_string'"; if (!mysql_query($query)){ die('Error :' .mysql_error()); } I am loading a link with ajax. When the link pops on the screen and I click it, I get redirected to my 404 page and my lightbox doesn't load. If the link pops in and I refresh my browser, then I click the link my lightbox will show up. How can I do a prevent default on the <a href> in pure JS? No frameworks please. $_POST['user_name'] = "CLUEL3SS"; $_POST['user_pass'] = "test123"; $_POST['confirm_pass'] = "test123"; $_POST['user_email'] = "user@email.com"; $_POST['confirm_pass'] = 'user@email.com'; function testFunc($inputVars){ foreach($inputVars as $key=>$value){ $escapeData[$key] = mysql_real_escape_string($value); } return $escapeData; } var_dump(testFunc($_POST)); I'm trying to make a user system for my site and I want to make sure its secure enough to void off injection attackers. Any useful advice and and suggestions would be greatly appreciated! Thanks! Hello all, A simple question: I have a HTML application from which a php script is executed. 'GET' method is used and no form is submitted. I was wondering if there is a way to prevent users from run this php script directly in the browser. Thank you all for your suggestions, Mamer How can I prevent the less than and greater than signs in the username field, and message on the post? As well as slashes. / \. Code: [Select] <form method="post" action="" id="reply"> <script type="text/javascript"> function hi(id){ var val = id.options[id.selectedIndex].value; var text = id.options[id.selectedIndex].text; if (val.length != 0){document.getElementById('user').value = text;hide('passrow');} else { document.getElementById('user').value = ''; document.getElementById('passrow').style.cssText = ''; } } </script> <div id="userpass" style="background: #000;"> <table style="border: 2px solid #252564; background: #1F1F5D;" width="100%" cellpadding="0" class="quick_userpass"> <tr> <td background="/images/bg3.jpg" height="26px"><font face=arial size=2 color="white"> <b>Your Name or Nickname</b></td> </tr> <tr> <td><input size=50 name="user" id="user" value="" style="margin-left: 10px;"></td> </tr> <tr><td background="/images/bg3.jpg" height=26px></td></tr> </table> <div id="passrow" style=""> <p> <table width=100% cellpadding=0 class="quick_userpass" style="border: 2px solid #252564; background: #1F1F5D;"> <tr><td background="/images/bg3.jpg" height=26px style=""><font face=arial size=2 color="white"> <b>Password (optional)</b></td></tr> <tr><td style=""><input size=50 name="pass" id="pass" type="password" style="margin-left: 10px;" value=""></td></tr> <tr><td background="/images/bg3.jpg" height=26px></td></tr> </table> </p> </div> <p> <table width=100% cellspacing=0 cellpadding=4 class="quick_userpass" style="border: 2px solid #252564; background: #1F1F5D;"> <tr bgcolor="#121236"><td><font face=arial size=2 color="white"><b>Enter your message here</b></font></td></tr> <tr><td><center><textarea id="quickreply" name="message" rows=10 cols=50 wrap="VIRTUAL" ></textarea></center></td></tr> </table> <div id="preview" style="display: none;"></div> </p> <br /> <center> <font face=arial size=2>When you're happy with your message, click:</font> <div id="javano"><input type="submit" value=" Post Message "></div> </center> <input type="hidden" name="tid" value="<?php echo $_GET["tid"];?>" /> </div> </form> That is the code I'm using for User/Pass/message fields. |