PHP - Using Php To Transmit/write Characters To A Usb Port Device At 9600 Baud Rate
Hello guys,
I am new to PHP programming. I am trying to figure out how to use PHP language to transmit/write characters to a USB port device at 9600 baud rate 8-N-1. Basically I just need the PHP coding to allow me to send stuff to the USB device but I have no idea how I can interface this. I did some researching but most were for RS-232 COM Port. I can't find the proper one for USB. If someone can help me out, that would be awesome. Thank you! Similar TutorialsI have a small project. I have a control board that is connected to the parallel port. It controls 8 strips of LED on the LPT1 port. I can turn these on and off via the command prompt, using LPTOUT.exe ie lptout 1 turns on the 1st LED lptout 2 will turn off 1st LED and turn on 2nd, lptout 4 turns on 3rd and 2nd off, etc 1, 2, 4, 8, 16, 32, 64, 128. and combinations ie lptout 3 turns on LEDS 1 and 2, and so on. However lptout seems very unresponsive sometimes I have to do lptout 1 twice before LED 1 turns on. Is there another command I can use to write to LPT1 port. I need some PHP code to control the outputs. I want to sequence the outputs ie 1on (1second) 2on (1 second) 3 on (1 second) 4 on etc. to 8, then all off then repeat. Can anyone help me. THANK YOU. Hi, I upgraded my XAMPP to the version 1.8.3 (win32) recently. Apache failed to start and I got the following error I have 2 servers I use for hosting, both Linux and Apache. I am executing the same php script on both, the one server the information is sent to me as it is processed, the other it only sends when it is finished processing the script. How can I change it so that it sends me the stuff as it processes it, and not right at the end? Thanks Do any one have an Idea on how to transmit xml or json from one site to another with php4......... any help please.. Thanks in advance Is it possible to retrieve a visitor's iPhone device id? If so, how? If it's not possible, do all iPhones accept cookies? Hello. I have written this script where user restaurant owner can add his place to the database of all local restaurants. (insert basic information into database, add up to 3 images, thumbnail creation, insert image information to database). It works well on localhost, but i would like some suggestions for improvement. Im not very sure of its structure, it may not execute well once it is online. And i also think there are too many "IF's". But i really have no idea how to do it any other way. Thanks for all the suggestions. Code: [Select] <?php if(!defined('PROTECTION') || constant('PROTECTION') != 'demover') { echo "fuck off intruder!"; exit; } $naziv = mysql_real_escape_string($_POST['Naziv']); $naslov = mysql_real_escape_string($_POST['Naslov']); $kraj = mysql_real_escape_string($_POST['Kraj']); $telefon = mysql_real_escape_string($_POST['Telefon']); $web = "http://www.".mysql_real_escape_string($_POST['Spletna']); $gm = mysql_real_escape_string($_POST['Lokacija']); //$gmaps = gmParse($gm); $gmaps = 10; $fill="INSERT INTO bpoint (sName, sAddr, placeID, sPhone, sWeb, sGMaps, companyID) VALUES ('$naziv','$naslov','$kraj','$telefon','$web','$gmaps','$cID')"; if (mysql_query($fill)) { $lastID=mysql_insert_id(); $path="./truck/".$cID."/".$lastID; $pname=$_FILES["pic"]["tmp_name"]; $num=0; if (count($_FILES["pic"]) && mkdir($path, 0777)) { include "thumbs.php"; foreach($pname as $imag){ $bname=date("YmdHis").$num; $num++; $finalpath=$path."/".$bname.".jpg"; $finalthumb=$path."/".$bname."_thumb.jpg"; if($imag!="") { if (move_uploaded_file($imag, $finalpath)) { make_thumb($finalpath,$finalthumb,150); mysql_query("INSERT INTO images (name, companyID) VALUES ('$finalpath', '$cID')"); } } } } unset($_FILES["pic"]); } else {die(mysql_error());} ?> I'm trying to detect a user's mobile handset when he visits my web page. So on my web page, I have placed this Javascript code: How do you establish a tax rate in a MySQL database to use in a form calculation, then be able to change the value to a new constant value from the form? Hi, I am trying to store the view rate of articles so that I can retrieve them later on by "the most popular". I have searched around but cannot find a straight answer. Can anyone point me towards the right direction? Edit: Never mind, I was over complicating the logic behind this. Hi, how can i detect if my website is being open in mobile type all devices instead of computer Please help function wsProcessClientMessage($clientID, $opcode, &$data, $dataLength) { global $wsClients; // check opcodes if ($opcode == WS_OPCODE_PING) { // received ping message return wsSendClientMessage($clientID, WS_OPCODE_PONG, $data); } elseif ($opcode == WS_OPCODE_PONG) { // received pong message (it's valid if the server did not send a ping request for this pong message) if ($wsClients[$clientID][4] !== false) { $wsClients[$clientID][4] = false; } } elseif ($opcode == WS_OPCODE_CLOSE) { // received close message if (substr($data, 1, 1) !== false) { $array = unpack('na', substr($data, 0, 2)); $status = $array['a']; } else { $status = false; } if ($wsClients[$clientID][2] == WS_READY_STATE_CLOSING) { // the server already sent a close frame to the client, this is the client's close frame reply // (no need to send another close frame to the client) $wsClients[$clientID][2] = WS_READY_STATE_CLOSED; } else { // the server has not already sent a close frame to the client, send one now wsSendClientClose($clientID, WS_STATUS_NORMAL_CLOSE); } wsRemoveClient($clientID); } elseif ($opcode == WS_OPCODE_TEXT || $opcode == WS_OPCODE_BINARY) { // received text or binary message if (function_exists('wsOnMessage')) wsOnMessage($clientID, $data, $dataLength, $opcode == WS_OPCODE_BINARY); } else { // unknown opcode return false; } return true; } Php Folks, I started learning php originally from 2015. On & off. Part time. Started getting into it seriously around 2017. From home. No classes. From forums and php manual and tutorial sites. Still at oop & mysqli. Had ups & downs as first learnt a lot of old stuffs then found out they been deprecated. For example, if I had originally known pdo is modern over mysqli then I would started on pdo from beginning. Got no real guidance anywhere. Just learnt things the hard way, coming across obstacles and bugging forums. Half-way learning mysqli I come across pdo. So you see, if I had taken school classes then they would have started me on the new stuffs. But because I learning from home, I came across a lot of old tutorials and started from there without knowing they are sort of outdated stuffs. Anyway, I don't like quitting half-way and so did not quit mysqli for pdo when a lot of programmers advised me to dump mysqli for pdo. Thought, since I "wasted time" on mysqli then might aswell build a few sites with it before ditching it. Part time study. Full time working on projects for 3yrs now. projects are own "hobby sites" so to speak and not for clients. I am not the freelancer type or professional type. layman type. Never really have launched any sites. I finish one site/project then move onto another project for learning purpose. So I learn very little then moving onto building sites based on what little I learnt. When I learnt how to use the SELECT, INSERT. DELETE, UPDATE in sql, I jumped into learning to build my own membership site (reg, log-in, logout, etc. pages) to deal with mysql db. So far, built membership parts (login, logout, account homepage, pagination). All by copying codes from tutorials and forums from people like you and changing here and there according to my needs. And when I get stuck. I bug programmers like you. I do have a conscious and do not like plagiarism even while learning and so everytime I copy paste codes from tutorials or forums (where I get help), I retype every line and then delete the copy-pasted lines and leave my typed lines in the file. that way, I feel good I atleast made some effort to build the site rather than copy & paste. Then, I change the codes here and there to suit my purpose. Don't you like me ? ;). You probably chuckling inside reading this. Here's an example of how I copy-paste then re-write the lines. <?php //Code from: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_login_form ?> <!DOCTYPE html> <!DOCTYPE html> <html> <html> <head> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> <style> body {font-family: Arial, Helvetica, sans-serif;} body {font-family: Arial, Helvetica, sans-serif;} form {border: 3px solid #f1f1f1;} form {border: 3px solid #f1f1f1;} input[type=text], input[type=password] { input[type=text], input[type=password] { width: 100%; width: 100%; padding: 12px 20px; padding: 12px 20px; margin: 8px 0; margin: 8px 0; display: inline-block; display: inline-block; border: 1px solid #ccc; border: 1px solid #ccc; box-sizing: border-box; box-sizing: border-box; } } button { button { background-color: #4CAF50; background-color: #4CAF50; color: white; color: white; padding: 14px 20px; padding: 14px 20px; margin: 8px 0; margin: 8px 0; border: none; border: none; cursor: pointer; cursor: pointer; width: 100%; width: 100%; } } button:hover { button:hover { opacity: 0.8; opacity: 0.8; } } .cancelbtn { .cancelbtn { width: auto; width: auto; padding: 10px 18px; padding: 10px 18px; background-color: #f44336; background-color: #f44336; } } .imgcontainer { .imgcontainer { text-align: center; text-align: center; margin: 24px 0 12px 0; margin: 24px 0 12px 0; } } img.avatar { img.avatar { width: 40%; width: 40%; border-radius: 50%; border-radius: 50%; } } .container { .container { padding: 16px; padding: 16px; } } span.psw { span.psw { float: right; float: right; padding-top: 16px; padding-top; 16px; } } /* Change styles for span and cancel button on extra small screens */ /* Change styles for span and cancel button on extra small screens */ @media screen and (max-width: 300px) { @media screen and (max-width: 300px) { span.psw { span.psw { display: block; display: block; float: none; float: none; } } .cancelbtn { .cancelbtn { width: 100%; width: 100%; } } } } </style> </style> </head> </head> <body> <body> <h2>Login Form</h2> <h2>Login Form</h2> <form action="/action_page.php" method="post"> <form action="/action_page.php" method="post"> <div class="imgcontainer"> <div class="imgcontainer"> <img src="img_avatar2.png" alt="Avatar" class="avatar"> <img src="img_avatar2.png" alt="Avatar" class="avatar"> </div> </div> <div class="container"> <div class="container"> <label for="uname"><b>Username</b></label> <label for="uname"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="uname" required> <input type="text" placeholder="Enter Username" name="uname" required> <label for="psw"><b>Password</b></label> <label for="psw"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="psw" required> <input type="password" placeholder="Enter Password" name="psw" required> <button type="submit">Login</button> <button type="submit">Login</button> <label> <label> <input type="checkbox" checked="checked" name="remember"> Remember me <input type="checkbox" checked="checked" name="remember"> Remember me </label> </label> </div> </div> <div class="container" style="background-color:#f1f1f1"> <div class="container" style="background-color:#f1f1f1"> <button type="button" class="cancelbtn">Cancel</button> <button type="submit" class="cancelbtn">Cancel</button> <span class="psw">Forgot <a href="#">password?</a></span> <span class="psw">Forgot <a href="#">password?</a></span> </div> </div> </form> </form> </body> </body> </html> </html> One thing I gain from this type of re-writings is that, typing the same thing over and over again sort of gets codes sink into my subconscious. Helps to memorise the codes. Ok. So now you know a little about me. As you can see, I always start on somebody else's skeleton, be it from a tutorial forum or a tutorial site or php manual. I have completed 3 websites, so to speak, in that way. 2 days ago I thought, I been doing this for 3yrs now. Let's test and see how well I can code without working on somebody else's skeleton. No copy-pasting from forums or tutorial sites or php manual. And so, look what I did. I coded all the following from my own memory. let me know how well I did. That repetition of lines re-writing has done me some good to memorise codes. I did make 2 mistakes. Note the comments in the code. You will notice "MY CODE ..." and then a correction "WHAT IT SHOULD BE ...". Compare the 2 and see how close or far away I was from the correction. And then give me score from 1-10 (where 10 is best) how well I did as a home study middle aged guy. Hard learning things at middle age. I think, if I had toild you I started learning a month ago then you'd give 9/10 but because it's been 3 yrs, you'll give 1/9 or 0. Just bear in mind it's not easy to learn things at middle age and remember them without forgetting. I learn fast but forget double fast. Lol! One thing though. My codes are not working. They do not INSERT data into db nor extract & display data from db. What is wrong ? TEST NUMBER 1: On this one, I first tried displaying data rows from mysql using mysqli_stmt_get_result(). That failed and so I tried with mysqli_stmt_bind_result() afterwards and so bear that in mind and don't ask me why I used both instead of one. Clicking the "search" button gives no response. Nothing happens on page. I did search for a ketywords that exist in each mysql tbl columns. <?php include('error_reporting.php'); require('conn.php'); //require('search_form.php'); ?> <form name = "search" method = "POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="keywords">Keywords:*</label> <input type="text" name="keywords" id="keywords" placeholder="Input Keywords" required> <br> <label for="search_column">Search in ... ?</label> <select name="search_column" id="search_column"> <option value="page_url">Page Url</option> <option value="link_anchor_text">Link Anchor Text</option> <option value="page_description">Page Description</option> <option value="keyphrase">Keyphrase</option> <option value="keywords">Keywords</option> </select> <br> <label for="tos_agreement">Agree to TOS or not ? *</label> <select name="tos_agreement" id="tos_agreement" required> <option value="Yes">Yes</option> <option value="No">No</option> </select> <br> <input type="button" name="search_links" id="search_links" value="Search Links!"> <br> <input type="reset"> <br> </form> <?php if($_SERVER['REQUEST_METHOD'] === 'POST') { if(ISSET($_POST['search_links'])) { $_POST['page_url']; $_POST['link_anchor_text']; $_POST['page_description']; $_POST['keyphrase']; $_POST['keywords']; //I WROTE 2 QUERIES HERE AS I WASN'T SURE HOW IT SHOULD BE. FINALLY, STUCK TO THE LATTER. HOWEVER, ON TESTS NONE OF THEM WORK! //QUERY 1. $query = "SELECT FROM links (page_url,link_anchor_text,page_description,keyphrases,keywords) WHERE keywords = ?"; //QUERY 2... $query = "SELECT page_url,link_anchor_text,page_description,keyphrases,keywords FROM links WHERE page_url = ?, link_anchor_text = ?, page_description = ?, keyphrases = ?, keywords = ?"; $stmt = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'sssss',$_POST['page_url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keyphrase'],$_POST['keywords']); //WRONG: FORGOT TO ADD "$result = " ... //mysqli_stmt_bind_result($stmt,$page_url,$link_anchor_text,$page_description,$keyphrase,$keywords); //CORRECTION: WHAT IT SHOULD BE ... $result = mysqli_stmt_bind_result($stmt,$page_url,$link_anchor_text,$page_description,$keyphrase,$keywords); //mysqli_stmt_execute($stmt);WRONG! THIS LINE SHOULDN'T EXIST UNLESS IT'S mysqli_stmt_get_result(). mysqli_stmt_fetch($stmt); //WASN'T SURE WHICH OF THE 3 FOLLOWING LINES ARE CORRECT REGARDING THE WHILE LOOP. FINALLY, STUCK TO THE 1ST LINE ... //1)... while(mysqli_stmt_fetch($stmt)) //2)... //while(mysqli_fetch_array($stmt,mysqli_assoc)) //3)... //while(mysqli_fetch($stmt)) { echo "url"; echo "<br>"; echo "anchor_text"; echo "<br>"; echo "description"; echo "<br>"; echo "keyphrases"; echo "<br>"; echo "keywords"; echo "<br>"; echo "|"; echo "<br>"; } mysqli_stmt_close($stmt);//CORRECTION: THIS SHOULD BE OUTSIDE THE "WHILE LOOP" mysqli_close($conn);//CORRECTION: THIS SHOULD BE OUTSIDE "IF" } else { echo "1. QUERY failed!"; } if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'sssss',$_POST['page_url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keyphrases'],$_POST['keywords']); mysqli_stmt_execute($stmt); //CORRECTION: FORGOT TO ADD "$result = " $result = mysqli_stmt_get_result($stmt); /* MY CODE WRONG! TRIED ECGHOING THE ARRAY "$row[]"! while($row = mysqli_fetch_array($result,mysqli_assoc)) { echo $row['page_url']; echo "<br>"; echo $row['link_anchor_text']; echo "<br>"; echo $row['page_description']; echo "<br>"; echo $row['keyphrases']; echo "<br>"; echo $row['keywords']; echo "<br>"; echo "|"; echo "<br>"; } */ //CORRECTION: HOW IT SHOULD BE: //$VARIABLE SHOULD BE ECHOED. NOT THE ARRAY $row[] while($row = mysqli_fetch_array($result,mysqli_assoc)) { $page_url = $row['page_url']; echo $page_url; echo "<br>"; $link_anchor_text = $row['link_anchor_text']; echo $link_anchor_text; echo "<br>"; $page_description = $row['page_description']; echo $page_description; echo "<br>"; $keyphrases = $row['keyphrases']; echo $keyphrases; echo "<br>"; $keywords = $row['keywords']; echo $keywords; echo "<br>"; echo "|"; echo "<br>"; } mysqli_stmt_close($stmt); mysqli_close($conn); } else { die("2. QUERY failed!"); } } } ?>
TEST NUMBER 2: On this one, clicking the "submit links" button gives no response atall!.
<?php include('error_reporting.php'); require('conn.php'); //equire('link_submission_form.php'); ?> <form name = "submit_link" method = "POST" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <label for="domain">Domain:</label> <input type="text" name="domain" id="domain" placeholder="Input Domain"> <br> <label for="domain_email">Domain Email:</label> <input type="email" name="domain_email" id="domain_email" placeholder="Input Domain Email"> <br> <label for="url">Url:</label> <input type="url" name="url" id="url" placeholder="Input Url"> <br> <label for="link_anchor_text">Link Anchor Text:</label> <input type="text" name="link_anchor_text" id="link_anchor_text" placeholder="Input Link Anchor Text"> <br> <textarea rows="10" cols="20">Page Description</textarea> <br> <label for="keywords">Keywords:</label> <input type="text" name="keywords" id="keywords" placeholder="Input Keywords related to Page"> <br> <label for="tos_agreement">Agree to TOS or not ?</label> <select name="tos_agreement" id="tos_agreement"> <option value="yes">Yes</option> <option value="no">No</option> </select> <br> <input type="button" name="submit_link" id="submit_link" value="Submit Link!"> <br> <input type="reset"> <br> </form> <?php if($_SERVER['REQUEST_METHOD'] === 'POST') { if(ISSET($_POST['submit_link'])) { $query = "INSERT into links (domain,domain_email,url,link_anchor_text,page_description,keywords) VALUES ?,?,?,?,?,?"; $stmt = mysqli_stmt_init($conn); if(mysqli_stmt_prepare($stmt,$query)) { mysqli_stmt_bind_param($stmt,'ssssss',$_POST['domain'],$_POST['domain_email'],$_POST['url'],$_POST['link_anchor_text'],$_POST['page_description'],$_POST['keywords']); mysqli_stmt_close($stmt); mysqli_close($conn); } else { die("INSERT failed!"); } } } ?>
What is wrong ? Why both codes don't work ? Edited July 14, 2020 by 2020 Hi, I have tried a lot of different scripts for detect and redirect for device for mobile and they seem to work ok on mac but ie does not load the page are there any scripts that work? I have a main site that sits at the usual www.domain.co.uk address and then i have a mobile site at www.domain.co.uk/phone i want to be able to have nay mobile users when accessing www.domain.co.uk be automaticly redirected to www.domain.co.uk/phone with that working in ie? any help please? thanks, Alight, I'm trying to figure out the error string for an api http://www.haloreachapi.net/wiki/API_rate_limits The wiki says the limit is 300rpm I tried to run this in two tabs on my browser still won't give me the error string, how can it be done faster? P.s. Api key will be changed in the near future don't waste your time.. <?php $gamertag = "l RaH l"; $url = "http://www.bungie.net/api/reach/reachapijson.svc/game/metadata/30cRxVA9J73esG388CzmOXUVRo5VjYhSfI2qBaqcMzs="; $t_start = microtime(true); for($i = 0; $i < 301; $i++) { $file = file_get_contents($url); echo "Iteration ".($i + 1)."<br>\n"; } $exectime = microtime(true) - $t_start; echo "Execution time: " . round($exectime, 4) . "<br><br>\n\n"; $json = json_decode($file, 1); print_r($json); ?> I am getting Warning: Division by zero in /rate.php on line 64 <?php function rateinstar($value) { preg_match_all('#([0-9]+)([0.0-9.9]+)|([0-9]+)#',$value,$tek); if($tek[0][1] > 0) { $rate=$tek[0][0]/$tek[0][1]; } else { $rate=0; } preg_match_all('#([0-9]+).([0-9]+)#',round($rate,1),$decm); if($decm[2][0] != "") { $no=($decm[1][0]*2)+1; for($i=1;$i<=10;$i++) { if($i<=$no){ if($i%2!=0) echo '<span class="starin piece1"></span>'; else echo '<span class="starin piece2"></span>'; }else{ if($i%2!=0) echo '<span class="starin piece3"></span>'; else echo '<span class="starin piece4"></span>'; } } }else{ for($i=1;$i<=10;$i++) { if($i<=$rate*2){ if($i%2!=0) echo '<span class="starin piece1"></span>'; else echo '<span class="starin piece2"></span>'; }else{ if($i%2!=0) echo '<span class="starin piece3"></span>'; else echo '<span class="starin piece4"></span>'; } } } } function rateintext($value) { preg_match_all('#([0-9]+)([0.0-9.9]+)|([0-9]+)#',$value,$tek); $rate=$tek[0][0]/$tek[0][1]; preg_match_all('#([0-9]+).([0-9]+)#',round($rate,1),$decm); return round($rate,1); } ?> This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=347646.0 I'm Trying to INSERT Data into mysql which is generated from biomatric attendance device. what i wanted to do is to save these data into mysql database. <?php include 'db.php'; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> <!-- <script type="text/javascript" src="load.js"></script> --> <link rel="stylesheet" href="style.css"> <title>Live Attendance</title> </head> <?php include("zklib/zklib.php"); $zk = new ZKLib("192.168.1.3", 4370); $ret = $zk->connect(); sleep(1); if ( $ret ): $zk->disableDevice(); sleep(1); ?> <body> <table border="1" cellpadding="5" cellspacing="2" style="float: left; margin-right: 10px;"> <tr> <th colspan="5">Data User</th> </tr> <tr> <th>UID</th> <th>ID</th> <th>Name</th> <th>Role</th> <th>Password</th> </tr> <?php try { //$zk->setUser(1, '1', 'Admin', '', LEVEL_ADMIN); $user = $zk->getUser(); sleep(1); while(list($uid, $userdata) = each($user)): if ($userdata[2] == LEVEL_ADMIN) $role = 'ADMIN'; elseif ($userdata[2] == LEVEL_USER) $role = 'USER'; else $role = 'Unknown'; ?> <tr> <td><?php echo $uid ?></td> <td><?php echo $userdata[0] ?></td> <td><?php echo $userdata[1] ?></td> <td><?php echo $role ?></td> <td><?php echo $userdata[3] ?> </td> </tr> <?php endwhile; } catch (Exception $e) { header("HTTP/1.0 404 Not Found"); header('HTTP', true, 500); // 500 internal server error } //$zk->clearAdmin(); if (isset($_POST['create_post'])) { $query = "INSERT INTO attendance(idx)"; $query .= "VALUES ($id)"; $submittodbquery = mysqli_query($con,$query); if (!$submittodbquery) { die("Failed up upload " . mysqli_error($con)); }else { echo "updated"; } } ?> </table> <button id="submit" type="submit" name="create_post" class="btn btn-danger">Submit New Post</button> <?php $name = $userdata[1]; $attendance = $zk->getAttendance(); sleep(1); while(list($idx, $attendancedata ) = each($attendance)): if ( $attendancedata[2] == 1 ) $status = 'Check Out'; else $status = 'Check In'; ?> <?php $idx ?> <?php $attendancedata[0] ?> <?php $attendancedata[1] ?> <?php $status ?> <?php date( "d-m-Y", strtotime( $attendancedata[3] ) ) ?> <?php date( "H:i:s", strtotime( $attendancedata[3] ) ) ?> <?php // custom code if (isset($_POST['submit'])) { $query = "INSERT INTO attendance(idx)"; $query .= "VALUES ($idx)"; $submittodbquery = mysqli_query($con,$query); if (!$submittodbquery) { die("Failed up upload " . mysqli_error($con)); }else { echo "updated"; } } ?> <?php endwhile ?> </table> <input type="submit" name="submit" value="Update Database"> <?php $zk->enableDevice(); sleep(1); $zk->disconnect(); endif ?> </body> </html> Thanks for reading my question ..
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=318425.0 Hi Everyone: Can anyone show me or direct me to a PHP PHP Mobile Device Detection & Redirection Script. I use to use this when doing ASP: Code: [Select] <% Dim user_agent, mobile_browser, Regex, match, mobile_agents, mobile_ua, i, size user_agent = Request.ServerVariables("HTTP_USER_AGENT") mobile_browser = 0 Set Regex = New RegExp With Regex .Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm)" .IgnoreCase = True .Global = True End With match = Regex.Test(user_agent) If match Then mobile_browser = mobile_browser+1 If InStr(Request.ServerVariables("HTTP_ACCEPT"), "application/vnd.wap.xhtml+xml") Or Not IsEmpty(Request.ServerVariables("HTTP_X_PROFILE")) Or Not IsEmpty(Request.ServerVariables("HTTP_PROFILE")) Then mobile_browser = mobile_browser+1 end If mobile_agents = Array("w3c ", "acs-", "alav", "alca", "amoi", "audi", "avan", "benq", "bird", "blac", "blaz", "brew", "cell", "cldc", "cmd-", "dang", "doco", "eric", "hipt", "inno", "ipaq", "java", "jigs", "kddi", "keji", "leno", "lg-c", "lg-d", "lg-g", "lge-", "maui", "maxo", "midp", "mits", "mmef", "mobi", "mot-", "moto", "mwbp", "nec-", "newt", "noki", "oper", "palm", "pana", "pant", "phil", "play", "port", "prox", "qwap", "sage", "sams", "sany", "sch-", "sec-", "send", "seri", "sgh-", "shar", "sie-", "siem", "smal", "smar", "sony", "sph-", "symb", "t-mo", "teli", "tim-", "tosh", "tsm-", "upg1", "upsi", "vk-v", "voda", "wap-", "wapa", "wapi", "wapp", "wapr", "webc", "winw", "winw", "xda", "xda-") size = Ubound(mobile_agents) mobile_ua = LCase(Left(user_agent, 4)) For i=0 To size If mobile_agents(i) = mobile_ua Then mobile_browser = mobile_browser+1 Exit For End If Next If mobile_browser>0 Then Response.Redirect("http://www.sp.com/SPMOBI/MOBI.asp") End If %> Is there a PHP equivalent of this? As always, I appreciate to wisdom of the board. Thanks! |