PHP - Auto Fill From Txt File
hi,
i looking for a way to use a auto fill for a inputbox text but all that i found is using a mysql bd. there is any solution using a txt file? stored in server. thanks a lot for your help Similar TutorialsHi All Not sure if this is possible, but I spend loads of time filling in the same form on a 3rd party website when people send me their details to check. Is there any way I am able to build a php script to read and check their details (can do this bit) and then submit them to a form on another website (can't do this bit)? The form is a hotel booking form and is spread over 4 pages. I am creating a simple web application that allows the user to update information in a database. I have a selector that allows the user to select what record they want to update and then a form field to insert the data to be updated. I want the form to to be passed the data from the selected entry "when selected" to auto-complete the default values of the text fields so the user can see the information right in the text fields. This is the form Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Tom's Culture Database</title> <meta name="GENERATOR" content="Quanta Plus"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <style> body { } h3 { color: #585858; } h4 { color : #c00000; } th { background : #000000; border : #ffffff solid 1px; color : #ff0000; text-align : left; } .form_wrapper { background : #000000; padding : 10px; border : solid 2px; } #form_inner { padding : 0 0 0 5px; display : inline-block; } td { border : #000000 solid 1px; } </style> <body> <?php //CONNECT INCLUDE require("connect.php"); //SELECT DATABASE $sql_user_info = mysql_query("SELECT * FROM collections ORDER BY id ASC"); //BEGIN FORM echo "<h3>Select an entry to update or delete!</h3> <form action='mysql_update_action.php' method='POST'><select name='name_select'>"; while ($row = mysql_fetch_assoc($sql_user_info)) { $id = $row['id']; $genus = $row['genus']; $species = $row['species']; $strain_name= $row['strain_name']; echo " <option value = '$id'>$id : $genus $species $strain_name</option> "; } echo "</select> <br><br><br> <DIV class='form_wrapper'> <DIV id='form_inner' align=\"left\"><h4>Genus Name:</h4><INPUT type=\"text\" name=\"to_change_genus_name\"></DIV> <DIV id='form_inner' align=\"left\"><h4>Species Name:</h4><INPUT type=\"text\" name=\"to_change_species_name\"></DIV> <DIV id='form_inner' align=\"left\"><h4>Strain Name:</h4><INPUT type=\"text\"name=\"to_change_strain_name\"></DIV> <DIV id='form_inner' align=\"left\"><h4>P-Value:</h4><INPUT type=\"text\" name=\"to_change_p_value\"></DIV> <DIV id='form_inner' align=\"left\"><h4>Origin:</h4><INPUT type=\"text\" name=\"to_change_origin\"></DIV> <DIV id='form_inner' align=\"left\"><h4>Get From:</h4><INPUT type=\"text\" name=\"to_change_get_from\"></DIV> <DIV id='form_inner' align=\"left\"><h4>Qty:</h4><INPUT type=\"text\" name=\"to_change_qty\"></DIV> <DIV id='form_inner' align=\"left\"><h4>Created:</h4><INPUT type=\"text\" name=\"to_change_date_created\" value=\"M/D/Y\"></DIV><br> <DIV id='form_inner' align=\"left\"><h4>Working Collection:</h4><INPUT type=\"checkbox\" name=\"to_change_work_collection\"></DIV> <DIV id='form_inner' align=\"left\"><h4>DNA Check:</h4><INPUT type=\"checkbox\" name=\"to_change_dna_check\"> </DIV> <br><br> <INPUT type='submit' name='change' value='Update'> <INPUT type='submit' name='name_delete' value='Delete'> </form></DIV>"; //END FORM ?> <?php //SELECT DATABASE $sql_user_info = mysql_query("SELECT * FROM collections ORDER BY id"); while ($row = mysql_fetch_assoc($sql_user_info)) { $id = $row['id']; $genus = $row['genus']; $species = $row['species']; $strain_name = $row['strain_name']; $p_value = $row['p_value']; $origin = $row['origin']; $get_from = $row['get_from']; $qty = $row['qty']; $work_collection = $row['work_collection']; $dna_check = $row['dna_check']; $date_created = $row['date_created']; $last_modified = $row['last_modified']; if ($work_collection == "0"){ $work_collection = "no"; } else { $work_collection = "yes"; } // Define $color=1 echo "<br>"; echo "<table width='400' border='1' align='left' cellpadding='2' cellspacing='0'>"; echo "<tr><th>ID</th><th>Genus</th><th>Species</th><th>Strain Name</th><th>P-Value</th></tr>"; $color= 1; // If $color==1 table row color = #FFC600 if($color==1){ echo "<tr bgcolor='#808080'><td>".$id."</td><td>".$genus."</td><td>".$species."</td></tr>"; // Set $color==2, for switching to other colors $color=2; } // When $color not equal 1, use this table row color else { echo "<tr bgcolor='#ffffff'><td>".$id."</td><td>".$genus."</td><td>".$species."</td></tr>"; // Set $color back to 1 $color='1'; } echo "</table>"; } ?> </body> </html> This is the update actions Code: [Select] <?php //CONNECT INCLUDE require("connect.php"); //GRAB DATA $name_select = $_POST['name_select']; $name_delete = $_POST['name_delete']; $to_change_genus_name = $_POST['to_change_genus_name']; $to_change_species_name = $_POST['to_change_species_name']; $to_change_strain_name = $_POST['to_change_strain_name']; $to_change_p_value = $_POST['to_change_p_value']; $to_change_origin = $_POST['to_change_origin']; $to_change_get_from = $_POST['to_change_get_from']; $to_change_qty = $_POST['to_change_qty']; $to_change_work_collection = $_POST['to_change_work_collection']; $to_change_dna_check = $_POST['to_change_dna_check']; $to_change_date_created = $_POST['to_change_date_created']; $date = strtotime("now"); $current_date = date("m/d/y", $date); if ($name_select&&$to_change_genus_name&&$_POST['change']) { $change = mysql_query("UPDATE collections SET genus='$to_change_genus_name', species='$to_change_species_name' WHERE id='$name_select'"); echo "<br><h2>Data updated</h2><br>"; header( 'Location: http://localhost/sam/Mycelium.eu/mysql_update.php' ) ; } elseif ($_POST['name_delete']) { $delete = mysql_query("DELETE FROM collections WHERE id='$name_select'"); echo "<br><h2>Data deleted</h2><br>"; header( 'Location: http://localhost/sam/Mycelium.eu/mysql_update.php' ) ; } else echo "Please enter some Information"; header( 'Location: http://localhost/sam/Mycelium.eu/mysql_update.php' ) ; ?> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=352528.0 Can someone help me with this.. I cannot figure out why it will not log in.. The actual url and user/pass are valid so feel free to test the live site. <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://www.handy-hanky.com/shirley/homesell_cron.htm'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'user=tom&pass=test&login_theme=cpanel'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); echo "STORE = $store<br>"; // CLOSE CURL curl_close ($ch); ?> Folks, I have a flat file or CSV, which has the tree structure of the Nesed Categories (All are delimited by either > or tab, it can be set easily). I want a PHP/Mysql code/routine that i can automaticaly create a table in MYsql with Parent Child relationship. Logic is there in my mind, every distinct Node will be an ID which while every child node will have the PID (parent ID) of its Parent. So the below data from flat file (Actual Data can be N Level Deep at least 4 Level): Electronics Electronics > Phones Electronics > Phones > Iphone Electronics > Phones > LG Electronics > Phones > Samsung Electronics > Phones > Samsung > 3G Electronics > Laptops Electronics > Laptops > Dell Electronics > Laptops > Sony Electronics > Laptops > HP Electronics > Laptops > HP > Core 2 Duo Will look like this in Mysql Table Structu Quote http://pastie.org/1592730 This is the Logic i need ot adopt, but i have no clue on how to code it to extract in this table structure and define this paren tchild mapping automatically. Can someone Help me out wiht this? Cheers Natasha T Hey Everyone, I'll start by saying that I am a very novice php programmer. But I am working on a file storage website, and I have it working and running properly, what you see here is on a new page called index2.php (Thought you might need to know) and full working version can be found here, http://www.jstpreview.net84.net now want I want the site to do is automatically generate a new .php or .html page once the user presses the "submit" button, I've looked through many tutorials to figure this out but anything I have tried so far didn't work. So anyways, the page generated should be named the name of the file uploaded plus the extension. I also want this page to be generated using a pre-uploaded template but if you look at the code, you will see that I havn't implemented that part yet. Code: [Select] <?php //Load the settings require_once("settings.php"); $message = ""; //Has the user uploaded something? if(isset($_FILES['file'])) { $target_path = Settings::$uploadFolder; $target_path = $target_path . time() . '_' . basename( $_FILES['file']['name']); //Check the password to verify legal upload if($_POST['password'] != Settings::$password) { $message = "Invalid Password!"; } else { //Try to move the uploaded file into the designated folder if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) { $message = "The file ". basename( $_FILES['file']['name']). " has been uploaded"; } else{ $message = "There was an error uploading the file, please try again!"; } } //Clear the array unset($_FILES['file']); } if(strlen($message) > 0) { $message = '<p class="error">' . $message . '</p>'; } /** LIST UPLOADED FILES **/ $uploaded_files = ""; //Open directory for reading $dh = opendir(Settings::$uploadFolder); //LOOP through the files while (($file = readdir($dh)) !== false) { if($file != '.' && $file != '..') { $filename = Settings::$uploadFolder . $file; $parts = explode("_", $file); $size = formatBytes(filesize($filename)); $added = date("m/d/Y", $parts[0]); $origName = $parts[1]; $filetype = getFileType(substr($file, strlen($file) - 3)); $uploaded_files .= "<li class=\"$filetype\"><a href=\"$filename\">$origName</a> $size - $added</li>\n"; } } closedir($dh); if(strlen($uploaded_files) == 0) { $uploaded_files = "<li><em>No files have been uploaded yet!</em></li>"; } function getFileType($extension) { $images = array('jpg', 'gif', 'png', 'bmp'); $docs = array('txt', 'rtf', 'doc'); $apps = array('zip', 'rar', 'exe'); if(in_array($extension, $images)) return "Images"; if(in_array($extension, $docs)) return "Documents"; if(in_array($extension, $apps)) return "Applications"; return ""; } function formatBytes($bytes, $precision = 2) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); $bytes /= pow(1024, $pow); return round($bytes, $precision) . ' ' . $units[$pow]; } ?> <!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=ISO-8859-1" /> <style type="text/css" media="all"> @import url("style/style.css"); </style> <script src="http://code.jquery.com/jquery-latest.js"></script> <title>JetStorm Technologies | Staff - CloudNet</title> </head> <body> <div id="container"> <h1></h1> <form method="post" action="index.php" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="15728640" /> <fieldset> <legend>Add a new file to CloudNet:</legend> <?php echo $message; ?> <p><label for="name">Select file:</label><br /> <input type="file" name="files" /></p> <p><label for="password">Authentication for upload:</label><br /> <input type="password" name="password" /></p> <p><input type="submit" name="submit" value="Start upload" /></p> </fieldset> </form> <fieldset> <center> <?php if(isset($_FILES['file'])); //else $file=1; $file = $_POST["$origName"]; // grabbed from the form $file = fopen("filepages/" . $origName .".php","x"); //(Creates the file) fwrite($out, "<p> Man this really does not work $origName</p>"); // Generates the contents of file ?> </center> </fieldset> <fieldset> <legend>Previousely uploaded files</legend> <ul id="menu"> <li><a href="">All files</a></li> <li><a href="">Documents</a></li> <li><a href="">Images</a></li> <li><a href="">Applications</a></li> </ul> <ul id="files"> <?php echo $uploaded_files; ?> </ul> </fieldset> </div> <script src="js/filestorage.js" /> </body> </html> I would greatly appreciate it if someone can point out and fix the errors in this code, but it would be even more appreciated if someone could provide a working source code of auto-generation of pages on form submit. Thanks in advanced Hello all. In lack of better terms, I am a programming noobie when it comes to designing code. I can look at a code and figure it out, but basically I am trying to figure this out. I host a website from home, running on a server 2008 machine, with apache/php, basically to share files from home, work, friends house, wherever I need. I do have a FTP for this, but I also want to be able to upload files via http. I actually want to be able to set a time or date that the file will auto-delete. Such as, I select a file from my local machine, set the deletion time to 1 hour/60 minutes/3600 seconds, whatever, upload it to the site, and it spit back a url that I can access that file for that set amount of time. It would be great to implement something like bit.ly to shorten the link, or even something to randomize the link. Any ideas on that from anyone? Willing to donate (paypal) a little bit if someone can actually help me out, or point me in the right direction. A week on google has proved useless. Thanks so much. $connet = mysql_connect("host", "db_username", "pass") or die(mysql_error()); $user = $_SESSION['SESS_FIRST_NAME']; mysql_select_db('db_name, $connet) or die(mysql_error()); mysql_query("SELECT members Get $earn='earned' WHERE $user='username' LIMIT 1;"); $earn = $total_earn; ?> <a>$<?php echo "$total_earn";?></a> So a project I have simply to learn how it is done is to make an auto updating sitemap with a auto submitter. I have been doing a little research on sitemaps but haven't found much in the way of a tutorial or white paper or similar, anyway I was wondering if I am on the right track or not. What I was thinking for the auto-updating sitemap is since site maps are XML, when an article is published using my custom CMS/Blogging system, I make it rewrite the sitemap appending the new URL that will be generated. Then for the auto-submit, I can either make it a cron job or just manual press, but it would go though a for list of URLs, replacing the end part with my site map url. I think that is how it would be done. If you have a better idea, or can point out an article so I can understand a lot more with sitemaps, I will appreciate it, I am trying to learn as much as possible, I have gone to the offical website (sitemaps.org) but it doesn't have what I am looking for. Thanks, James //php code <?php include_once('con.php'); if(!empty($_GET['search'])) { $search = $connect->prepare('SELECT * FROM posts WHERE title LIKE :search'); $search->bindValue(':search', '%'.$_GET['search'].'%', PDO::PARAM_STR); $search->execute(); ?> <?php while($row = $search->fetch()) {?> <li class="result" onClick="searchValue('<?php echo $row['title'];?>')"><?php echo $row['title'];?></li> <?php } ?> <?php } ?> //ajax $('#inputsch').keyup(function(){ $.ajax({ type: 'GET', url: 'fetch.php', data:'search='+$(this).val(), success: function(data){ $('#box').show(); $('#box').html(data); } }); }); }); function searchValue(val) { $('#inputsch').val(val); $('#box').hide(); } //search box <form action="search.php"> <input id="inputsch" type="text" name="search" placeholder="search..." autocomplete="off" autofocus> <button type="submit" value="search" >search</button> </form> <div id="box"></div> //the problem here is when i click the result is only added to input, but i want it to autosubmit
Any suggestions for using to php to take html form data and fill a pdf form? Anything for cakephp? Thanks Code: [Select] <?php $var=$_POST["fname"]; $xmlDoc = new DOMDocument(); $xmlDoc->loadXML($var); $root = $xmlDoc->documentElement; $elms = $root->getElementsByTagName("*"); foreach ($elms as $item) { // gets the name and the value of each $item $tag = $item->nodeName; $value = $item->nodeValue; // outputs the $tag and $value echo $tag. ' = '. $value . ''; I want to use the code above to get all the xml files parent and child names and values and get them into the database. is this going to work? thanks in advance I have a few questions that deal with cURL. Question #1 Lets say I'm using cURL to fill out a form with multiple pages. Is cURL able to navigate through each page of the form retaining all the previous pages information until I reach the last page, then submit it all without losing any data? Question #2 Lets just say theoretically I was trying to fill out a form with a CAPTCHA (which obviously I can't get past). Is there a way to display the web page with all the other information filled out, and just leave the CAPTCHA blank to be manually inputted? I'm really just looking for yes/no answers, but it would be much appreciated if you are able to point me in the right direction as well! Thanks in advance! Hi, I've got a pdf catalog which posts an order to a php form. The idea is that that the php page looks like an order form that the client can check before finally hitting 'submit' (i.e. along the lines of go to shopping cart). I'd like the php page to be editable. Meaning clients can not only look at their echoed order, but change it before committing to it. So the catalog order gets put into a php submit form with editable fields. I've read that others have accomplished this with statements like: Code: [Select] value="<?php echo $clientName; ?>" Which should fill the client name input box on the order form with the posted variable. But it doesn't work properly for me, instead, the form field is filled with "<?xml version=" with the expected name on the line benath the input box and " /> on the line beneath that. Placing the input box declaration entirely within php tags doesn't work either (exactly the same output). Code: [Select] <?php echo ("Name: <input class=\"inputbox\" type=\"text\" name=\"clientName\" maxlength=\"40\" value=\"$clientName\"><br>"); ?> Can anyone help? Steve I have a form that saves the input data as such: Quote bass inshore offshore Array, regional, mid, 70, 40, 2 x yr, all, fellowship knowledge information learnig, one, one, three, four, one, one, two, three, three, four, TPWD round table discussions conservation biology, the guide talking about fishing the venturi, Jack Ellis and TAG fishing in the East Texas creeks., none at present bass inshore offshore Array, regional, mid, 70, 40, 2 x yr, all, fellowship knowledge information learnig, one, one, three, four, one, one, two, three, three, four, TPWD round table discussions conservation biology, the guide talking about fishing the venturi, Jack Ellis and TAG fishing in the East Texas creeks., none at present bass inshore offshore Array, regional, mid, 70, 40, 2 x yr, all, fellowship knowledge information learnig, one, one, three, four, one, one, two, three, three, four, TPWD round table discussions conservation biology, the guide talking about fishing the venturi, Jack Ellis and TAG fishing in the East Texas creeks., none at present This php program reads it back to the screen as it is writen and as you see it above. Code: [Select] <?php $YourFile = "meeting.survey"; $handle = fopen($YourFile, 'r'); while (!feof($handle)) { $Data = fgets($handle); print $Data; print "<hr>"; } fclose($handle); ?> The code below fails. I feel it is because I am using 'explode' incorrectly. Code: [Select] <?php $YourFile = "meeting.survey"; $handle = fopen($YourFile, 'r'); while (!feof($handle)) { $Data = fgets($handle); $answers = explode(',', $Data); print $answers[0]; print $answers[1]; print $answers[2]; print $answers[3]; print $answers[4]; print $answers[5]; print $answers[6]; print $answers[7]; print $answers[8]; print $answers[9]; print $answers[10]; print $answers[11]; print $answers[12]; print $answers[13]; print $answers[14]; print $answers[15]; print $answers[16]; print $answers[17]; print $answers[18]; print $answers[19]; print $answers[20]; print $answers[21]; print "<hr>"; } fclose($handle); ?> My PHP coding skills are minimal at best, any help, direction, comments you have will be greatly appreciated. If you wish to view the survey html go here If you wish to view the php code used to produce the data, Code: [Select] wget http://texasflyfishers.org/quiz/php_tutorial/survey.php If you wish to view a readback of the data go here Everything I've been able to find over the web, tells me this is what I need to do if I want to add some text that tells what each responce means. hey guys thanks for the upcoming support how do I set the blue to fill up the remaining width of the while maininfo div? I tried setting the width:auto <div class="maininfo"> <div class="large">2</div> <div class="smallblock"> <div class="smalltop">3</div> <div class="small">4</div> </div> <div class="smallblock"> <div class="smalltop">5</div> <div class="small">6</div> </div> </div> .maininfo { width: 600px; } .large { float: left; height: 95px; background-color: blue; width:auto; } .smallblock { float: right; height: 90px; margin: 0 0 0 5px; width: 20%; } .small { background-color: red; height: 50%; width: 100%; } .smalltop { background-color: red; height: 50%; width: 100%; margin-bottom:5px; }Edit fiddle - JSFiddle atm i have this in a function: Code: [Select] $returnInfo = array(); $returnInfo["totalWords"] = $totalWords; $returnInfo["uniqueWords"] = count($uniqueWords); $returnInfo["positiveWords"] = $positiveWords; $returnInfo["negativeWords"] = $negativeWords; $returnInfo["rating"] = $mappedrating; return $returnInfo; If i recursive print it it says Array instand of my expected values. p.s., i have found examples where the array get's created in 1 line with all there values but i prefer not to do that since it will be a very long line. Hi, I am using this code, what i want is to random fill up stepa field with either option a or option b every time i refresh the page, any help is highly appreciated!:
<form action="myc.php" method="get"> <label for="element_1"> </label> <div> <select class="element select medium" name="stepa"> <option value="" selected="selected"></option> <option value="option a" >Advanced Human option a</option> <option value="option b">Advanced Human Option b</option> </select> </div> <br> <input type="submit"> </form>
I have database that is a list of categories that I would like to insert into a switch statement. This is the only way that I know how to do it right off hand and of course it doesn't work. I've looked on the internet and found examples but they are slightly over my head as ways to do it. Depending on $group which comes from the url a title an h1 would be assigned. Code: [Select] $q = "SELECT * FROM categories"; $r = @mysqli_query ($dbc, $q); switch ($group) { if ($r) { //If $r ran OK while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)){ case '$row['id_cat']': $h1 = '.$row['group']'; break; } } } Thanks S |