PHP - Help With Separating The Html From The Php
I'm trying to separate the HTML(form) into a separate .html file (from the php file below).
Someone suggested to "place the HTML in someFile.html and the PHP in someFile.php, and alter the <form> tag's 'action' element in the .html file to target someFile.php". But I don't know how to alter the <form> tag's 'action' element in the .html file to target this upload_file.php file. Any additional help will be appreciated. <?php session_start(); require_once 'phps3integration_lib.php'; $message = ""; if (@$_POST['submit'] != "") { $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip", "flv", "mp4"); $extension = end(explode(".", $_FILES["file"]["name"])); if (($_FILES["file"]["size"] < 32428800) && in_array($extension, $allowed_ext)) { if ($_FILES["file"]["error"] > 0) { //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "<br>";//Enable this to see actual error $message.="There is some error in upload. Please try after some time."; } else { $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true); if ($uploaded_file != FALSE) { $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous"; $form_data = array( 'file' => $uploaded_file, 'user_name' => $user_name, 'type' => 'file' ); mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error()); $message.= "File successfully uploaded in S3 Bucket."; } else { $message.="There is some error in upload. Please try after some time."; } } } else { $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip file of maximum size 30 MB."; } } ?> <?php require_once 'header.php'; ?> <fieldset> <legend>PHP AWS S3 integration library Demo1</legend> Description: In this demo a file is being upload to an S3 bucket using "PHP AWS S3 integration library". After upload you can check the uploaded file in below table. If you require some manipulation before uploading file to S3 then check <a href="upload_file_manually.php">Demo2</a> <br /> <br /> <form action="" method="post" enctype="multipart/form-data"> <div class="control-group"> <label for="file" class="control-label">Choose a file to upload: <span style="color:red">*</span></label> <div class='controls'> <input id="file" type="file" name="file" /> <?php //echo form_error('file'); ?> </div> </div> <div class="control-group"> <label for="user_name" class="control-label">Your name:</label> <div class='controls'> <input id="user_name" type="text" name="user_name" maxlength="255" value="" /> <?php //echo form_error('user_name'); ?> </div> </div> <div class="control-group"> <label></label> <div class='controls'> <input type="submit" name="submit" value="Submit" class="btn"> </div> </div> </form> </fieldset> <?php if ($message != "" || @$_SESSION['message'] != "") { ?> <div class="alert alert-success"> <?php echo $message; ?> <?php echo @$_SESSION['message']; @$_SESSION['message'] = ''; ?> </div> <?php } ?> <div> <table class="table table-hover"> <caption> <strong>Last 10 user uploaded files</strong> </caption> <?php $files_result = mysql_query("SELECT * from `phps3files` WHERE type LIKE 'file' ORDER by id DESC LIMIT 10"); $i = 1; while ($file = mysql_fetch_object($files_result)) { ?> <tr> <td><?php echo $i++; ?></td> <td><a href="<?php echo site_url_s3("uploads/" . $file->file); ?>" target="_blank">View/Download</a> </td> <td><a href="<?php echo site_url("delete_file.php?id=" . $file->id); ?>">Delete file from S3</a></td> <td><?php echo "Uploaded by: " . $file->user_name; ?></td> </tr> <?php } if ($i == 1) { ?> <tr> <td colspan="2"> No files uploaded yet</td> </tr> <?php } ?> </table> </div> <h4>Source Code Part of Demo</h4> <pre class="prettyprint lang-php linenums"> <?php session_start(); require_once 'phps3integration_lib.php'; $message = ""; if (@$_POST['submit'] != "") { $allowed_ext = array("gif", "jpeg", "jpg", "png", "pdf", "doc", "docs", "zip"); $extension = end(explode(".", $_FILES["file"]["name"])); if (($_FILES["file"]["size"] < 32428800) && in_array($extension, $allowed_ext)) { if ($_FILES["file"]["error"] > 0) { //$message.="There is some error in upload, see: " . $_FILES["file"]["error"] . "<br>";//Enable this to see actual error $message.="There is some error in upload. Please try after some time."; } else { $uploaded_file = uploaded_file_to_s3($_FILES["file"], "uploads", true); if ($uploaded_file != FALSE) { $user_name = @$_POST['user_name'] != "" ? @$_POST['user_name'] : "Anonymous"; $form_data = array( 'file' => $uploaded_file, 'user_name' => $user_name, 'type' => 'file' ); mysql_query("INSERT INTO `phps3files` (`id`, `file`, `user_name`, `type`) VALUES (NULL, '" . $uploaded_file . "', '" . $user_name . "', 'file')") or die(mysql_error()); $message.= "File successfully uploaded in S3 Bucket."; } else { $message.="There is some error in upload. Please try after some time."; } } } else { $message.= "Invalid file, Please upload a gif/jpeg/jpg/png/pdf/doc/docs/zip file of maximum size 30 MB."; } } ?> </pre> <?php require_once 'footer.php'; ?> Similar TutorialsHi there, I'm new to the board, so apologise if something like this has been asked before. I'm also quite new to php, so the disaster that is my code will probably make your stomach turn, but it works so far... I am using file_get_contents to grab a website I have access to (my work rota, incidentally), and parse a bit of the html. The aim is to be able to take my rota and do a few things with the times and dates, etc.. So far, I have got the file, parsed the crap out of the string that I don't need, and i'm left with something that looks like this: Code: [Select] <TR><TD ></TD></TR><TR bgcolor='ffff00'><TD>Date</TD><TD>Duty</TD><TD>Dep</TD><TD>Begin</TD><TD>End</TD><TD>Arr</TD></TR><TR><TD ></TD></TR><TR><TD>23 Apr 12, Mon</TD><TD>297</TD><TD>STN</TD><TD>15:55</TD><TD>17:10</TD><TD>DUB</TD></TR><TR><TD>23 Apr 12, Mon</TD><TD>288</TD><TD>DUB</TD><TD>17:35</TD><TD>18:50</TD><TD>STN</TD></TR><TR><TD>23 Apr 12, Mon</TD><TD>293</TD><TD>STN</TD><TD>19:15</TD><TD>20:30</TD><TD>DUB</TD></TR><TR><TD>23 Apr 12, Mon</TD><TD>298</TD><TD>DUB</TD><TD>20:55</TD><TD>22:05</TD><TD>STN</TD></TR><TR><TD ></TD></TR> The people who wrote my rota weren't very tidy, but in a nutshell, I want the information between the TD/TR brackets. Each Row contains cells with my date, time, destination etc in it. I can use striptags, but I end up with a long string that is difficult to split into useful information. I need something that parses the string like this.. "for every row grab information between <td> and </td> and load into $td[0]" etc.." How would I go about doing something like this? I'm a bit stumped. Thanks in advance Horgy Lets say I pull a value from a database field that has a value of 1,2 and what I want to do is seperate them and then run each of those values against a separate table how would that be accomplished. I'm having trouble trying to separate the output into variables that I can use/echo on my page. when I do a print I see the two rows of data all grouped together how can I separate each result base on field and row? maybe something like $line['m_id'][0], $line['m_name'][0], $line['m_id'][1], $line['m_name'][1], etc... $bio = mysql_query("SELECT * FROM soc_meminfo WHERE m_id = '".mysql_real_escape_string($en['mm_id'])."'"); if (mysql_num_rows($bio) == 0) call404(); while ($line = mysql_fetch_assoc($bio)) { foreach ($line as $key => $value) { $en['b'.$key] = str_replace("\n",'<br/>',stripslashes($value)); } echo '<pre>'; print_r($line); echo '</pre>'; } I'm going through my project trying to find a way of separating the backend (the query and php code) from the frontend (html/css). I want to bring the two together with the include function. I've done other but I'm getting confused because the while loops html code. I don't want someone to do this for me, I just what someone to highlight the most logical way. <?php include 'auth.inc.php'; include 'db.inc.php'; include 'buy.inc.php'; //connect to database. $db = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die ('Unable to connect. Check your connection parameters.'); mysql_select_db(MYSQL_DB, $db) or die(mysql_error($db)); //select orders that this user has bought. $query2 = sprintf('SELECT d.name_id, d.order_id, d.order_qty, d.product_code, feedback, p.title, c.email FROM order_details d LEFT JOIN product p ON d.product_code = p.product_code LEFT JOIN contact c ON d.name_id = c.name_id WHERE d.buyer_id = "%u"', mysql_real_escape_string($_SESSION['name_id'])); $result2 = mysql_query($query2, $db) or die(mysql_error()); //echo out the information in a while loop, add pagination? $odd = true; while ($row2 = mysql_fetch_array($result2)) { echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">'; $odd = !$odd; echo '<td style="text-align: center; width:100px;">' . $row2['title'] . ' <table> <tr> <th colspan="2">Shipping Information</th> </tr><tr> <td>First Name:</td> <td>' . $row2['title']. '</td> </tr><tr> <td>First Name:</td> <td>' . $row2['order_qty']. '</td> </tr><tr> <td>Last Name:</td> <td>' . $row2['product_code']. '</td> </tr><tr> <td>Billing Address:</td> <td>' . $row2['email'] . '</td> <td>' . $row2['order_id'] . '</td> </tr> </table> </tr>'; if ($row2['feedback'] == 0){ echo ' <form action="reputation.php" method="POST"><p>Please give the seller feedback on how you have received your product. <td><input type="hidden" name="name_id" value="' . $row2['name_id'] . '"></td> <td><input type="hidden" name="order_id" value="' . $row2['order_id'] . '"></td> <td><input type="submit" name="submit" value="Feedback"/></td> </form>'; } } ?> Can someone give me some guidance of how to separate Form Display from Form Processing? I have always used forms that submitted back to themselves which isn't so bad, but then trying to cram in code to display the form, validation errors, and messages after the form is processed all in one file is insane?! Currently I am working on a simple "Add a Comment" form. It would be nice to have a separate form processing script, but I don't know where to begin... Debbie Hi Guys I'm returning to programming after 5 years, almost a newbie. I have a field(column) in a MySQL database table that has strings of characters separated by a delimiter (||). For example: (TOM||PAUL||HARRIS) I would like to separate the strings into an array. Something like this: ARRAY[0] = 'TOM'; ARRAY[1]='PAUL'; ARRAY[3]='HARRIS'; Can some one tell me how to do this? TIA. This is a LINK to the page -> http://shoutkey.com/carriage I have a problem of separating MySQL concatenated info, yet still maintaining their relationship to other arrays in the same order. First off here is the MySQL code: Code: [Select] $query ="SELECT report,"; $query.="GROUP_CONCAT(DISTINCT docID) AS docIDs, "; $query.="GROUP_CONCAT(DISTINCT analyst) AS analysts, "; $query.="GROUP_CONCAT(DISTINCT region) AS regions, "; $query.="GROUP_CONCAT(DISTINCT country) AS countries, "; $query.="GROUP_CONCAT(DISTINCT topic) AS topics, "; $query.="GROUP_CONCAT(DISTINCT date) AS dates, "; $query.="GROUP_CONCAT(DISTINCT event) AS events, "; $query.="GROUP_CONCAT(DISTINCT link) AS links, "; $query.="GROUP_CONCAT(DISTINCT province) AS provinces "; $query.="FROM reports GROUP BY report ORDER BY dates DESC, docIDs DESC"; The most important thing is to get all attributes about each report. The thing is, each report can have as many records as it must, in order to store various types of information, like, if multiple analysts are working on the report, then each one saves their own record, but when retrieving these records MYSQL concatenates the records, to make it look to the analysts like this Report 1 --- Josh, Rebecca --- Philippines However, my problem is trying to display the reports by country... as you can see http://shoutkey.com/carriage. I have no idea about how to split up the countries, while maintaining their relationship to the $rows pulled from MySQL. I am gonna post the entire code, and let me know if anybody has any ideas. Code: [Select] $result = mysql_query($query); $numrows = mysql_affected_rows(); $current = false; while($row=mysql_fetch_assoc($result)) { $dates = $row['dates']; $analysts = $row['analysts']; $provinces = $row['provinces']; $topics = $row['topics']; $regions = $row['regions']; $countries = $row['countries']; $reports = $row['report']; $links = $row['links']; $events = $row['events']; if (!$current){ //first call echo "<h3><a href=\"#\">{$countries}</a></h3>"; //echo first call $current = $countries; echo "<div>" ;//open content div } elseif($current != $countries){ // country has changed echo "</div>"; //close previous content div echo "<h3><a href=\"#\">{$countries}</a></h3>"; //echo subsequent countries $current = $countries; echo "<div><p>" ;//open content div } echo $analysts." ----- ".$provinces." ----- ".$reports; echo "<br /><br />"; } echo "</div>"; ?> </div> Hi there, In a string for a shopping cart I am storing both the item id and the item size selected in a number like this 12s1 where 12 is the id and 1 is the size. How can I separate these from one another again? I'm guessing it's to do with expand() ? Thanks, Jack I have a form that users input user name, password, and email... all writes to csv fine. My problem is I need to concatenate a a string with a variable and some html code will preserving the html when written to the csv.. I need the csv to be this username,password,email,user,category,text with http://sub.domain..com/splash/,something,something here's what i have Code: [Select] <?php if($_POST['formSubmit'] == "Submit") $varUserName = $_POST['username']; $varPW = $_POST['PW']; $varEmail = $_POST['email']; { $fs = fopen("testcsv.csv","a"); fputcsv($fs, array($varUserName,$varPW,$varEmail,"user","title",",category","some text '<a href="http://$varUserName.url.com/splash/>site.com</a>',)); fclose($fs); exit; } ?> and of course I'm getting Parse error: syntax error, unexpected T_STRING, expecting ')' on line 9 Hey guys, I'm a total newbie here, and just about as a new to php. My issue: I have a very large .html file that contain multiple articles (I actually have a few of these, but we'll start with one for practicality). The article titles are all wrapped in <h2> tags, there are 10 articles in one file. The articles are very simple, just a title wrapped with <h2> and then a few paragraphs wrapped in <p> tags. What I want to know how to do: I want to know if there's a way to open that file, and have each article saved as it's own .html or .txt document (the title & following paragraphs of each article). Ultimately taking my 1 large file, and creating the subsequent 10 smaller files from the articles inside of it. I am having trouble explaining this in text so I'll try to illustrate: I have "Articles.html" - which contains (article1,article2,article3.. ..article10) I want to split "Articles.html" and create "Article1.html", "Article2.html", "Article3.html", etc. Is that possible? Or am I looking at something far more complex than I can imagine at this point - perhaps something I'd be better off doing by hand? Ultimately I intend to stick all these articles into a database, but that's the 2nd part of what I want to do (and I think will be the easier of the tasks). Let me know if you need any additional information in the event my description above is unclear... I simply am having issues figuring out how to separate out the text into individual articles. Hi, How do I open all HTML file contained in a folder, then search for the title of the page, and save the title in the database? Also, is it possible to do this using functions? Cheers. require_once 'phpSimpleHtmlDomClass.php'; $html = '<div> <div class="man">Name: madac</div> <div class="man">Age: 18 <div class="man">Class: 12</div> </div>' $name=$html->find('div[class="man"]', 0)->innertext; $age=$html->find('div[class="man"]', 1)->innertext; $cls=$html->find('div[class="man"]', 2)->innertext; wanna get a text from each div class="man" but it didn't work because there is a missing closing div tag on 2nd line of html code. please help me to fix this. thanks in advance. Hi Everybody. I hope someone here can advise the correct method for storing html/text in a MySQL DB AND retrieving it for updating via a <textarea> Basically, I need to store in my DB knowlege base articles, which have a title, category, product version/edition, description, solution, notes, etc... standard KB fields.. sorta... The issue I am experiencing, or the trouble I am having, is when I need to store both formatting HTML and output HTML in the solution or notes fields, html special chars are being interpreted and the HTML that should be displayed is not there. The char codes are interpreted and the browser then "hides" the HTML tags. For example, the solution may be this: Code: [Select] Find the following line: <serverURL>URL</serverURL> Change the URL to reflect your current server URL. The html chars are interpreted and changed to the actual less than and greater than signs rather than their &...; form (ie: < >   etc.) Some code snippets if it helps... Creating a record: Code: [Select] ... $sol = addslashes($_POST['asol']); $notes = addslashes($_POST['anotes']); include('./conf/connect.php'); mysql_query("INSERT INTO `faq_kb`.`articles` (`id`, `solution`, `notes`, `updated`) VALUES (NULL, '$sol', '$notes', NULL) ") or die(mysql_error()); mysql_close($conn); ... Retrieving a record: Code: [Select] ... include('./connect.php'); $get = $_GET['a']; $sql = "SELECT * FROM articles WHERE id='$get'"; $result = mysql_query($sql); mysql_close($conn); while($row=mysql_fetch_array($result)) { $solution = $row['solution']; $notes = $row['notes']; } ... <h4>Solution:</h4> <div align="right"><textarea name="rsol" style="width:550px;height:150px;"> <?php echo $solution; ?> </textarea></div> <h4>Notes:</h4> <div align="right"><textarea name="rnotes" style="width:550px;height:150px;"> <?php echo $notes; ?> </textarea></div> ... Updating a record: Code: [Select] ... $aid = $_POST['id']; $sol = addslashes($_POST['rsol']); $notes = addslashes($_POST['rnotes']); include('./conf/connect.php'); mysql_query("UPDATE `faq_kb`.`articles` SET solution='$sol', notes='$notes' WHERE id='$aid'") or die(mysql_error()); mysql_close($conn); ... I guess, you can ignore my whole spiel above and simply answer this question: what function do I need to use to encode the variable for inserting into the database, and what function do I then need to use to decode the variable for output so that it retains it's formatting html and my output/displayed html (< >)??? Thanks guys! I hope that this makes sense... ------------------------ Further Example: This is what is output (inside the dashes): ---------------------------- To configure your SysAid Server logging to debug mode please do the following. Open the file serverConf.xml located in the directory: [...\SysAidServer\root\WEB-INF\conf\] Change <sysaidLogLevel>info</sysaidLogLevel> to <sysaidLogLevel>debug</sysaidLogLevel> Save the change and then restart the SysAid Server service. -------------------------- And this is what the source of that looks like: Code: [Select] <div class="divText" id="txtselect"><p> <span style="font-size: 10pt; font-family: 'Times New Roman',serif; color: black;" lang="EN-US"> To configure your SysAid Server logging to debug mode please do the following.</span></p> <p><font size="2"><span style="font-family: 'Times New Roman',serif;">Open the file </span></font> <span style="font-size: 10pt; font-family: 'Times New Roman',serif; color: black; font-style: italic;" lang="EN-US"> serverConf.xml</span><span style="font-size: 10pt; font-family: 'Times New Roman',serif; color: black;" lang="EN-US"> located in the directory:</span></p> <p><font size="2"><span style="font-family: 'Times New Roman',serif;"> </span></font> <span style="font-size: 10pt; font-family: 'Times New Roman',serif; color: black;" lang="EN-US"> [...\SysAidServer\root\WEB-INF\conf\] </span></p> <p> <span style="font-size: 10pt; font-family: 'Times New Roman',serif; color: black;" lang="EN-US"> Change <br> </span><font face="Courier New"> <span style="font-size: 10pt; color: black;" lang="EN-US"> <sysaidLogLevel>info</sysaidLogLevel><br> </span></font> <span style="font-size: 10pt; font-family: 'Times New Roman',serif; color: black;" lang="EN-US"> to<br> </span><font face="Courier New"> <span style="font-size: 10pt; color: black;" lang="EN-US"> <sysaidLogLevel>debug</sysaidLogLevel></span></font></p> <p><span style="font-size: 10pt; color: black;" lang="EN-US">Save the change and then restart the SysAid Server service.</span></p> </div> And this is a copy paste straight out of phpMyAdmin: Code: [Select] <p> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> To configure your SysAid Server logging to debug mode please do the following.</span></p> <p><font size="2"><span style="font-family: 'Times New Roman',serif">Open the file </span></font> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black; font-style: italic"> serverConf.xml</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> located in the directory:</span></p> <p><font size="2"><span style="font-family: 'Times New Roman',serif"> </span></font> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> [...\SysAidServer\root\WEB-INF\conf\] </span></p> <p> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> Change <br> </span><font face="Courier New"> <span lang="EN-US" style="font-size: 10.0pt; color: black"> <sysaidLogLevel>info</sysaidLogLevel><br> </span></font> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> to<br> </span><font face="Courier New"> <span lang="EN-US" style="font-size: 10.0pt; color: black"> <sysaidLogLevel>debug</sysaidLogLevel></span></font></p> <p><span lang="EN-US" style="font-size: 10.0pt; color: black">Save the change and then restart the SysAid Server service.</span></p> Then EVEN CRAZIER, I click the edit button on the article and this is (direct copy paste) what is output to the <textarea>: Code: [Select] <p> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> To configure your SysAid Server logging to debug mode please do the following.</span></p> <p><font size="2"><span style="font-family: 'Times New Roman',serif">Open the file </span></font> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black; font-style: italic"> serverConf.xml</span><span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> located in the directory:</span></p> <p><font size="2"><span style="font-family: 'Times New Roman',serif"> </span></font> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> [...\SysAidServer\root\WEB-INF\conf\] </span></p> <p> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> Change <br> </span><font face="Courier New"> <span lang="EN-US" style="font-size: 10.0pt; color: black"> <sysaidLogLevel>info</sysaidLogLevel><br> </span></font> <span lang="EN-US" style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: black"> to<br> </span><font face="Courier New"> <span lang="EN-US" style="font-size: 10.0pt; color: black"> <sysaidLogLevel>debug</sysaidLogLevel></span></font></p> <p><span lang="EN-US" style="font-size: 10.0pt; color: black">Save the change and then restart the SysAid Server service.</span></p> Notice how there are NO < or > chars in this? How do I make this work Thanks guys I'm trying to submit html/php code through an html form and then insert it into a mysql database. I've got the following code so far (without the insert into database query), however when I submit the form I get pushed through to my 403 page. If i comment out the textarea that contains the code I am trying to submit, then it goes through fine. Any ideas? Code: [Select] <? if (isset($_POST['optone'])) {$optone=$_POST['optone']; $opttwo=$_POST['opttwo'];} if (isset($_POST['type'])) {if ($_POST['type']=='Theory') {$optone=1;} if ($_POST['type']=='Demo') {$optone=2;} $opttwo=$_POST['module'];} ?> <h3>Module administration</h3> <script> function setOptions(chosen) { var selbox = document.myform.opttwo; selbox.options.length = 0; if (chosen == " ") { selbox.options[selbox.options.length] = new Option('Please select an option first',' '); document.myform.go.disabled=true; } if (chosen == "1") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } if (chosen == "2") { selbox.options[selbox.options.length] = new Option('Module 1','1'); selbox.options[selbox.options.length] = new Option('Module 2','2'); selbox.options[selbox.options.length] = new Option('Module 3','3'); selbox.options[selbox.options.length] = new Option('Module 4','4'); selbox.options[selbox.options.length] = new Option('Module 5','5'); selbox.options[selbox.options.length] = new Option('Module 6','6'); selbox.options[selbox.options.length] = new Option('Module 7','7'); selbox.options[selbox.options.length] = new Option('Module 8','8'); selbox.options[selbox.options.length] = new Option('Module 9','9'); selbox.options[selbox.options.length] = new Option('Module 10','10'); document.myform.go.disabled=false; } } </script> <br /> <center> <form name="myform" method='post'> Edit: <select id="optone" name="optone" size="1" onchange="setOptions(document.myform.optone.options[document.myform.optone.selectedIndex].value);" > <option value=" " >--Choose--</option> <option value="1" >Theory</option> <option value="2" >Demo</option> </select> <select name="opttwo" size="1"> <option value=" " selected="selected">Please select an option first</option> </select> <input type='submit' name='go' id='go' value='Go' disabled='disabled'/> </form> </center> <br /><br /> <? if (isset($opttwo)) { if ($optone==1) {$query = "SELECT info,userscompleted,last_user,enabled FROM theorydata WHERE TheoryID=".$opttwo; $typestr='Theory'; $texthelp='Code must be entered in HTML';} if ($optone==2) {$query = "SELECT info,userscompleted,last_user,enabled FROM demodata WHERE DemoID=".$opttwo; $typestr='Demo'; $texthelp='Code must be entered in PHP';} $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result); $query2="SELECT full_name FROM users WHERE id=".$row['last_user']; $result2 = mysql_query($query2) or die(mysql_error()); $row2 = mysql_fetch_array($result2); ?> <form method='post' > <table> <tr> <td align='center'> Type: </td> <td> <input type='text' name='type' readonly='readonly' value="<? echo $typestr; ?>" /> </td> </tr> <tr> <td align='center'> Module: </td> <td> <input type='text' name='module' readonly='readonly' value="<? echo $opttwo; ?>" /> </td> </tr> <tr> <td align='center' > Enabled? </td> <td> <select name='enabled'> <option value='yes' <? if ($row['enabled'] == '1') {echo "selected='selected'";}?> >Yes</option> <option value='no' <? if ($row['enabled'] == '0') {echo "selected='selected'";}?> >No</option> </select> </td> </tr> <tr> <td align='center'> Code: </td> <td> <center><font color='red'><? echo $texthelp; ?></font></center> <textarea name='info' rows=35 cols=80><? echo htmlentities($row['info']); ?></textarea> </td> </tr> <tr> <td align='center' > Users completed: </td> <td> <input type='text' name='userscompleted' value="<? echo $row['userscompleted']; ?>" size=4/> </td> </tr> <tr> <td align='center' > Last user: </td> <td> <input type='text' name='last_user' readonly='readonly' value="<? echo $row2['full_name']; ?>" /> </td> </tr> <tr> <td></td> <td align='center'> <input type='submit' value='Edit'/> </td> </tr> </table> </form> <? }//close isset(opttwo) ?> Say I have the following text stored in a MySQL database... Code: [Select] <b>Classic Quote from movie</b> and I retrieve it into a variable called $text, how do I properly echo that so that it keeps the bold tags and actually display the text "Classic quote from movie" in BOLD? I'm doing something wrong somewhere along the line (simply doing "echo $text;") because it displays on the page as... Code: [Select] <b>Classic Quote from movie</b> Instead of... Classic Quote from movie Any info on properly storing and echoing back HTML would be very appreciated. Hi all, I have an html form that sends formdata to a php script called example.php with the POST method. example.php then has the following structu Code: [Select] <?php if(isset($_POST['var1'])) {$var1 = $_POST['var1'];} else {$var1 = 'English';} if(isset($_POST['var2'])) {$var2 = $_POST['var2'];} else {$var2 = 'French';} print" <html> <body> <form> <select id='select1'> <option>var1</option> <option>var2</option> <option>etc...</option> </select> <input type='text' id='input1'> ETC. ETC. </form> </body> </html> "; ?> So example.php has an embedded html form. How do I specify that some elements of the form should take their values from the variables retrieved at the start of the script via the POST command? For example, I want select1 to have 'var1' pre-selected and I want input1 to display var2. var1 & var2 get sent through to example.php fine, I just don't know how to get the embedded html form to use them. Please help! Thanks a lot. Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hi there (first post), I'm trying to learn how to manipulate html with PHP and DOM. I'm fairly new to this. The problem I seem to be having seems to be server related. I've spoken to the support people and they say they don't support simple html DOM and so when I try to call- file_get_html() fatal errors occur. I wonder if someone could point me in the right direction here- are there any available hosts that will support simple html DOM? Any advice appreciated. If you need more info let me know. Thanks in advance. Hello!!! How are you all? Actually i want the user to upload a pdf file and my system will convert that into html for editing. Is there any API or any other solution to solve this problem? I'll be really thankful to you... Waiting for your help... I ahve a php page passwordchange.php.. I want that if a user goes to url passwordchange.php?via=security_question some html input fields will be shown And when user goes to url passswordchange.php?via=previous_password Some other input fields will be shown.. Basically i want to put a lot of html code in php's if statement Code: [Select] <?php if($_GET['via']=="security_question") // LOT OF HTML DATA ?> <?php if($_GET['via']=="previous_password") // LOT OF HTML DATA ?> How sould i use html inside php...??? |