PHP - Detected Browser
hi
i was wondering if anyone has any idea how to get this code to work for more then one browser? i can get it to work for one browser but have no luck on getting it to work for more then one browser thanks... code that don't work: Code: [Select] <?php include("browserDetection.php"); $user_browser = browser_detection('browser'); if ( $user_browser == 'mozilla' ) { echo("<link href='style.css' type='text/css' rel='stylesheet'></link>\n"); } else { echo("<link href='style1.css' type='text/css' rel='stylesheet'></link>\n"); } if ( browser_detection('msie') ) { echo("<link href='style.css' type='text/css' rel='stylesheet'></link>\n"); } else { echo("<link href='style1.css' type='text/css' rel='stylesheet'></link>\n"); } ?>code that works: Code: [Select] <?php include("browserDetection.php"); $user_browser = browser_detection('browser'); if ( $user_browser == 'Mozilla' ) { echo("<link href='style.css' type='text/css' rel='stylesheet'></link>\n"); } else { echo("<link href='style1.css' type='text/css' rel='stylesheet'></link>\n"); } ?> Similar Tutorialsif I have a list of 5,000 bots and their server header into in my DBs, can someone point me to a web resource that can give me any insight into how to show a custom page if a bot is detected at the render request? I can look up PHP functions myself and possibly use header(), but didn’t know if anything special was involved that I don’t already know about. so, say for instance, as a joke I want to do this: <?php $ip = gethostbyaddr($_SERVER['REMOTE_ADDR']); if (substr($ip, 0, 3) = '10.') { echo 'sorry, but we do not display content to USA government's automated server sniffing bots.'; } ?> how much of a pain in the rear would it be to display custom pages for ‘‘x’’ number of automated hits? I realize that this is pointless because most are just from researching orgs the world over, but it IS a relevant question to ask. thanks. Hello everyone, I'm just starting out with PHP as I need to create an online bookstore for a school project. I'm working by a magazine which should teach you exactly how to do this using PHP, but I've had a bunch of problems with the code they use and I don't really know what's going on. Anyway, this looks really simple and basically what it does is allows you to post a comment on a book, then returns you to the book's page. Problem is, I'm getting the Header may not contain more than a single header, new line detected. error and I can't figure out why. I've tried researching into the matter but all the cases I found had to do with returning to an url, which is not my case. Anyway, here's the snippet of code: The form: Code: [Select] <div style="width:400px; border:1px solid #ffffff; background-color:#F9F1E7; padding:5px"> <b>Adauga opinia ta:</b> <hr size="1"> <form action="adauga_comentariu.php" method="POST"> Nume: <input type="text" name="nume_utilizator"><br><br> Email: <input type="text" name="adresa_email"><br><br> Comentariu: <br> <textarea name="comentariu" cols="45"></textarea><br><br> <input type="hidden" name="id_carte" value="<?=id_carte?>"> <center><input type="submit" value="Adauga"</center> </form> </div> The script adaugare_comentariu.php: Code: [Select] <?php ob_start(); include("conectare.php"); $numeFaraTags=strip_tags($_POST['nume_utilizator']); $emailFaraTags=strip_tags($_POST['adresa_email']); $comentariuFaraTags=strip_tags($_POST['comentariu']); $sql="insert into comentarii (id_carte, nume_utilizator, adresa_email, comentariu) values(".$_POST['id_carte'].", '".$numeFaraTags."','".$emailFaraTags."','".$comentariuFaraTags."')"; mysql_query($sql); $inapoi="carte.php?id_carte=".$_POST['id_carte']; header("location:urldecode($inapoi)"); ob_end_flush(); ?> conectare.php connects to the mysql database. $inapoi is the variable which returns the user to carte.php (the book he posted a comment on), where id_carte is the book's unique id. I'm getting Header may not contain more than a single header, new line detected on line ten, which is the header line. Can anyone help me? I've been stumped on this for a few days now and I've just let it pass and started working on other bits, but it's bugging me too much and I'd like to fix it. I'd like to use an application that's not browser based, on Internet Explorer. I've read somewhere that this is possible with a PHP script, but which one? If you can get me on the right track, I'd really appreciate it. Cheers. I am trying to come up with a script that will detect whether the requesting user agent is a bot or a browser, as their are so many bots and scripts around i have decided to go with the latter so i need a list of browsers that may be used to do the following Quote $browser_array = array(list of browsers..................); if(!in_array($_SERVER['HTTP_USER_AGENT'], $browser_array)) { output text; } else { output html; } so basically i am now stuck without a complete list of user agents so if anyone knows where i can find a list it would be much appreciated Hello PHPers, I need help regards obtaining the correct Host and IP address. Using all browsers except mozilla-firefox, I will received the correct IP address. But with Mozzilla-firefox I get the wrong Host and IP address back as 10.1.23.22 ..The code I have is $mj_ip = $_SERVER['REMOTE_ADDR']; $mj_host = gethostbyaddr($_SERVER['REMOTE_ADDR']); Cheers, HJ Hello,
I want to know how they keep the same url when page is changing, if you dont know what i mean try the link and check the browser when you wat happens when you click in a other link in the website.
( Website Link ( Normal Content ) ) http://geedmo.com/?item=LushSlider
Thanks in advance.
Hey there, I'm trying to set up a little ftp script to make it easier to upload files and add new folders for images and videos ect on a backend admin page however the following script just will not connect I keep getting the "Couldn't connect to 66.40.52.167" error so it's not even finding the server however when I put it into my browser it connects just fine, I've even pinged it and all works fine so I don't get it. $ftp_server = "66.40.52.167"; $ftp_user = "username"; $ftp_pass = "password"; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected as $ftp_user@$ftp_server\n"; } else { echo "Couldn't connect as $ftp_user\n"; } ftp_close($conn_id); Any ideas would be appreciated! Is there a way so when someone loads your website that it forces them to load it in a different browser? I got problem with one of my php page. Mozilla browser keeps on loading although it shows the page, i am not really sure which part is wrong. But i don't find any problem with other browsers lol. Can anyone help me please thanks in advance This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=314530.0 I need to use an if statement in conjunction with the browser name/type "Mozilla Firefox" vs "Google Chrome" to display certain scripts of CSS to a page. I am not sure how to do this. Any help would help, Brian Hi, I have tried a "Hello.php" to open in my web browser. It throws 404 file not found error. I am using Intranet. How to determine the web server I am using? Thanks. I have done some searching and digging, but it seems everyone has their own ways of doing things, some more effective than others. I have a web design portfolio website, which uses a "coinslider" flash slideshow. It looks awesome in FF, but IE6/etc users cant view it properly. How can I create a PHP if/then to detect if they are using a sub-par browser, and display a more simple slideshow? That way it will work for all users, and those with Firefox and similar browsers can view the more interesting slideshow. Thanks. I'm planning on writing a library script holding pdf files which will serve the purpose as ebooks in which people could search and open. I don't know for sure, but doubt that you can open a pdf file and make it readable in php. I've noticed adobe reader has managed to do it, and what method do they use to do so? OK, I'm nearing the end of a very long chat project and I have one last hurdle to jump, I've saved this task to the near end because I thought it would be a problem as I have no idea what to do or where to start. The problem is exactly what is said in the subject title. I have looked into JavaScript options such as "onbeforeunload" but that is just BAD. The login is controlled by sessions, so when the user closes the browser, the session is ended, but data in the database says different, cookies are not an option I'm afraid. I've had an idea that if I create a special account (or a few) and always leave these accounts logged in, they can check if a user has been inactive for a certain period of time, and then run queries to change things, I know this sound odd but maybe I will not have to create these accounts but general accounts that people make will be able to do this for me, without them even knowing. Please help, any ideas, suggestions, logic or methods that you think will help will be great. Thanks. how would you code a map for a browser game like travian? i know how it works but i cant code that sort of stuff. ive got my database set up like this x y player 1 1 1 2 etc.... so i when you click an arrow it will got to the next square along. Is there anything to worry if I see no SSL warning in my browser's address bar when I am in the logging credentials form?
hello, this is part of my contact form code. When i click on the submit button i need the form to take me to the $success_message or the $failure_message instead of the top of the page. I know i can do it with # tag or # id normally. But I do not know how to apply it to the form. Code: [Select] //some text and stuff<tr> <td> <? if(!empty($success_message)) { echo "<center><font color='blue'><b>".$success_message."</b></font><br></p>"; } if(!empty($failure_message)) { echo "<center><font color='red'><b>".$failure_message."</b></font><br></p>"; } ?> <? if((empty($_POST)) || !empty($strError)) { echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>"; ?> <form action="<?php echo $PHP_SELF;?>" method="post"> <tr height='40'> <td> <font color="black"><B> First Name: </B></font> </td> <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Last Name: </B></font></td> <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Email Address: </B></font></td> <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?> </td> </tr> <tr height='35'> <td><font color="black"><B> Business Name: </B></font></td> <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?> </td> </tr> <tr> <td><font color="black"><B> Business Description: </B></font></td> <td ><textarea rows=7 cols=31 name="description" class="advertising-textarea-style"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea> <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?> </td> <tr height='35'> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </form> I'm not sure if JS or PHP is causing my browser to lock up when I access this page. I have a database of zipcodes ... approx. 70,000 of them. I have a php loop put them into a JS array. I then want JS to create a drop down with all the zip codes. On Chrome it completely doesn't work. On FF it will loop to about 64,000 and then give a warning that the script is taking too long. Reading up on google it seems that JS should be able to handle an array much bigger then mine... so what could be he problem? <script language="javascript"> function addOption(selectbox,text,value ) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; selectbox.options.add(optn); } <?php //TESTING $con = mysql_connect("","",""); mysql_select_db("", $con); //END TESTING $data = mysql_query("SELECT postalCode FROM geo_city WHERE postalCode !='' ORDER BY postalCode ASC") or die(mysql_error()); echo 'function addOption_list(selectbox){ var zip = new Array("VOID"'; while($info = mysql_fetch_array($data)){ echo ',"'.$info['postalCode'].'"'; } echo ');'; ?> for (var i=0; i < zip.length;++i){ addOption(document.drop_list.zip_list, zip[i], zip[i]); } } </script> </head> <body onLoad="addOption_list()";> <FORM name="drop_list" action="" method="POST" > <SELECT NAME="zip_list"> <Option value="" >Zip Code list</option> </SELECT> </form> If I were to write a code where the browser details and resolution are to be displayed, would the following code work? Code: [Select] //Here, I am using the "</body>" tag to end the body of the webpage and the "</html>" tag to end the HTML script </body> </html> //By using the "<?php" code, I am creating a PHP script and when I use the "function" keyword here, I am creating a function called Identification with no arguments in the parameters <?php function Identification() //Here, I am creating a variable called "$viewer" //The value of this variable uses the "getenv" library function and the "HTTP_USER_AGENT" is what the "getenv" library function will be performed on and the value of this is that value of the $viewer attribute //The code uses the ";" to end the command $viewer = getenv ("HTTP_USER_AGENT"); $width= $_get['width']; $height=$_get['height']; //Here, I am using the "echo" library function and the "$viewer" attribute as well as the "<b> (bold)" tags to write a formatted string to the webpage //I then use the ";" to end the command and I use "?>" to end the PHP script $msg = "Browser details: $viewer"; $msg .= "Resolution is $width pixels long and $height pixels high"; echo ($msg); ?> //Here, I am using the "<html>"<head"> and "<title>" tags as well as the "</head"> and "</title>" so that I can write a title (Browser + Platform Identification Script) for the webpage that the script will be shown on <html><head><title>Browser + Platform Identification Script</title></head> //Here, I am using the "<body>" tag to create the body of the webpage <body> //Here, I am using the "<?php" code so that I can start a PHP script that will run the Identifcation script and show the results on a webpage <?php Identification() //I then use the "}?> to end the PHP script ?> //Here, I am using the "</body>" tag to end the body of the webpage and the "</html>" tag to end the HTML script </body> </html> Thanks, Andrew |