PHP - Remove Recently Type From Input
How can I make it so that the things that the user recently typed in an input is not displayed as a drop down. I want nothing to be displayed.
Similar TutorialsCan anyone let me know what I am doing wrong. I am sure it will (after the fact) be obvious, but I don't see it right now. Wish to remove all array elements which do not implement ValidatorCallbackInterface. Thanks <?php interface ValidatorCallbackInterface{} class ValidatorCallback implements ValidatorCallbackInterface{} function array_filter_recursive($input) { foreach ($input as &$value) { if (is_array($value)) { $value = array_filter_recursive($value); } } return array_filter($input, function($v) { return $v instanceOf ValidatorCallbackInterface; }); } function recursive_unset(&$array) { foreach ($array as $key => $value) { if (is_array($value)) { recursive_unset($value); if(empty($value)) { unset($array[$key]); } } elseif(!$value instanceOf ValidatorCallbackInterface) { unset($array[$key]); } } } $validatorCallback = new ValidatorCallback(); $rules=[ 'callbackId'=>"integer", 'info'=>[ 'arrayofobjects'=>[$validatorCallback], 'foo1'=>'bar1' ], 'foo2'=>'bar2', 'bla'=>[ 'a'=>'aa', 'b'=>'bb', ], 'singleobject'=>$validatorCallback ]; echo('original rules'.PHP_EOL); var_dump($rules); $desiredrules=[ 'info'=>[ 'arrayofobjects'=>[$validatorCallback] ], 'singleobject'=>$validatorCallback ]; echo('desired rules'.PHP_EOL); var_dump($desiredrules); echo('array_filter_recursive'.PHP_EOL); var_dump(array_filter_recursive($rules)); echo('recursive_unset'.PHP_EOL); recursive_unset($rules); var_dump($rules);
original rules array(5) { ["callbackId"]=> string(7) "integer" ["info"]=> array(2) { ["arrayofobjects"]=> array(1) { [0]=> object(ValidatorCallback)#1 (0) { } } ["foo1"]=> string(4) "bar1" } ["foo2"]=> string(4) "bar2" ["bla"]=> array(2) { ["a"]=> string(2) "aa" ["b"]=> string(2) "bb" } ["singleobject"]=> object(ValidatorCallback)#1 (0) { } } desired rules array(2) { ["info"]=> array(1) { ["arrayofobjects"]=> array(1) { [0]=> object(ValidatorCallback)#1 (0) { } } } ["singleobject"]=> object(ValidatorCallback)#1 (0) { } } array_filter_recursive array(1) { ["singleobject"]=> object(ValidatorCallback)#1 (0) { } } recursive_unset array(2) { ["info"]=> array(2) { ["arrayofobjects"]=> array(1) { [0]=> object(ValidatorCallback)#1 (0) { } } ["foo1"]=> string(4) "bar1" } ["singleobject"]=> object(ValidatorCallback)#1 (0) { } }
Hi Guys, Appreciate any help here please... Basically I want to hide some inputs on my registration page and populate them will default values. Everything works okay, apart from the input below: Code: [Select] <input type="hidden" name="seek_location" value="Anywhere"> When I use the above, the MYSQL database field for seek_location is left empty... I've noticed that the code below pulls the location into a dropdown list. You know the kind of thing, Australia, UK, USA etc etc: Code: [Select] $seek_location = $wcr[$seek_location]; Code: [Select] <? $p=0;asort($wcr);reset($wcr); while (list ($p, $val) = each ($wcr)) { echo '<option value="'.$p.'">'.$val; } ?> So, all I want to do is have: Code: [Select] <input type="hidden" name="seek_location" value="Anywhere"> Populate seek_location with Anywhere Any help appreciated Thanks Rob This is a cross between HTML, PHP, and MySQL. I'm not exactly sure which to blame (other than myself of course) I'm collecting a bid price in a standard form <input type="number" name="maxbid" value="<?php echo $maxbid ?>"/> I have recalled the value from the database where I store it and display it in the field if it exists. If the field has never been entered, the field shows nothing. It's not required that a bid be entered. There are other fields of data that may be updated and this field is left blank. On the page called by the submit button I'm retrieving the fields $maxbid=$_POST[maxbid]; Then I store the fields in the database either with an INSERT or an UPDATE if(mysql_num_rows(mysql_query("SELECT id FROM data WHERE id = '$id'"))) { echo "Updating....."; mysql_query("UPDATE data SET maxbid='$maxbid', name='$name' where id='$id'"); } else { echo "Inserting....."; mysql_query("INSERT INTO data (id, maxbid,name) VALUES ('$id','$maxbid',$'name')"); } I know I'm not handling the Numeric values correctly, and I'm having a hard time finding the correct method for doing so. Right now, if the name is entered byt the maxbid is left blank, nothing gets inserted or updated. if I enter both the maxbid and the name it works. I can't have maxbid show up as a 0, I need it to be blank if nothing is entered. Also when I check $maxbid, it's not an INTEGER (per INTVAL) when I check it, even though maxbid in the table is an INTEGER. When I pass it around, it seems to lose it's INTEGER value, but still shows as a number. I know this sounds confusing, heck I'm confused. If someone could point me to a good tutorial, I'd figure it all out, but most tutorials don't get into the data type that much, and the combination of the form, passing the variables, reading the values from the database, etc. is what's causing me grief. Any guidance would be appreciated. i have the following code: <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ? <select id="yesnolist" onChange="getChoice(this.value)"> <option value="yes" selected="selected">Yes</option> <option value="no">No</option> </select> </li> <input type="hidden" name="text" size=30 id="yesandno"> <?php if ($_GET['yesandno'] == "no") { echo "anything!!!!!!!!!!!!!!!!!!!"; } ?> then my java script for getCoice(): function getChoice(val) { yesNo = new Array("Yes", "No"); var getsel = document.contactus.yesnolist.value; var e = document.getElementById("yesnolist"); var strUser = e.options[e.selectedIndex].value; document.contactus.yesandno.value = strUser; alert(document.contactus.yesandno.value); return strUser; } my alert will gove yes or no depending on what i chose in the dropdown but HOWCOME it does not go into the if ($_GET['yesandno'] == "no") ???? please help??? This function is throwing the following error: invalid input syntax for type timestamp "1301297896" Code: [Select] function removeInactiveUsers(){ if(!TRACK_VISITORS) return; $timeout = time()-USER_TIMEOUT*60; $result = pg_query_params($this->connection, "delete from active_users where timestamp < $1", array($timeout)); $this->calcNumActiveUsers(); } I know the problem is with $timeout using a php timestamp vs postgresql timestamp but I'm not sure how to fix that Hey guys! I'm making a locally run web based application for entering/storing/editing data. I am trying to do this thing where I export a 'records.txt' file to a different location which can be selected by the user. I have a lame <input type='text' value='H:\'> box going on which I was going to use to define the path for the file to be saved, but I want to be able to use a pop up windows (or whatever native OS finder application) just like the one which appears when you use <input type='file'>. Now that I think about it, I think this is more of a html question, but it's 2.30am and my project is due today... See! what the hell, I just habitually pressed ctrl-s after working in dreamweaver for hours and the exact function which I am looking for popped up, how do I do that?! Please thanks guys I think I understand that there can only be one "submit" button on a page.
I want buttons for separate forms to not trigger the empty errors on the other forms...
How do you accomplish specific button actions?
I think I've tried it with javascript but you can do it with PHP right?
Thanks for any help.
Hello, Iv written a small script in JS to add input boxes of the type file to the page.. My problem is when i use multiple of those input boxes and submit the form the $_FILES variable only reads 1 of those boxes.. This is the javascript im using: Code: [Select] function addImageBox() { var imageBoxes = document.getElementById("imageBoxes"); var tr = document.createElement("tr"); var td = document.createElement("td"); var td2 = document.createElement("td"); var inputFile = document.createElement("input"); inputFile.setAttribute("type", "file"); inputFile.setAttribute("name", "image[]"); inputFile.setAttribute("style", "width: 450px"); td.appendChild(document.createTextNode("Image")); td2.appendChild(inputFile); tr.appendChild(td); tr.appendChild(td2); imageBoxes.appendChild(tr); } When i add 2 boxes (making it 3 boxes on the page in total) and count the $_FILES var after submiting the form, the count method returns 1, and when i var_dump it only 1 array is in $_FILES. Any idea's? thanks! hidden input field type doesnt display the full value i get from table, say if it is a first name and last name i get only the first name. here is my input field echo "<input type=hidden name=proid value=$result_row[project_id]></include>"; echo "<input type=text value=$result_row[project_name] readonly></include>"; my sql query returns the full name but when i input into the text field it returns an incomplete project name like say if it is fans of soccer, i just get the value "fans" in my display..... Long time lurker, first time poster here. I am having a problem with a multiple file uploader form I am trying to build. I am using the CodeIgniter framework, but I believe my problem is with the form itself. Here is the form: Code: [Select] <form action="http://localhost/show/submit" id="sendfiles" method="post" name="sendfiles" enctype="multipart/form-data"> <input type="hidden" name="doup" value="1" /> <input type="file" name="userfile1" value="" id="userfile1" size="20" /> <br /> <input type="file" name="userfile2" value="" id="userfile2" size="20" /> <br /> <input type="file" name="userfile3" value="" id="userfile3" size="20" /> <br /> <input type="submit" name="submit_btn" value="Upload" /> </form> The form is being passed to this function: if(empty($_POST['doup'])){ foreach($_REQUEST as $k => $v) print ">>> $k : $v <br />"; $data['form_open'] = form_open_multipart(uri_string(), array( 'id' => 'sendfiles', 'method' => 'post', 'name' => 'sendfiles' )); $data['form_flag'] = form_hidden('doup', '1'); $data['file1'] = form_input(array( 'id' => 'userfile1', 'name' => 'userfile1', 'size' => '20', 'type' => 'file', )); $data['file2'] = form_input(array( 'id' => 'userfile2', 'name' => 'userfile2', 'size' => '20', 'type' => 'file', )); $data['file3'] = form_input(array( 'id' => 'userfile3', 'name' => 'userfile3', 'size' => '20', 'type' => 'file', )); $data['form_submit'] = form_submit('submit_btn', 'Upload'); $data['form_close'] = form_close(); $this->load->view('show/submit', $data); } else { $config['allowed_types'] = 'mp3'; $config['max_size'] = '10240'; $config['upload_path'] = $this->config->item('file_upload_path'); $uploaded_files = array(); for($nona=1; $nona<4; $nona++){ if (strlen($_FILES['userfile'.$nona]['tmp_name']) <=0){ echo "tempname$nona failed"; continue; } //print "------ USERFILE $nona ------ <br />"; //print sizeof($_FILES['userfile'.$nona])."<br />"; //foreach ($_FILES['userfile'.$nona] as $k => $v){ // print "$k : $v <br />"; //} $this->upload->initialize($config); $upload = $this->upload->do_upload('userfile'.$nona); if (!$upload){ $form_errors = array('form_errors' => $this->upload->display_errors()); $this->load->view('show/submit', $form_errors); break; } else { $data = array('upload_data' => $this->upload->data()); $data = $data['upload_data']; $fp = $data['full_path']; $filename = strtolower(random_string('numeric', 16) . $data['file_ext']); $rel_path = 'show/submissons/uploaded/'; $path = $this->config->item('media_root_path') . $rel_path; exec('mkdir -p ' . $path , $a1, $r1); exec('mv ' . $fp . ' ' . $path . $filename, $a2, $r2); array_push($uploaded_files, $path . $filename); } } $this->session->set_flashdata('img_data',implode("||", $uploaded_files)); // redirect("show/submit_info"); } The problem is this: When I choose only one file to upload, it works. I can choose any of the 3 inputs and it works great. But as soon as I try to choose 2 or more files, the form fails to post. When I press submit, the page simply reloads and none of the form variables get posted. I have checked settings in php.ini and tried building and rebuilding this form. I'm hoping someone here can provide some insight into what I'm doing wrong? Hi Guys, I have a script that shows the user of my shop what they have looked at. I was wondering if someone can tell me how I can limit this so it only lists 10 and no more. Here is the code: Code: [Select] if(RECENTVIEWED ==1) { if(isset($_COOKIE['jimbeam'])){ $productUrl = SITE_URL."ecom/index.php?action=ecom.pdetails&mode="; $productUrl = $this->libFunc->m_safeUrl($productUrl); foreach ($_COOKIE['jimbeam'] as $name => $value) { $this->obDb->query="SELECT vTitle FROM ".PRODUCTS." WHERE vSeoTitle = '".$value."'"; $rsProd = $this->obDb->fetchQuery(); $this->obTpl->set_var("TPL_VAR_PRODUCTTITLE",stripslashes($rsProd[0]->vTitle)); $this->obTpl->set_var("TPL_VAR_PRODUCTURL",$productUrl.$value); $this->obTpl->parse("recent_blk","TPL_RECENT_BLK",true); } $this->obTpl->parse("mainrecent_blk","TPL_MAINRECENT_BLK"); } } Thanks, Jordan I want to be able to grab any new images uploaded and display them right away on the front page, at the moment I can grab the id of each but that won't update the gallery. Once 4 images are uploaded, the next one to be uploaded pushes the last out of the gallery.
At the moment, I only have 2 images on the db, but I want it ready to be used by a community
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data"> Upload:<br><br> <input type="file" name="image"><br><br> <input type="submit" name="submit" value="Upload"> </form> <?php if(isset($_POST['submit'])) { mysql_connect("localhost","____","____"); mysql_select_db("moduni_images"); $imageName = mysql_real_escape_string($_FILES["image"]["name"]); $imageData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"])); $imageType = mysql_real_escape_string($_FILES["image"]["type"]); if(substr($imageType,0,5) == "image") { mysql_query("INSERT INTO `images` VALUES('','$imageName','$imageData')"); echo "Image uploaded!"; } else { echo '<br>O<font color="#8B0000">nly images are allowed!</font>'; } } ?> <?php mysql_connect("localhost","____","____"); mysql_select_db("moduni_images"); if(isset($_GET['id'])) { $id = mysql_real_escape_string($_GET['id']); $query = mysql_query("SELECT * FROM `images` WHERE `id`='$id'"); while($row = mysql_fetch_assoc($query)) { $imageData = $row["image"]; } header("content-type: image/jpeg"); echo $imageData; } else { echo "Error!"; } ?> <div id="user-gallery"> <h2>Gallery</h2> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> <div class="img"> <a href="scripts/show_image.php?id=2" data-lightbox="image-1"> <img src="scripts/show_image.php?id=2" width="125px" height="71px"> </a> </div> </div> This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=307986.0 Hi.. I used this code for displaying formatted number and I notice that instead comma(,) it become point(.): Code: [Select] $P28_maxdoz = $row['P28_maxdoz']; $P28_maxdoz = number_format($P28_maxdoz, 2, '.', ','); <table> <tr> <td><input type='text' name='P28_maxdoz' value="<?php echo $P28_maxdoz;?>"></td> </tr> </table> the output is : 22.782.20 i need output is : 22,782.20 Thank you hi there, i am fairly new to OOPs in php, i get an error when i declare the argument type (as object) in a function and pass the same type (object). class eBlast { public static function getEmail(object $result) { return $result->email; } } $r = mysql_fetch_object($query); eBlast::getEmail($r); echo gettype($r); // outputs: object error is : Code: [Select] Catchable fatal error: Argument 1 passed to eBlast::getEmail() must be an instance of object, instance of stdClass given, called in C:\wamp\www\integra\client\pl_eblast\admin\send_emails.php on line 145 and defined in C:\wamp\www\integra\client\pl_eblast\app\app.eBlast.php on line 8 if i remove the type declaration in the function it works, but just would like to know why it shows error when pass the same type, also isnt mysql_fetch_object is the instance of stdclass? thanks in advance! First problem fixed. My second problem is if the result is 0X.XX,0 or 0X.XX,1 I would like to remove the first 0 The X.XX are numbers, but the 0 is not always there. Can anyone help please Thanks Probably a stupid question . . .
The MIME type in my php.ini file is set to text/html:
default_mimetype = "text/html"But, because I use XHTML 1.0 Strict, the MIME type of my web pages is set to text/xml: <meta http-equiv="content-type" content="text/xml; charset=utf-8" />I should therefore change the php.ini MIME type to text/xml, right? I hope I can explain what is happening. I have created two forms in PHP. The first 'almost' works, i.e. it shows the data. But I have two problems - 1) the second pulldown menu is always empty and 2) $value from the first pulldown menu ALWAYS equals the last entry thus the last 'if' in the function subdomains ($domains) is always called (but still empty). The code may explain this better than me:
<!DOCTYPE html> <html> <body> <!-- processDomains.php is this file - it calls itself (for testing purposes so I can see what is happening) --> <form action="processDomains.php" method="post"> <?php // create the domains array (there are actually several entries in the array but I cut it down for testing) $domains = array (1 => 'Decommission', 'Migration'); echo "Select Domain:"; echo "<br>"; // Make the domain pull-down menu - this displays correctly echo '<select name="domain">'; foreach ($domains as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; // input doesn't matter what is 'submitted', always goes to last $value echo '<input type="submit" name="submit" value="Submit">'; // call function subdomains subdomains ($value); function subdomains ($domains) { // define values for each array - each array contains available choices for the subdomain pulldown menu $migration = array (1 => 'Application Migration', 'Application Patch', 'Application Upgrade'); $decommission = array (1 => 'Applications', 'Servers', 'Storage'); if ($domains === 'Migration') { echo "Select subdomain:"; echo "<br>"; // Make the Migration pull-down menu echo '<select name="migration">'; foreach ($migration as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; } else if ($domains === 'Decommission') { /* === * since 'Decommission' is the last entry in the 'Domains' pulldown list, $value ALWAYS equals * 'Decommission' and $domains equals $value. So this menu SHOULD work but is always * empty. Thus, two problems - the pulldown menu is always empty and $value isn't based * upon user input. */ echo "Select subdomain:"; // this prints so I know I'm in 'Decommission (I eliminated the echo "$domain" to show I'm always coming here)' echo "<br>"; // Make the 'Decommission' pull-down menu echo '<select name="decommission">'; foreach ($decommission as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; echo '<input type="submit" name="submit" value="Submit">' ) // end of 'if-else' } // end of function 'subdomain' ?> </form> </body> </html>Let me say thank you in advance and I appreciate the help! I know I'm doing something (or more than one thing) wrong and I hope someone can tell me what it is. Best Regards! Edited by mac_gyver, 19 January 2015 - 09:37 PM. code tags around posted code please |