PHP - Data Not Matching But Code Does Not Acknowledge This
Hi everyone, My code is meant to give a certain response if the hospital number & PIN together do or do not match. However, whatever I input, whether it is correct information or random numbers, I still get the output that the data has been submitted successfully. Any thoughts?
<?php $connect = mysqli_connect($hostname, $username, $password, $databaseName); $query = "UPDATE card SET comments = '$comments' , seniorsent = '$seniorsent' WHERE hospitalnumber = '$hospitalnumber' and PIN = '$PIN'"; @mysqli_query($connect, $query); $result = mysqli_query($connect, $query); if($result) { echo 'Data submitted successfully'; }else{ echo 'Please check that all details are correct'; } >
Thanks in advance, samanj Similar Tutorials
Good morning. Thanks in advance to everyone. <!doctype html> <html dir=ltr style="overflow-x: hidden;padding: 0px;width: 100%;"> <head> <meta charset=utf-8> <meta http-equiv=X-UA-Compatible content="IE=edge"> <meta name=viewport content="width=device-width, initial-scale=1"> <title></title> <meta name="description" content=""> <meta name="author" content="SoftMat"> <link media="all" href="css/style.css" rel="stylesheet" /> <!-- qrcode-reader core CSS file --> <link rel="stylesheet" href="css/qrcode-reader.min.css"> <!-- jQuery --> <script src="js/jquery.min.js"></script> <!-- qrcode-reader core JS file --> <script src="js/qrcode-reader.min.js"></script> <script> $(function(){ // overriding path of JS script and audio $.qrCodeReader.jsQRpath = "js/jsQR.min.js"; $.qrCodeReader.beepPath = "audio/sound.mp3"; // bind all elements of a given class $(".qrcode-reader").qrCodeReader(); // bind elements by ID with specific options $("#openreader-multi2").qrCodeReader({multiple: true, target: "#multiple2", skipDuplicates: false}); $("#openreader-multi3").qrCodeReader({multiple: true, target: "#multiple3"}); // read or follow qrcode depending on the content of the target input $("#openreader-single2").qrCodeReader({callback: function(code) { if (code) { window.location.href = code; } }}).off("click.qrCodeReader").on("click", function(){ var qrcode = $("#single2").val().trim(); if (qrcode) { window.location.href = qrcode; } else { $.qrCodeReader.instance.open.call(this); } }); }); </script> </head> <body> <div align="center" class="container"> <div align="center" class="col-xs-12"> <div align="center" class="container" style="background-color:white; box-shadow:0px 2px #00000085;"> <img style="margin-top:15px; margin-bottom:15px;" src="img/logo.png"> </div> <div align="center" class="col-xs-12" style="background-image: url(img/blakcstonemain.png); background-repeat:no-repeat; background-position:center; background-size: cover; margin-top:10px;"> <br> <!--Lavorazione : Scelta OP--> <h1 style="margin-bottom: 0px;">Seleziona Ordine di Produzione</h1> <?php $conn = odbc_connect('', '', ''); if(! $conn){ print( "..." ); exit; } //definisco gli ordini di produzione $sql="SELECT * FROM dbo.OP_Ordini LEFT JOIN dbo.MG_AnaART ON dbo.OP_Ordini.OPOR_MGAA_Id = dbo.MG_AnaArt.MGAA_Id "; $rs=odbc_exec($conn,$sql); if (!$rs) {exit("Errore nella tabella!");} echo"<center>"; echo"<br>"; echo"<select>"; echo"<option>--ORDINI--</option>"; while(odbc_fetch_row($rs)) { $ord_id=odbc_result($rs,"OPOR_Id"); $ord_anno=odbc_result($rs,"OPOR_Anno"); $ord_ordine=odbc_result($rs,"OPOR_Ordine"); $ord_lotto=odbc_result($rs,"OPOR_Lotto"); $ord_desc=odbc_result($rs,"OPOR_Descr"); $mgaa_matr=odbc_result($rs,"MGAA_Matricola"); echo"<option>| $ord_id | $ord_anno | $ord_ordine | $ord_lotto | $ord_desc | $mgaa_matr</option>"; } echo"</select>"; echo"<br>"; echo"<br>"; ?> <!--Lavorazione : Scansione--> <div align="center" class="col-xs-12"> <h1 style="margin-bottom: 0px;">Scansione Materiale</h1> <br> <label for="single"></label> <input id="single" type="text" size="50"> <button type="button" class="qrcode-reader" id="openreader-single" data-qrr-target="#single" data-qrr-audio-feedback="false" data-qrr-qrcode-regexp="^https?:\/\/"><img style="width:20%;" src="img/qr1.png"></button> <!--Lavorazione : Matching--> <h1 style="margin-bottom: 0px;">Esamina</h1> <img style="width:20%;" src="img/compara.png"> <input id="submit" type="submit" value="MANDALA!"> <!--<video id="preview" class="p-1 border" style="width:75%;border: solid #d34836;box-shadow: 5px 5px #000000a6;"></video>--> </div> </div> </div> </div> </body> </html> Edited September 1, 2020 by requinix please use the Code <> button when posting code Hi All I'm after some advice about how to write a parser to match many different naming formats of a tv episode, so the one thing we can rely on is that a episodes are inside a folder named after the show, for example "House MD\episode name. s1e07.mkv" so we know the show name, that part is easy, the bit I need to match is the season and episode number. The format of the file name can differ is so many ways, here are some examples: - S01E01 - s1e10 - S3e6 - 105 (for season 1, episode 5) - EP01 (usually there's one season in this case, but not 100% of the time) So as you can see there are a few variations, almost always the show name is in there too, and sometimes they contain resolution, so: House.MD S1E09 720p HD.mkv, there are many combinations but since we already know the show name it's not something I think we need to worry *too* much about. My question relations to how you would approach this? You can see from the examples above sometimes this would be hard to match and work out. My initial idea would be to have a class called 'tvmatcher', or something, which has match handlers, one match handler for each format we need match, a handler would be a class that extends tvmatcher and have the same method, like $handler->match($string); the first one to match would be the winner. This could be extended to sanity check the result and ensure that the season/ep actually exists. I really don't know how to go about this, the idea above is my best so far, so again my questions really a How would you approach this? Is there a pattern that would help? any other ideas about how this could be acheived? It's worth noting that I'd be using external APIs to get show information, but would be out of the scope of this library, but could help with said sanity checks. Cheers, Billy This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351561.0 Hi, I am in the procress of creating discussion system however I am a bit puzzled about the best way to go about it. I am starting the discussion by creating an ID number and then match the answer to the initial ID number. However, I dont know whether if is best to put the responses into a different database. I'm a bit puzzled how ID matching systems works. Lets say: Question 1 = ID1 Question 2 = ID2 Question 3 = ID3 Question 1 Answer 1 = ID4 (How is this matched to ID1) Question 2 Answer 1 = ID5 (How is this matched to ID2) is this based on preg_match? Wondering if someone could help me. What I am trying to do is display the information from each row. I am trying to read from 2 tables and display them on a page. I want them to show like this name,make,type, price,"images/listings/a1.jpg,images/listings/a2.jpg,images/listings/a3.jpg,images/listings/a4.jpg,images/listings/a5.jpg,images/listings/a5.jpg" name,make,type, price,"images/listings/b1.jpg,images/listings/b2.jpg,images/listings/b3.jpg,images/listings/b4.jpg,images/listings/b5.jpg,images/listings/b5.jpg" Example. the table structures are as so: Code: [Select] listings -------------------------------- id name make type price (then a couple more columns I dont need data from) -------------------------------- 1 name1 make1 type1 price1 2 name2 make2 type2 price2 3 name3 make3 type3 price3 listimages ---------------------------------------------------- id imagepath mainimage listingid ---------------------------------------------------- 1 images/listings/a1.jpg 1 1 2 images/listings/a2.jpg 0 1 3 images/listings/a3.jpg 0 1 4 images/listings/a4.jpg 0 1 5 images/listings/a5.jpg 0 1 6 images/listings/a6.jpg 0 1 7 images/listings/b1.jpg 1 2 8 images/listings/b2.jpg 0 2 9 images/listings/b3.jpg 0 2 10 images/listings/b4.jpg 0 2 11 images/listings/b5.jpg 0 2 12 images/listings/b6.jpg 0 2 13 images/listings/c1.jpg 1 3 etc Here is the code I am using. Everything works except some of the listing images don't match up to the names. I think when certain names don't have pictures it just moves up the images to the next person. I need to somehow associate the listingid column from listimages table with the id column from the listings table. The mainimage column tells what image of the group of images is default for that name. 1 being the default 0 not the default Here is the code I am using. Code: [Select] <?php // Make a MySQL Connection mysql_connect("localhost", "xxxxxx", "xxxxxx") or die(mysql_error()); mysql_select_db("xxxxxx") or die(mysql_error()); $result = mysql_query("SELECT * FROM listings l JOIN listimages li ON l.id = li.listingid ORDER BY l.id DESC") or die(mysql_error()); $last_listingid = null; $curRow = array(); while($row = mysql_fetch_array($result)) { // Check for a difference in listing ID - and if it is, then we should show the previous row first if ($last_listingid != $row['listingid'] && $last_listingid !== null) { // Implode the array with quotes around it echo $row['name']; echo ","; echo $row['make']; echo ","; echo $row['model']; echo ","; echo $row['type']; echo ","; echo $row['price']; echo ","; echo '"' . implode(',', $curRow) . '"<br />'; // And start fresh $curRow = array(); } // Now we can save it to the array $curRow[] = $row['imagepath']; // And set the new ID $last_listingid = $row['listingid']; } // Finally, we'll need to implode it one last time since there should always be at least one value in the array echo '"' . implode(',', $curRow) . '"'; ?> Please let me know what I am doing wrong Anyone Thanks
Example Code: if FirstImage=1 is absent, continue with FirstImage=0 Thanks for your idea and effort. Dear All, I am developing a website www.computationalphotography.in on which I need to register new users. I have designed an HTML form for this purpose, but will need help with writing the code for checking and validating the data in the respective fields. The code for my web form is below and the address of the website is www.computationalphotography.in/registration.php: Code: [Select] <html> <head> <title> Photography Experiment Registration </title> </head> <body> <h1> Questionnaire </h1> <h3> We would like to know about your background and interests in photography. For each multiple-choice question, please circle all answers that apply.</h3> <form method="post" action="registration.php"> Name <input name="name" type="text"> <br> <br> <input name="email" type="text"> <br> <br> 1.) Roughly How many pictures do you take each year? <br> <br> <input name="radios" type="radio" value="a"> a) a few: <10 in a year <br> <input name="radios" type="radio" value="b"> b) many: probably 100's a photos a year <br> <input name="radios" type="radio" value="c"> c) a lot: probably 1000's of photos a year <br> <br> 2.) Do you share your pictures with anyone? <br> <input name="radios" type="radio" value="a"> a) No <br> <input name="radios" type="radio" value="b"> b) Yes, but only with friends or family <br> <input name="radios" type="radio" value="c"> c) Yes, I share with friends or family and also post on public sites such as Flickr, Picasaweb, or Snapfish for anyone to see. <br> <input name="radios" type="radio" value="d"> d) Yes, I share frequently and I have also published my photos in books or magazines, or exhibitde my photos in shows. <br> <br> 3.) How much training in photography have you had? <br> <input name="radios" type="radio" value="a"> a) None <br> <input name="radios" type="radio" value="b"> b) Some, but it's self-taught from books or websites <br> <input name="radios" type="radio" value="c"> c) Quite a bit: I have taken courses in photography <br> <input name="radios" type="radio" value="d"> d) A lot:I have completed a degreee or certificate in the subject <br> <br> 4.) How do you describe yourself as a photographer? <br> <input name="radios" type="radio" value="a"> a) A novice:someone who takes a few pictures occasionally <br> <input name="radios" type="radio" value="b"> b) An amateur:someone who takes many photos, but doesn't usually share them <br> <input name="radios" type="radio" value="c"> c) An enthusiast:someone who loves to take pictures, possibly shows them with oters on public sites, or who might own a DSLR, or frequently uses a camera in other than "automatic mode" <br> <input name="radios" type="radio" value="d"> d) An expert:skilled photographer who has published their work, or exhibited their work in shows, or has been paid for their work <br> <br> 5.) Do you have artistic training or exposure? <br> <input name="radios" type="radio" value="a"> a) No <br> <input name="radios" type="radio" value="b"> b) I visit museums or art galleries <br> c) I have studied art: please describe <br> <textarea name="data5c" cols="50" rows="5"> </textarea> <br> d) I am a practicing artist: please describe <br> <textarea name="data5d" cols="50" rows="5"> </textarea> <br> <br> 6.) Some optional information, if you don't mind. We respect your privacy. <br> <br> Age <br> <textarea name="6a" cols="1" rows="1"> </textarea> <br> <br> Gender <br> <input name="radios" type="radio" value="a"> a) Male <br> <input name="radios" type="radio" value="b"> b) Female <br> <br> Languages Spoken <br> <textarea name="6b" cols="25" rows="2"> </textarea> <br> <br> Languages Read <br> <textarea name="6c" cols="25" rows="2"> </textarea> <br> <br> <br> <input type="submit" value="Send"> <input type="reset" value"Reset"> </form> </body> </html> Kindly help me out with this issue. Thank you for your help in this regard. Hi, I have a working PHP script that picks data from an XML file. I would like the script to pick values from certain range. Right now the PHP shows every Item with name and value in a table. So when all 4 of the item values are shown they are beneath each other in a column. But i would like them all to be next to each other. Therefore if i have these 4 item values (Name 0000), if i could pick them from the XML e.g. not the first but the second than i could make them manually with 4 different PHP scripts and put them next to each other. I'm not very good at PHP, but i think this is probably very easy thing to do. Thanks in advance. The PHP script looks like this: Code: [Select] <? // DOMElement->getElementsByTagName() -- Gets elements by tagname // nodeValue : The value of this node, depending on its type. // Load XML File. You can use loadXML if you wish to load XML data from a string $objDOM = new DOMDocument(); $objDOM->load("feed.xml"); //make sure path is correct $note = $objDOM->getElementsByTagName("item"); // for each note tag, parse the document and get values for // tasks and details tag. foreach( $note as $value ){ $places = $value->getElementsByTagName("name"); $place = $places->item(0)->nodeValue; $details = $value->getElementsByTagName("amount"); $detail = $details->item(0)->nodeValue; echo "<BODY STYLE='background-color:transparent'> <table border='0'> <tr> <td width='127'><table width='127px' border='0' cellpadding='0' cellspacing='0'> <tr> <td><p style='font-family:arial;color:white;font-size:22px;padding-left:3px;text-align:left; background:url(bg2.png)'><strong> $place</strong></p></td> </tr> </table> </td> <td width='115'> <table width='115px' border='0' cellpadding='0' cellspacing='0'> <tr> <td><p style='font-family:arial;color:white;font-size:22px;text-align:right;padding-right:5px; background:url(bg1.png)'><strong>$detail</strong></p></td> </tr> </table></td> </tr> </table> "; $i++; } ?> And the XML looks like this: Code: [Select] <xml> <item> <name>Examplename</name> <amount>0000</amount> </item> <item> <name>Examplename</name> <amount>0000</amount> </item> <item> <name>Examplename</name> <amount>0000</amount> </item> <item> <name>DExamplename</name> <amount>0000</amount> </item> </xml> I am trying to identify the username from a series of windows logs. I have been using (?:User Name:|Account Name:)\s*([\S]+) and it works for examples 1-4, however I'm having problems with example 5. Because it has two occurrences of the pattern Account Name: in the string I can only get the regex to return the first match, i.e. USER-PC$. How can I tell regex, that if there are two Account Name: patterns in the string, or the string contains the pattern "New Logon:" then return the second Account Name: match, i.e. John.Doe? eg 1 - The screen saver was invoked. Subject: Security ID: S-X-X Account Name: John.Doe Account Domain: INTERNAL Logon ID: 0xa4091 Session ID: 1 eg 2 - User initiated logoff: Subject: Security ID: S-X-X Account Name: John.Doe Account Domain: INTERNAL Logon ID: 0x3d95c This event is generated when a logoff is initiated. No further user-initiated activity can occur. This event can be interpreted as a logoff event. eg 3 - User Logoff: User Name: John.Doe Domain: INTERNAL Logon ID: (0x0,0x458E4AB4) Logon Type: 8 eg 4 - Successful Network Logon: User Name: John.Doe Domain: INTERNAL Logon ID: (0x0,0x43) Logon Type: 8 Logon Process: Advapi Authentication Package: Negotiate Workstation Name: USER-PC Logon GUID: {2e483a4f-} Caller User Name: USER-PC $ Caller Domain: INTERNAL Caller Logon ID: (0x0,0x7) Caller Process ID: 4816 Transited Services: - Source Network Address: xx.xxx.xx.x Source Port: 35029 eg 5 - An account was successfully logged on. Subject: Security ID: S-X-X Account Name: USER-PC$ Account Domain: INTERNAL Logon ID: 0x3e7 Logon Type: 2 New Logon: Security ID: S-X-X Account Name: John.Doe Account Domain: INTERNAL Logon ID: 0xa4062 Logon GUID: {23-xx-22} Process Information: Process ID: 0x2fc Process Name: C:\Windows\System32\winlogon.exe Network Information: Workstation Name: USER-PC Source Network Address: xx.x.x.x Source Port: 0 Any help would be appreciated:) What I'm trying to do is have it match up the image file name wiht the same name as the link. Sometimes it does but sometimes obviously the image is random. Any ideas? Code: [Select] function spotlight($dbc){ $query = " SELECT * FROM characters WHERE characters.statusID = 1 AND characters.styleID = 1 ORDER BY RAND() LIMIT 1"; $result = mysqli_query($dbc, $query); $row = mysqli_fetch_array($result); $shortName = $row[ 'shortName' ]; $labels = array('shortName'); $img = array(); if($handle = opendir('images/spotlight/')) { $count = 0; while (false !== ($file = readdir($handle))) { if(strlen($file) > 2){ $img[$count] = $file; $count++; } } } echo "<a href='bio.php?shortName=" . $shortName . "'><img src='/images/spotlight/".$img[rand(0, (count($img)-1))]."' alt=Spotlight border=0 /></a>"; } Hello group. I need some help with my code.
<?php
$a1 = array("line1"=>"1-2-3-10-14","line2"=>"1-2-3-10-34","line3"=>"1-2-7-16-35","line4"=>"1-2-3-17-19","line5"=>"2-5-11-15-32");
$result = array_intersect($a1,$a2); ?> Right now, I can only search and find an exact match of all 5-Numbers. I want to code a PHP form that will take a (5-number string) as input and then compare that string against an array database of (5-number strings) to find all matching number occurrences for each “LINE 1 thru LINE 5”. For instance, if I were to type the 5-number string “1-2-3-10-34” as input. The Output populated results would look like this .. Edited February 21, 2019 by Jayfromsandiego I'm working a membership application page for my amateur radio club. I'm currently stumped passing a variable from HTML to PHP. The variable is called "nametag" and it's a "radio" type. No Matter if I select 10 or 0. I still get 15 being passed to PHP.
Any help is appreciated.
Thanks -HP Garcia Hello
So I want to try and match everything preceding a file extension in a string using preg_match.
An example file name: "Images_home_blah.blah.jpg" .
I've tried the following regex:
/^([a-z0-9_\-\.]+)(?!\.jpg)/iBut this sadly appears to capture the whole string instead of ignoring the '.jpg' part. Can anyone point me in the right direction? Thanks, Drongo Hi there im just trying to understand how to compare and output results in a table. For example lets say i have the following table: Beans ID Type Location And say 3 records: 1 Baked kitchen 2 Runners Garage 3 Broad Kitchen I want to select only the beans that have matching locations and output the Type: Baked, Broad. I'm trying to get my head around how to work this out, if you could nudge me in the right direction that would be excellent. Thank you. Basically i want to take an array of numbers let's say: Code: [Select] <? $array1=array("1","2","3","4"); ?> Now say i reprint that same array, but the 3 is missing. Code: [Select] <? $array2=array("1","2","4"); ?> How would i print what's missing from $array1 out of $array2? Sorry if this is confusing, i'll be happy to go into details if needed. Hi I'm trying to match @USERNAME in a string and replace it with @<a href="message.php?member=USERNAME">USERNAME</a> I've tried a few different methods: Code: [Select] preg_replace ('/@(.*?)/', '<a href="message.php?member=$1">$1</a>', $str)and also * and \@ but i just can't seem to get it to work. any help would be appreciated! In the below example, we match 0 or more alphanumeric characters in the beginning and 0 or more alphanumeric characters in the end. Then we create 4 groups. Each group has "?=" which means "the next text must be like this". Now in first group we match any character 8 or more times. The next group we match 0 or more characters and a digit. In the next group we match 0 or more characters and a lowercase letter. In the next group we match 0 or more characters and an uppercase letter.
<?php $password = "Fyfjk34sdfjfsjq7"; if (preg_match("/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $password)) { echo "Your passwords is strong."; } else { echo "Your password is weak."; } ?>My question is do these four groups impact each other? That is, the fact that the first group has 8 or more characters means that all the groups must have 8 or more characters. The fact that the second group has a digit means that all the groups must have a digit. Or do they work exclusively meaning that a 4 character word with a single digit would match this pattern, even though first group says it must have 8 characters. I have a list of companies I have to look up information for on the entity search page for the state. here is what i have so far except there seems to be a verification error. Anyone know how to fix this so the page will display results? <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://appext9.dos.state.ny.us/corp_public/CORPSEARCH.SELECT_ENTITY'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); //set curl options curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2. Gecko/20100722 Firefox/3.6.8 ( .NET CLR 3.5.30729)"); curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, 'CURLCOOKIE'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); //visit page to get cookies //$strGet_page_contents = curl_exec ($ch); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'p_entity_name=Apple LLC&p_name_type=Arwen&p_search_type=BEGINS&submit=Search!'); // EXECUTE $store = curl_exec ($ch); echo curl_exec ($ch); // CLOSE CURL curl_close ($ch); ?> Hey, I need a bit of help replacing some variables in a string. I know its done with preg_replace. Here is the string: Code: [Select] Header 1 <|header 2|> header 3 <b>header 4</b> I would like to get ONLY <|header 2|> from the above string. But "header 2" is variable so please its useless if the preg_replace isn't flexible to find whatever word is in there regardless. Thanks you. |