PHP - How Do You Check If Textarea Is Empty?
Hi, I have a form containg three text inputs and one text area. On the php page that processes the form, I want to check first to make sure the user entered something (input field is not empty) before processing the form. I'll just provide a skeleton of form processing page below. *(I'm save space and time by omitting the form itself but he text inputs fields have the following name attributes "name", "company", "email", and the textarea field's name attribute is "message" ) I'll do my best to explain the code in further detail within the code comments.
Code: [Select] <?php //Turn on output buffering. Allows for headers to be called anywhere on script. See pg228 Ulman. ob_start(); if (isset($_POST['submit'])) { // Initialize a session to keep tract of error and success messages: session_start(); //Define a session variable that keeps tract of how many times user accesses page. $_SESSION['views'] = 1; // Connect to the database. require('config/config.php'); //Check for errors. //Check to make sure they entered their name. if (!empty ( $_POST['name'])) { $a = TRUE; } else { $a = FALSE; //This variable will be echoed on the form if field is missing a value $_SESSION['name'] = '*Please enter a valid name.'; } //Check to make sure they entered their company name. if (!empty ( $_POST['company'])) { $b = TRUE; } else { $b = FALSE; //This variable will be echoed on the form if field is missing a value $_SESSION['company'] = '*Please enter the name of an institution you are affiliated with.'; } //Check to make sure email is valid. if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])) { $c = TRUE; }else { $c = FALSE; //This variable will be echoed on the form if field is missing a value or email format is wrong. $_SESSION['email'] = '*Please enter a valid email address.'; } //Check to make sure they entered their message. if (!empty ( $_POST['message'])) { $d = TRUE; } else { $d = FALSE; //This variable will be echoed on the form if field is missing a value $_SESSION['message'] = '*Please enter your message.'; } //If no errors if (empty($_SESSION['name'] ) && empty($_SESSION['company'] ) && empty($_SESSION['email'] ) && empty($_SESSION['message'] ) ) { //Insert data into database. $query = "INSERT INTO table... ; $result = mysql_query($query) or die("Data could not be inserted into table because: " .mysql_error()); if (mysql_affected_rows() == 1) { // Display success message //This variable will be echoed on the form if everything is filled out correctly. $_SESSION['sent'] = "Your email has been sent. We will get back to you shortly."; // Display contact page (the page containing the form) header("Location: contact_page.php"); exit(); }else{die(mysql_error());} //Display error messages. } else {// if errors array is not empty // Display page (page containing the form) header("Location: contact_page.php"); exit(); }//End of if there are errors. }//End of if submit. ?> So there it is. Everything works fine except that the part which checks if the textarea (named "message") is empty, doesn't work. If I click the submit button without filling out any field, the appropriate error messages are printed for the text input fields but not the text area field. If I fill out all fields correctly and leave the "message" field blank, the form gets processed correctly and values are placed in the database and the success message is printed out. This is also the case when I enter a value for "message" textarea field. Now I tried something. I changed the textarea to a text field and the $_SESSION['message'] variable finally got echoed when I left this field blank. So apparently, the problem arises from the fact that the named attribute from a textarea tag is not being processed correctly?? Who knows what's going wrong here? Similar TutorialsHi i would like to know what is the best way to check if a textarea or an input box is empty. Is the empty function effective? Hello, I have encountered a problem and I am not even sure it's stricty PHP-related. The problem is with website I want to migrate to a better hosting provider and I also have to edit the code to make it PHP 5 compatible. I have a news editing panel that uses FCKEditor. There are 3 fields: date, news title, and news text. The first two are OK, but the textarea is empty and non-editable, i.e. I cannot click in it to put the cursor inside. The problem only exists on my local Wampserver (PHP 5.3.0). When I upload all the files to the old hosting server (PHP 5.2.5) the textarea is editable. Here is the code that loads the news editing page: <?php class page extends admin{ function page(){ if(isset($_GET['do'])) { if($_GET['do']=='del'){ mysql_query("DELETE FROM news WHERE id = '$_GET[id]'"); mysql_query("DELETE FROM news_text WHERE parent = '$_GET[id]'"); $this->loc("?nav=news"); } if(!empty($_POST['date'])){ $sql="UPDATE news SET ".$this->post_insert(array("date"))." WHERE id = '$_GET[id]'"; mysql_query($sql); echo $sql; $parent=$_GET['id']; //insert lang values $this->update_langs("news_text",array("name","content"),$parent); $this->loc(); } } } // Sub menu Buttos var $sub_menus=array( array("Списък новини","news"), array("Добави новина","add_news") ); //Sub menu generation function sub_menu(){ for($i=0;$i<sizeof($this->sub_menus);$i++){ echo "<li><a href=\"?nav=".$this->sub_menus[$i][1]."\">".$this->sub_menus[$i][0]."</a></li>"; } } // Language form template function lang_form($name,$id){ echo ' <fieldset> <legend>'.$name.'</legend> <div class="line"><label>Име: </label> <input name="name_'.$id.'" class="text" style="width:450px;" value="'.$this->get_sql_value("SELECT * FROM news_text WHERE parent='$_GET[id]' AND lang='$id'","name").'" type="text" /> </div> <div class="line"><label>Съдържание: </label></div>'; $oFCKeditor = new FCKeditor('content_'.$id); $oFCKeditor->BasePath = 'includes/fckeditor/'; $oFCKeditor->Height= '500px'; $oFCKeditor->Value= $this->get_sql_value("SELECT * FROM news_text WHERE parent = '$_GET[id]' AND lang='$id'","content"); $oFCKeditor->Create(); echo' </fieldset>'; } } $p=new page(); ?> <div id="left"> <ul> <li><h1>Опции:</h1></li> <?php echo $p->sub_menu(); ?> </ul> </div> <div id="center"> <h1>Amalipe.com / Администрация / Новини / Редакция на новина</h1> <form name="add" id="add" action="" method="post"> <fieldset> <legend>Основна информация</legend> <div class="line"><label>Дата: </label> <input name="date" class="text" type="text" value="<?php echo $p->get_value("news","date"); ?>" /></div> </fieldset> <?php $p->lang_forms(); ?> <input value="Промени" class="btn" type="submit" /> </form> </div> The encoded characters you see in the code are Cyrillic names. At first I thought this had something to do with the FCKEditor version so I upgraded it to the last one (FCKeditor_2.6.6) but nothing changed. On my local Wampserver I have two PHP versions - 5.2.9-2 and 5.3.0 - neither works. I have also added 5.2.5 to see if this changes anything but no, it doesn't - the textarea is still empty and non-editable. I hope I can get some help! I have the form / script below that works to add multiple rows of data with one query. One thing I did not think about is what if the first set of form fields are filled and the second is not. Currently the script insert an empty row. I'm sure how I would go about checking for an empty row and if there is an empty row ignore it and do not put it in the DB. Can someone point me in the right direction? Code: [Select] <?php // Begin the script for this page if (isset($_POST['submit'])) { //Assign each array to a variable $id = $_POST['id']; $store = $_POST['store']; $item = $_POST['item']; $itemprice = $_POST['itemprice']; $itemnumber = $_POST['itemnumber']; $couponvalue = $_POST['couponvalue']; $couponsused = $_POST['couponsused']; $limit = count($id); $values = array(); // initialize an empty array to hold the values for($i=0;$i<$limit;$i++){ $store[$i] = check_input($store[$i]); $item[$i] = check_input($item[$i]); $itemprice[$i] = check_input($itemprice[$i]); $itemnumber[$i] = check_input($itemnumber[$i]); $couponvalue[$i] = check_input($couponvalue[$i]); $couponsused[$i] = check_input($couponsused[$i]); $values[$i] = "( '{$id[$i]}', '{$store[$i]}', '{$item[$i]}', '{$itemprice[$i]}', '{$itemnumber[$i]}', '{$couponvalue[$i]}', '{$couponsused[$i]}')"; // build the array of values for the query string } $query = "INSERT INTO `item` (user_id, store, item, itemprice, itemnumber, couponvalue, couponsused) VALUES " . implode( ', ', $values ); // Form the query string and add the implod()ed values if (!mysql_query($query,$link)){ die('Error: ' . mysql_error()); } else { $added = "Your items have been added."; } } ?> <div class="pageContent"> <div id="main"> <div class="container"> <?php echo $added; if($_SESSION['id']){ echo '<form action="" method="post">'; echo '<table cellpadding= "4">'; echo '<tr>'; echo '<input type="hidden" name="id[]" id="id[]" value='.$_SESSION['id'].' />'; echo '<td><DIV CLASS="p2"><b>Store</b></div>'; echo '<input type="text" name="store[]" id="store[]" size="15" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b>Item</b></div>'; echo '<input type="text" name="item[]" id="item[]" size="15" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b>Item Price</b></div>'; echo '<input type="text" name="itemprice[]" id="itemprice[]" size="5" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b>Item #</b></div>'; echo '<select name="itemnumber[]" id="itemnumber[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><DIV CLASS="p2"><b>Coupon Value</b></div>'; echo '<input type="text" name="couponvalue[]" id="couponvalue[]" size="10" maxlength="255"/></td>'; echo '<td><DIV CLASS="p2"><b># Coupons</b></div>'; echo '<select style="width: 60px;" name="couponsused[]" id="couponsused[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><DIV CLASS="p2"><b>Doubled Coupon</b></div>'; echo '<select style="width: 75px;" name="doubledcoupon[]" id="doubledcoupon[]"><option value="1">Yes</option><option value="0">No</option></td>'; echo '</tr>'; echo '<tr>'; echo '<input type="hidden" name="id[]" id="id[]" value="'.$_SESSION['id'].'" />'; echo '<td><input type="text" name="store[]" id="store[]" size="15" maxlength="255"/></td>'; echo '<td><input type="text" name="item[]" id="item[]" size="15" maxlength="255"/></td>'; echo '<td><input type="text" name="itemprice[]" id="itemprice[]" size="5" maxlength="255"/></td>'; echo '<td><select name="itemnumber[]" id="itemnumber[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><input type="text" name="couponvalue[]" id="couponvalue[]" size="10" maxlength="255"/></td>'; echo '<td><select style="width: 60px;" name="couponsused[]" id="couponsused[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option></select></td>'; echo '<td><select style="width: 75px;" name="doubledcoupon[]" id="doubledcoupon[]"><option value="1">Yes</option><option value="0">No</option></td>'; echo'</tr>'; echo'<tr>'; echo '<input type="submit" name="submit" value="Submit Item">'; echo'</tr>'; echo '</table>'; echo'</form>'; } else { echo '<h1>Please, <a href="index.php">login</a> and come back later!</h1>'; } ?> </div> </div> </div> Ok so i have registration page on my webs but i didn't work on empty fields so how could i check all fields? Code: [Select] //if no name if(!$name){ $error = "Username missing."; } //if no pass if($pass == false){ $error = "$error,Password missing"; } //if no pass conf if($pass_conf == false) { $error = "$error,Pass conf missing."; } //if no email if($email == false){ $error = "$error,Email missing."; } //pass conf if($pass != $pass_conf){ $error = "$error,Passwords do not match."; } echo "<script>alert('$error');</script>;"; //header("Location: register.php"); My script gives same results every time (even if i fill any of fields)...also if i un-comment header command it wont show alert..it just reloads the page So can anyone help me with this? Thanks.. I have two array, how I can have if else to check if both array1 and array2 are empty? if (empty both arrays) { } else { even if one of them are not empty } i am pulling the login date from the databases and i want it to check if the variable is empty and if it is echo Never Loged In and if it not empty echo the date <?php include'db.php'; $id=$_GET['id']; $sql=mysql_query("SELECT * FROM admin WHERE id='$id'")or die(mysql_error()); while($row=mysql_fetch_array($sql)) { $date=$row['login_date']; if($date > 0) { echo"Never Loged In"; } else { echo"$date"; } } ?> Been trying to find an answer and keep running around in circles... I have: ( left test echos in there) if ($r['left_house_number'] != '') { /* Now see what they are supposed to get */ $left_customer_query = "SELECT * FROM customer WHERE house_number ='".$r['left_house_number']."' AND street = '".$r['left_house_street']."' AND route_number = '".$_SESSION['route_number']."'"; // echo "SELECT * FROM customer WHERE house_number ='".$r['left_house_number']."' AND street = '".$r['left_house_street']."' AND route_number = '".$_SESSION['route_number']."'"; $left_customer_result = mysql_query($left_customer_query) or die(mysql_error()); $left_customer_result_count = mysql_num_rows($left_customer_result); echo $r['left_house_number'].' =lhn1'; while ($lrow = mysql_fetch_array($left_customer_result)) { echo $r['left_house_number'].' =lhn2'; /* See if there is any customer if not display blank row */ echo $left_customer_result_count.' = count '; if ($left_customer_result_count < 1) { echo $r['left_house_number'].' =lhn3'; echo '<span class="delivery_nothing">'.$r['left_house_number'].' </span> 1<span class="delivery_nothing">'.$r['left_house_street'].' '; } else { /* Have a customer, now check to see if they are supposed to get something */ if ($lrow['status'] != "AC" && $lrow['status'] != "VH") { /* Customer is stopped or on vacation so show house number and street not bolded */ echo '<span class="delivery_nothing">'.$r['left_house_number'].'</span>2<span class="delivery_nothing">'.$r['left_house_street']; echo $r['left_house_number'].' =lhn4'; } else { /* Now check for correct delivery day and return data */ if (Show_Product($lrow['product']) == '1') { echo $r['left_house_number'].' =lhn5'; echo '<span class="delivery_bold">'.$lrow['house_number'].'</span><span class="delivery_bold">'.$lrow['placement'].'</span><span class="delivery_bold">'.$lrow['street'].'</span>'; echo Product_Formater($lrow['product']); } I have tried... if ($left_customer_result_count < 1) { if ($left_customer_result_count == 0) { if ($left_customer_result_count == '') { if ($left_customer_result_count === 0) { And I can't get it to work. the count "test echo" is either blank or 1 If I echo the sql statement with values I know aren't in the db and paste it into phpmyadmin: SELECT * FROM customer WHERE house_number = '3333' AND street = 'Chili Avenue' AND route_number = '68-24-630' I get: "MySQL returned an empty result set" And if I change it to something that is in the db: SELECT * FROM customer WHERE house_number = '3019' AND street = 'Chili Avenue' AND route_number = '68-24-630' I get: "Showing rows 0 - 0 (1 total, Query took 0.0012 sec)" So what do I have to do to get this to work right? What does it actually output when there are no results returned? thanks, Hey guys, Really dumb question, but I want to check if a bunch of variables are all not empty. Then, if they aren't, I want to execute a mySQL query. Right now I have this which I know is wrong because it doesn't work the right way: Code: [Select] if($album != null || $artist != null || $year != null || $genre != null) { // stuff here... } Obviously I want all of those variables to be checked if they are empty or not. I did a quick Google and found that checking if the variables are null wouldn't be the correct way of solving this situation because an "empty string" is still not null? Anyway, any help would be appreciated. I'm pretty sure it's really simple :p. Now this one is a bit of a shit head. I am using a really comprehensive class i found on on the web for upload / re-size / crop but i want to be able to override it's error handling and i am not good enough to start modifying the code in the class with out fucking it up. Firstly i will show you how i have invoked the class. Code: [Select] if( isset($_FILES['image'] ) ) { //Class includes include("../scrips/php/cms/database.insert.class.php"); include ("../scrips/php/cms/img.upload.resize.crop.class.php.php"); //----------|Start: upload, resize & save $your_image = new _image; //----------| Upload orginal image $your_image->uploadTo = 'uploads/'; $upload = $your_image->upload($_FILES['image']); //----------| Resize and upload small thumbnail $your_image->newPath = 'thums/'; $your_image->newWidth = 50; $your_image->newHeight = 50; $resized = $your_image->resize(); //----------| Resize and upload medium thumbnail $your_image->newPath = 'thums2/'; $your_image->newWidth = 100; $your_image->newHeight = 100; $resized = $your_image->resize(); //----------| Getting the image name to insert into the database futher on in the code $name = $resized; $img_str = explode("/",$name); $final_img_name = $img_str['1']; echo "Article has been added!"; //----------------|end //----------------| Start database insert (class manipulation) $table = "blog_posts"; $title = "'".$_POST['ArticleTitle']."',"; $img = "'".$final_img_name."',"; $post = "'".$_POST['ArticleBody']."',"; $aurthor_id = "'1',"; $category_id = "'".$_POST['Category']."',"; $date_posted = "NOW()"; $values = array("$title","$img","$post","$aurthor_id","$category_id","$date_posted"); $fields = array('title,','img,','post,','aurthor_id,','category_id,','date_posted'); $obj= new DatabaseInsert; $obj->DatabaseConnectionRequire(); $obj->ArticleInsert($values,$fields,$table); //----------------|end } As you can see it's fairly basic. What i want to do is before it runs this script and starts including/invoking the class etc, i want to be able to check to see if there is a value been posted from a FILE FORM OBJECT and if there is to proceed with this script, alternatively i want it to execute another code which will handle it in regards to the concept of my page. A simple javascript alert with be ok providing it reloaded the page to it's default state. If any one can help me here i would appreciate it a lot. Thanks i am trying to check if the array element (which would be a file) is null or not. when i run it, uploading one file, it says "Please select some files to upload first!" X 3. what am i doing wrong? my code: http://pastebin.com/m0k3fEd2 Code: [Select] Array ( [Comment] => Array ( [post_id] => 1 [name] => cc [email] => [body] => spam ) ) How can i check if email is empty or not? Is there any php built in function? Should i use foreach? Hi All, I guess there must be someway to do this with regex, but I'm not too hot on regex. What I want to do is check a text area for the presence of a phone number, and if it is there remove it. Ideally I don't want to remove all number as there might be a need for them to use a number, for example... I am 25 years old would be fine, but entering their number wouldn't be. Is there anyway of tacking this with regex, or is it going to be tricky? Many thanks, Greens85 Hello Everyone, I am having issues where people are submitting null characters on my website (I.e. %00). Currently, I check if their is a value by using the empty function, and I also am checking if the value after running the trim command is =="". How can I check for these special characters to make sure that whatever they are submitting actually contains some sort of legitimate value? Thanks! Man, I'm having a rough week with questions--if you're following at home. Basically matching a Coach's first and last name to another table, which if matched will yield information about that coach's team. Code: [Select] // or get user by username $current_user = wp_get_current_user(); $current_first = $current_user->user_firstname; $current_last = $current_user->user_lastname; $current_id = $current_user->ID; echo '<div class="contact_form">'; echo $current_first . ' ' . $current_last .' :: '; $query = "SELECT * FROM schools WHERE coachFirst='".$current_first."' AND coachLast='".$current_last."'"; $result = mysql_query ($query); if(!$result) { echo 'There is not a match for your name.'; } else { while($school= mysql_fetch_array($result)) { echo $school['school'] . ' ' . $school['id']; include(ABSPATH ."wp-content/plugins/my-team/form.php"); } echo '</div>'; echo '<div class="roster">'; include(ABSPATH ."wp-content/plugins/my-team/roster.php"); echo '</div>'; } What I am looking for is that if any field in a database is empty, the form comes back and puts in the word "empty" into the web page, but not the database. I got this right now, it shows the first part fine, but the second part it doesn't show the "Empty" comment... I don't understand why... as far as I can tell the code is fine... Code: [Select] <?php //Nonconformity, Disposition, Comments and Comments & Additional Details echo '<div id="box3">'; if (!empty($row['Nonconformity']) || !empty($row['Disposition']) || !empty($row['Comments']) || !empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />' . $row['Nonconformity'] . '</div>'; echo '<div id="dis"><span class="b">Disposition: </span><br />' . $row['Disposition'] . '</div>'; echo '<div id="comm"><span class="b">Comments: </span><br />' . $row['Comments'] . '</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />' . $row['CommentsAdditional_Details'] . '</div>';} else if (empty($row['Nonconformity']) || empty($row['Disposition']) || empty($row['Comments']) || empty($row['CommentsAdditional_Details'])) { echo '<div id="non"><span class="b">Nonconformity: </span><br />Empty</div>'; echo '<div id="dis"><span class="b">Disposition: <br /></span>Empty</div>'; echo '<div id="comm"><span class="b">Comments: <br /></span>Empty</div>'; echo '<div id="comma"><span class="b">Comments and/or Additional Details: </span><br />Empty</div>';} echo '</div>'; ?> I have a form that generates html code, and displays it in a textarea with submit button. I want to submit button to take the data entered in that textarea1 on page 1, and upload to textarea2 on page 2 How can I do this? I have no idea where to start. I have search page in the form of search.php?q=query, as the php script calls for other files and a long process. When visiting search.php directly, the value of q is indeed null, and it makes a long loop and use lots of cpu. How to kill the script or redirect to the main page when visiting search.php? i have made query and i want replace with no data N/A i have tryed with swich but no luck Code: [Select] if (($row['name']) = empty) { echo('n/a'); } Hi everyone! I'm new to PHP and needed from you. I have the following code that I can't figure out why it doesn't work on the last elseif. If I comment out the first elseif (line 19-39), it does go through the last elseif. Can someone here help? Thank you!!! The content of Instructors.txt as follow: ID#|fName lName|email_address|course1:course2:course3 ID#|fName lName|email_address|course1:course3 ID#|fName lName|email_address|course1:course2:course4 ID#|fName lName|email_address|course2:course3:course5:course6 <?php //If we submitted the form if(empty($_POST['Location'])) { $FH = fopen("Locations.txt", "rb"); print "<FORM name=\"myForm\" action=\"test4.php\" method=\"POST\">\n"; print "<P> Location:\n"; print "<select name=\"Location\">\n"; print "<option value=\"\">-- Select --\n"; while (!feof($FH)){ $line_of_text = fgets($FH); $line = explode('|', $line_of_text); print "<option value=$line[1]>$line[1]"; } fclose($FH); print "<input type=\"submit\" value=\" Next 1 \">\n"; exit(); } elseif(empty($_POST['Instructor'])) { $location = ($_POST['Location']); $FH = fopen("Instructors.txt", "rb"); print "<FORM name=\"myForm\" action=\"test4.php\" method=\"POST\">\n"; print "<P> Location: <input type=text value=$location>\n"; print "<P> Instructor: \n"; print "<select name=\"Instructor\">\n"; print "<option value=\"\">-- Select --\n"; while (!feof($FH)){ $line_of_text = fgets($FH); $line = explode('|', $line_of_text); if ($line[0] == "$location") { print "<option value=\"$line[1]\">$line[1]\n"; } } fclose($FH); print "<input type=\"submit\" value=\" Next 2 \">\n"; exit(); } elseif(empty($_POST['Course'])) { $location = ($_POST['Location']); $instructor = ($_POST['Instructor']); $FH = fopen("Instructors.txt", "rb"); print "<FORM name=\"myForm\" action=\"test4.php\" method=\"POST\">\n"; print "<P> Location: <input type=text value=$location>\n"; print "<P> Instructor: <input type=text value=\"$instructor\">\n"; print "<P> Course: \n"; print "<select name=\"Course\">\n"; print "<option value=\"\">-- Select --\n"; while (!feof($FH)){ $line_of_text = fgets($FH); $line = explode('|', $line_of_text); if ($line[1] == "Bert Vandenber") { $course = explode(':', $line[3]); for ($i=0; $i<count($course); $i++) { print "<option value=\"$course[$i]\">$course[$i]\n"; } } } fclose($FH); print "<input type=\"submit\" value=\" Next 3 \">\n"; exit(); } ?> |