PHP - How To Retain The Values In The Sub Process?
hi there,
I have a chained combo boxes. I manage to get the values for the sub process using onchange event.My problem here is how can I retain the values in the sub process combo box after the page is loaded? main.php Code: [Select] <?php require_once 'connectDB.php'; $sub_id = $_GET['sub_id']; $id = $_SESSION['process_id']; $sql = " SELECT * FROM tb_process ORDER BY pro_id ASC"; $result = mysql_query($sql) or die(mysql_error()); $sql = "SELECT tb_record.rec_tpcd, tb_record.rec_part, tb_record.rec_code, tb_record.rec_vendor, tb_record.rec_location, tb_record.rec_remark, tb_sub_process.sub_name, tb_process.pro_name FROM tb_record LEFT JOIN tb_sub_process ON tb_record.sub_id=tb_sub_process.sub_id LEFT JOIN tb_process ON tb_sub_process.pro_id=tb_process.pro_id WHERE tb_sub_process.sub_id = '$sub_id'"; $result2 = mysql_query($sql); $row = mysql_fetch_assoc($result2); $pro_name = $row['pro_name']; $sub_name = $row['sub_name']; ?> <html> <head> <script type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript" src="js/jquery-1.2.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#selectProcess").change(function() { var processID = $(this).val(); if(processID > 0) { $("#txtID").val(processID); $("#selectSubProcess").load('getSub.php?processID='+processID); } }); $("#selectSubProcess").change(function() { var subProcessID = $(this).val(); if(subProcessID > 0) { window.location = 'main.php?sub_id='+subProcessID; } }); }); </script> </head> <body> <form action="" method="post"> <table> <tr> <td>Process: </td> <td> <select id="selectProcess" name="selectProcess"> <option value="0" selected="selected">---SELECT PROCESS---</option> <?php while ($row = mysql_fetch_array($result)) { $process_id = $row['pro_id']; $process_name = $row['pro_name']; $select = ($id == $process_id) ? 'selected="selected"' : NULL; echo "<option value='$process_id' $select>$process_name</option>"; } ?> </select> </td> </tr> <tr> <td>Sub Process: </td> <td> <select id="selectSubProcess" name="selectSubProcess" > <option>SELECT PROCESS FIRST</option> </select> </td> </tr> </table> </form> <table border=1> <?php while($row = mysql_fetch_assoc($result2)) { extract($row); $imageDir1="images/".$rec_tpcd.".jpg"; $info = @getimagesize($imageDir1); if((bool)$info) { $imageDir="images/".$rec_tpcd.".jpg"; } else { $imageDir="images/NoPhoto.jpg"; } if ($col == 0) { $display .= "<tr>"; } $col++; if ($col == 1) { $col = 0; $display .= "</td>"; } echo "<tr> <td> <img src=$imageDir width='220' height='170' onClick=\"window.open('$imageDir', 'popup','height=500,width=800,scrollbars=yes,resizeable=yes status=yes'); return false\" target=\"_blank\"> </td> <td> <table style='overflow:auto; width:325px;'> <tr> <td width='80' valign='top'>Name</td> <td valign='top'>:</td> <td valign='top' colspan='2'>$rec_part</td> </tr> <tr> <td valign='top'>Code</td> <td valign='top'>:</td> <td valign='top' colspan='2'>$rec_code</td> </tr> <tr> <td>TPCD</td> <td>:</td> <td colspan='2'>$rec_tpcd</td> </tr> <tr class='style15'> <td>Vendor</td> <td>:</td> <td colspan='2'>$rec_vendor</td> </tr> <tr> <td>Location</td> <td>:</td> <td colspan='2'>$rec_location</td> </tr> <tr> <td>Remarks</td> <td>:</td> <td>$rec_remark</td> <td align='right'> <input type='image' name='change[$rec_tpcd]' src='library/cart add.png' width='20' height='20' value='Add To Order List >'/> </td> </tr> </table> </td> </tr>"; } ?> </table> </body> </html> getSub.php Code: [Select] <?php require_once 'connectDB.php'; if(isset($_GET['processID'])) { $process_id = $_GET['processID']; $sql = " SELECT * FROM tb_sub_process WHERE pro_id = '$process_id' ORDER BY sub_id ASC"; $result = mysql_query($sql) or die(mysql_error()); $_SESSION['process_id'] = $process_id; echo "<option>---------------------SELECTION--------------------</option>"; while($row = mysql_fetch_assoc($result)) { $sub_process_id = strtoupper($row['sub_id']); $sub_process_name = strtoupper($row['sub_name']); echo "<option value='$sub_process_id'>$sub_process_name</option>"; } } ?> Similar TutorialsI have several drop down boxes. When submit is clicked it execute query on another page. Problem is when submit is clicked selected values are return to defaults. Is it possible for the values to be remembered after submitting them? Part of the drop down code: Code: [Select] <?php $result = mysql_query("SELECT * FROM product GROUP BY Rim"); ?> <select id="Rim" name="Rim" selected="selected" style="width:158px;position:static;z-index:-1;"> <option value="rim" selected="selected"><?php echo "Rim"; ?></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option>" . $row['Rim'] . "</option>"; echo "<br />"; } ?> </select> Hi there, I am having a PHP form with simple combo box. Here is the code: <form name="form1" method="get" action=""> <select name="select" onChange="form1.submit()"> <option value='value1'>My Value1</option> <option value='value2'>My Value2</option> <option value='value3'>My Value3</option> </select> </form> Now the form is successfully being submitted upon 'onChange' event. The only thing I am trying to do is to retain the value of the new option. As every time I select the value from the combo, it goes back and displays the 'value 1' even when I select value 3 or 2. How do I make the combo box retain the value as 3 (when I select option 3) after the form is submitted. Please reply. Thank you! Hi, I have set up 2 php pages page 1 - add_entry2.php In this page I have a invoice table created where I can dynamically add/delete rows. This has a View Bill button which takes me to page 2- add_entry3.php In this page it shows up the rows added in page 1 in read only format, so if the user wants to modify the data that he/she entered then he must Click on <back> that i have provided in the page 2 which will direct him to page 1 Now the problem starts here on click of Back the dynamically added rows dissappear..which is frustrating..I know its something to do with my code..but can anyone help me fix it. One more thing is that i dont want to store the data into DB till the finalise button is clicked on page 2 so that means till page 2 is submitted nothing goes to DB from Page 1. I am able to retain values if I use the code Code: [Select] <form action="add_entry2.php" name="eval_edit" method="post" format="html"> i,e if I submit back to the same page and retrieve values form $_POST but If I use the code Code: [Select] <input type="button" value="Back" onClick="history.go(-1);return true;">to get back to add_entry2.ph it looses all the values. Is there any other way to code the BACK link retaining my $_POST values(Do you think $_SESSION would work in this case?) I am making a project by designing my own MVC model. In this the user accesses controller class which further calls model class which accesses the database by $dbh attiribute defined public. My View is a script which calls different pages. In the constructor of model I'm establishing connection with the database. Firstly I construct the model object when the user accesses i.e. in the controller class to check in the databse then if the username is not present in the dtaabse I want to insert his info in the database for that I again calla model class but this time I again have to establish connection. Is the $dbh firstly constructed is lost like dangling pointers in C++. Do I have to worry about it. If yes how can I solve this problem. How do I retain a password as a user navigates from page to page without having to ask him for it again. I do not need it to protect the page, I need it to execute whatever selection he makes. enter_psw.html // this is a form verify_psw.php // I have the password here menu1.html // I don't have the password here and need it display_records add_record.php change_record.php delete_record_php Hi all, I have a listbox on a form that gets it's data from a MySQL query, all of which is working fine. I make a selection in my listbox and then submit the form which is reloading itself. However on the reload I would like the listbox to display the selection made by the user, instead it reverts to the first item in the list. I have included the code, if someone could point me in the right direction that would be great. I have searched these forums and tried a few things that are suggested but I still can't get it to work. Code: [Select] <?php include("dbconn.php"); $query = "SELECT location.location_name, printer.model_number, location_printer.serial_number" . " FROM location, printer, location_printer" . " WHERE location.location_id = location_printer.location_id" . " AND printer.printer_id = location_printer.printer_id"; $result = mysql_query($query); echo "<table>"; echo "<th>Location</th>"; echo "<th>Printer</th>"; echo "<th>Serial No</th>"; while(($row = mysql_fetch_array($result))) { echo "<tr>"; echo "<td>".$row['location_name']."</td>"; echo "<td>".$row['model_number']."</td>"; echo "<td>".$row['serial_number']."</td>"; echo "</tr>"; } echo "</table>"; if(isset($_POST['location'])) { $loc = $_POST['location']; echo "<p>Location = <b> $loc </b>"; } ?> <html> <head> <title>Loop Results</title> </head> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" > <table> <tr> <td> <?php $query = "SELECT * FROM location ORDER BY location_name"; $result = mysql_query($query); $default = $_POST['location']; echo "<p>Location: "; echo "<select name='location'>"; while(($row = mysql_fetch_array($result))) { echo "<option value='{$row['location_id']}"; //Selected value if($row['location_id'] == $default) echo " selected "; echo "'>{$row['location_name']}</option>\n"; } echo "</select>"; ?> </td> </tr> <tr> <td> <input type="submit" /> </td> </tr> </table> </form> </body> </html> Hi, I have set up 2 php pages page 1 - add_entry2.php In this page I have a invoice table created where I can dynamically add/delete rows. This has a View Bill button which takes me to page 2- add_entry3.php In this page it shows up the rows added in page 1 in read only format, so if the user wants to modify the data that he/she entered then he must Click on <back> that i have provided in the page 2 which will direct him to page 1 Now the problem starts here on click of Back the dynamically added rows dissappear..which is frustrating..I know its something to do with my code..but can anyone help me fix it. One more thing is that i dont want to store the data into DB till the finalise button is clicked on page 2 so that means till page 2 is submitted nothing goes to DB from Page 1. here is the code(I have removed the java script functionalities to reduce length of the post) add_entry2.php Code: [Select] <html> <head> <title>Page Title</title> </head> <body leftmargin="0" topmargin="0"> <!--- forms are good when you wanna actually do stuff ---> <form action="add_entry3.php" name="eval_edit" method="post" format="html"> <table align="center" width = "75%"> <tr> <td align = "center"> Invoice </td> </tr> <tr> <td align = "center"> <!--- very imporant to give the table an id ---> <!--- otherwise it won't know where to edit ---> <table border="1" id="mySampleTable"> <tr> <th>Item No</th> <th>Item Name</th> <th>Item code</th> <th>Description</th> <th>Unit Cost</th> <th>Quantity</th> <th>Price</th> <th>Cancel ?</th> </tr> <tr> <td>1</td> <td><input type="text" name="itemname[]" size="40" maxsize="100"/></td> <td><input type="text" name="itemcode[]" size="20" maxsize="100" /></td> <td><input type="text" name="description[]" size="20" maxsize="100" /></td> <td><input type="text" name="unitcost[]" size="10" maxsize="100" /></td> <td><input type="text" name="quantity[]" size="4" maxsize="100" /></td> <td><input type="text" name="price[]" size="10" maxsize="100" /></td> <td><input type="CHECKBOX" name="cancel[]"/></td> </tr> </table> <table id="totaltbl"> <tr> <th>Total</th> <th>Vat%</th> </tr> <tr> <td><input type="text" name="total" size="20" maxsize="100" /></td> <td><input type="text" name="total" size="3" maxsize="3" /></td> </tr> </table> <!--- our buttons call our javascript functions when clicked ---> <p> <input type="button" value="Add Row" onclick="addRow();" /> <input type="button" value="Calculate Total Amount" onclick="Totalcal();" /> <input type="hidden" name="count" value=""/> <!--<input type="submit" name="submit" onclick="countRow();" value="Insert into Invoice!" />--> <input type="submit" name="submit" value="View Bill" /> <input type="hidden" name="submitted" value="true" /> </p> </td> </tr> </table> </form> </body> </html> ****************************************************8888 This is add_entry3.php Code: [Select] <?php $num=count($_POST['itemcode']); $itemname= $_POST['itemname']; $itemcode = $_POST['itemcode']; $unitcost = $_POST['unitcost']; $description = $_POST['description']; $unitcost = $_POST['unitcost']; $quantity = $_POST['quantity']; $price = $_POST['price']; $problem = FALSE; ?> <h1 align ="center"><b><u>Invoice Details</b></u></h1> <table align="center" width = "75%"> <tr> <td align = "center"> <table border="1" id="mySampleTableheader"> <tr> <td width="75"><b>Item No</b></td> <td width="275"><b>Item Name</b></td> <td width="155"><b>Item code</b></td> <td width="155"><b>Description</b></td> <td width="95"><b>Unit Cost</b></td> <td width="60"><b>Quantity</b></td> <td width="95"><b>Price</b></td> </tr> </table> <?php $i=0; while ($i < $num) { ?> <!--- forms are good when you wanna actually do stuff ---> <form action="save_entry.php" name="eval_edit" method="post" format="html"> <table border="1" id="mySampleTable"> <tr> <td width="75"><?php echo $i+1; ?></td> <td><input type="text" name="itemname[]" value = "" size="40" maxsize="100" readonly/></td> <td><input type="text" name="itemcode[]" value ="<?php echo $itemcode[$i]; ?>" size="20" maxsize="100" readonly/></td> <td><input type="text" name="description[]" value ="<?php echo $description[$i]; ?>" size="20" maxsize="100" readonly/></td> <td><input type="text" name="unitcost[]" value ="<?php echo $unitcost[$i]; ?>" size="10" maxsize="100" readonly/></td> <td><input type="text" name="quantity[]" value = "<?php echo $quantity[$i]; ?>" size="4" maxsize="100" readonly/></td> <td><input type="text" name="price[]" value = "<?php echo $price[$i]; ?>" size="10" maxsize="100" readonly/></td> </tr> </table> <?php $i++;} ?> <!--- our buttons call our javascript functions when clicked ---> </td> </tr> </table> <p> <table id="totaltbl"> <tr> <th>Total</th> </tr> <tr> <td><input type="text" name="total" size="20" maxsize="100" /></td> </tr> </table> <input type="button" value="Add Row" onclick="addRow();" /> <input type="button" value="Row count" onclick="countRow();" /> <input type="hidden" name="count" value=""/> <!--<input type="hidden" name="count" value=""/> <input type="submit" name="submit" onclick="countRow();" value="Insert into Invoice!" />--> <input type="button" value="Back" onClick="history.go(-1);return true;"> <input type="submit" name="submit" value="Finalise" /> <input type="hidden" name="submitted" value="true" /> </p> </form> </body> </html> Hi all,
I am trying to validate all required fields in my contact form using php. However I am unable to retain what was selected in my country dropdown list after it is selected and submitted if the form had errror while validating. I want the form to retain the value that was selected by the user to stay in the form so that users can make necessary changes and resubmit the form all other values stay in the form except the country dropdown. Please help Below is the code. <!DOCTYPE HTML> <html> <head> <style> .error {color: #FF0000;} </style> </head> <body> <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = $countryErr = ""; $name = $email = $gender = $comment = $website = ""; $country =""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); // check if e-mail address syntax is valid if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/",$email)) { $emailErr = "Invalid email format"; } } if (empty($_POST["website"])) { $website = ""; } else { $website = test_input($_POST["website"]); // check if URL address syntax is valid (this regular expression also allows dashes in the URL) if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) { $websiteErr = "Invalid URL"; } } if (empty($_POST["comment"])) { $comment = ""; } else { $comment = test_input($_POST["comment"]); } if (empty($_POST["gender"])) { $genderErr = "Gender is required"; } else { $gender = test_input($_POST["gender"]); } $country = $_POST['country']; if (!in_array($country, array("AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "Gg", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "AN", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "SH", "KN", "LC", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "CS", "SC", "SL", "SG", "SK", "SI", "SB", "SO", "ZA", "GS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW" ))) { $country1 = "Please select your country";} } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <h2>contact us</h2> <p><span class="error">* required field.</span></p> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> Name: <input type="text" name="name" value="<?php echo $name;?>"> <span class="error">* <?php echo $nameErr;?></span> <br><br> E-mail: <input type="text" name="email" value="<?php echo $email;?>"> <span class="error">* <?php echo $emailErr;?></span> <br><br> <legend>Country:</legend> <select name="country"> <option value="NULL">select</option> <option value="AF">Afghanistan</option> <option value="AX">Ã…Land Islands</option> <option value="AL">Albania</option> <option value="DZ">Algeria</option> <option value="AS">American Samoa</option> <option value="AD">Andorra</option> <option value="AO">Angola</option> <option value="AI">Anguilla</option> <option value="AQ">Antarctica</option> <option value="AG">Antigua And Barbuda</option> <option value="AR">Argentina</option> <option value="AM">Armenia</option> <option value="AW">Aruba</option> <option value="AU">Australia</option> <option value="AT">Austria</option> <option value="AZ">Azerbaijan</option> <option value="BS">Bahamas</option> <option value="BH">Bahrain</option> <option value="BD">Bangladesh</option> <option value="BB">Barbados</option> <option value="BY">Belarus</option> <option value="BE">Belgium</option> <option value="BZ">Belize</option> <option value="BJ">Benin</option> <option value="BM">Bermuda</option> <option value="BT">Bhutan</option> <option value="BO">Bolivia</option> <option value="BA">Bosnia And Herzegovina</option> <option value="BW">Botswana</option> <option value="BV">Bouvet Island</option> <option value="BR">Brazil</option> <option value="IO">British Indian Ocean Territory</option> <option value="BN">Brunei Darussalam</option> <option value="BG">Bulgaria</option> <option value="BF">Burkina Faso</option> <option value="BI">Burundi</option> <option value="KH">Cambodia</option> <option value="CM">Cameroon</option> <option value="CA">Canada</option> <option value="CV">Cape Verde</option> <option value="KY">Cayman Islands</option> <option value="CF">Central African Republic</option> <option value="TD">Chad</option> <option value="CL">Chile</option> <option value="CN">China</option> <option value="CX">Christmas Island</option> <option value="CC">Cocos (Keeling) Islands</option> <option value="CO">Colombia</option> <option value="KM">Comoros</option> <option value="CG">Congo</option> <option value="CD">Congo, The Democratic Republic Of The</option> <option value="CK">Cook Islands</option> <option value="CR">Costa Rica</option> <option value="CI">Cote D'Ivoire</option> <option value="HR">Croatia</option> <option value="CU">Cuba</option> <option value="CY">Cyprus</option> <option value="CZ">Czech Republic</option> <option value="DK">Denmark</option> <option value="DJ">Djibouti</option> <option value="DM">Dominica</option> <option value="DO">Dominican Republic</option> <option value="EC">Ecuador</option> <option value="EG">Egypt</option> <option value="SV">El Salvador</option> <option value="GQ">Equatorial Guinea</option> <option value="ER">Eritrea</option> <option value="EE">Estonia</option> <option value="ET">Ethiopia</option> <option value="FK">Falkland Islands (Malvinas)</option> <option value="FO">Faroe Islands</option> <option value="FJ">Fiji</option> <option value="FI">Finland</option> <option value="FR">France</option> <option value="GF">French Guiana</option> <option value="PF">French Polynesia</option> <option value="TF">French Southern Territories</option> <option value="GA">Gabon</option> <option value="GM">Gambia</option> <option value="GE">Georgia</option> <option value="DE">Germany</option> <option value="GH">Ghana</option> <option value="GI">Gibraltar</option> <option value="GR">Greece</option> <option value="GL">Greenland</option> <option value="GD">Grenada</option> <option value="GP">Guadeloupe</option> <option value="GU">Guam</option> <option value="GT">Guatemala</option> <option value="Gg">Guernsey</option> <option value="GN">Guinea</option> <option value="GW">Guinea-Bissau</option> <option value="GY">Guyana</option> <option value="HT">Haiti</option> <option value="HM">Heard Island And Mcdonald Islands</option> <option value="VA">Holy See (Vatican City State)</option> <option value="HN">Honduras</option> <option value="HK">Hong Kong</option> <option value="HU">Hungary</option> <option value="IS">Iceland</option> <option value="IN">India</option> <option value="ID">Indonesia</option> <option value="IR">Iran, Islamic Republic Of</option> <option value="IQ">Iraq</option> <option value="IE">Ireland</option> <option value="IM">Isle Of Man</option> <option value="IL">Israel</option> <option value="IT">Italy</option> <option value="JM">Jamaica</option> <option value="JP">Japan</option> <option value="JE">Jersey</option> <option value="JO">Jordan</option> <option value="KZ">Kazakhstan</option> <option value="KE">Kenya</option> <option value="KI">Kiribati</option> <option value="KP">Korea, Democratic People'S Republic Of</option> <option value="KR">Korea, Republic Of</option> <option value="KW">Kuwait</option> <option value="KG">Kyrgyzstan</option> <option value="LA">Lao People'S Democratic Republic</option> <option value="LV">Latvia</option> <option value="LB">Lebanon</option> <option value="LS">Lesotho</option> <option value="LR">Liberia</option> <option value="LY">Libyan Arab Jamahiriya</option> <option value="LI">Liechtenstein</option> <option value="LT">Lithuania</option> <option value="LU">Luxembourg</option> <option value="MO">Macao</option> <option value="MK">Macedonia, The Former Yugoslav Republic Of</option> <option value="MG">Madagascar</option> <option value="MW">Malawi</option> <option value="MY">Malaysia</option> <option value="MV">Maldives</option> <option value="ML">Mali</option> <option value="MT">Malta</option> <option value="MH">Marshall Islands</option> <option value="MQ">Martinique</option> <option value="MR">Mauritania</option> <option value="MU">Mauritius</option> <option value="YT">Mayotte</option> <option value="MX">Mexico</option> <option value="FM">Micronesia, Federated States Of</option> <option value="MD">Moldova, Republic Of</option> <option value="MC">Monaco</option> <option value="MN">Mongolia</option> <option value="MS">Montserrat</option> <option value="MA">Morocco</option> <option value="MZ">Mozambique</option> <option value="MM">Myanmar</option> <option value="NA">Namibia</option> <option value="NR">Nauru</option> <option value="NP">Nepal</option> <option value="NL">Netherlands</option> <option value="AN">Netherlands Antilles</option> <option value="NC">New Caledonia</option> <option value="NZ">New Zealand</option> <option value="NI">Nicaragua</option> <option value="NE">Niger</option> <option value="NG">Nigeria</option> <option value="NU">Niue</option> <option value="NF">Norfolk Island</option> <option value="MP">Northern Mariana Islands</option> <option value="NO">Norway</option> <option value="OM">Oman</option> <option value="PK">Pakistan</option> <option value="PW">Palau</option> <option value="PS">Palestinian Territory, Occupied</option> <option value="PA">Panama</option> <option value="PG">Papua New Guinea</option> <option value="PY">Paraguay</option> <option value="PE">Peru</option> <option value="PH">Philippines</option> <option value="PN">Pitcairn</option> <option value="PL">Poland</option> <option value="PT">Portugal</option> <option value="PR">Puerto Rico</option> <option value="QA">Qatar</option> <option value="RE">Reunion</option> <option value="RO">Romania</option> <option value="RU">Russian Federation</option> <option value="RW">Rwanda</option> <option value="SH">Saint Helena</option> <option value="KN">Saint Kitts And Nevis</option> <option value="LC">Saint Lucia</option> <option value="PM">Saint Pierre And Miquelon</option> <option value="VC">Saint Vincent And The Grenadines</option> <option value="WS">Samoa</option> <option value="SM">San Marino</option> <option value="ST">Sao Tome And Principe</option> <option value="SA">Saudi Arabia</option> <option value="SN">Senegal</option> <option value="CS">Serbia And Montenegro</option> <option value="SC">Seychelles</option> <option value="SL">Sierra Leone</option> <option value="SG">Singapore</option> <option value="SK">Slovakia</option> <option value="SI">Slovenia</option> <option value="SB">Solomon Islands</option> <option value="SO">Somalia</option> <option value="ZA">South Africa</option> <option value="GS">South Georgia And The South Sandwich Islands</option> <option value="ES">Spain</option> <option value="LK">Sri Lanka</option> <option value="SD">Sudan</option> <option value="SR">Suriname</option> <option value="SJ">Svalbard And Jan Mayen</option> <option value="SZ">Swaziland</option> <option value="SE">Sweden</option> <option value="CH">Switzerland</option> <option value="SY">Syrian Arab Republic</option> <option value="TW">Taiwan, Province Of China</option> <option value="TJ">Tajikistan</option> <option value="TZ">Tanzania, United Republic Of</option> <option value="TH">Thailand</option> <option value="TL">Timor-Leste</option> <option value="TG">Togo</option> <option value="TK">Tokelau</option> <option value="TO">Tonga</option> <option value="TT">Trinidad And Tobago</option> <option value="TN">Tunisia</option> <option value="TR">Turkey</option> <option value="TM">Turkmenistan</option> <option value="TC">Turks And Caicos Islands</option> <option value="TV">Tuvalu</option> <option value="UG">Uganda</option> <option value="UA">Ukraine</option> <option value="AE">United Arab Emirates</option> <option value="GB">United Kingdom</option> <option value="US">United States</option> <option value="UM">United States Minor Outlying Islands</option> <option value="UY">Uruguay</option> <option value="UZ">Uzbekistan</option> <option value="VU">Vanuatu</option> <option value="VE">Venezuela</option> <option value="VN">Viet Nam</option> <option value="VG">Virgin Islands, British</option> <option value="VI">Virgin Islands, U.S.</option> <option value="WF">Wallis And Futuna</option> <option value="EH">Western Sahara</option> <option value="YE">Yemen</option> <option value="ZM">Zambia</option> <option value="ZW">Zimbabwe</option> </select> <span class="error">*<?php echo $country1;?></span> <br><br> Website: <input type="text" name="website" value="<?php echo $website;?>"> <span class="error"><?php echo $websiteErr;?></span> <br><br> Gender: <input type="radio" name="gender" <?php if (isset($gender) && $gender=="female") echo "checked";?> value="female">Female <input type="radio" name="gender" <?php if (isset($gender) && $gender=="male") echo "checked";?> value="male">Male <span class="error">* <?php echo $genderErr;?></span> <br><br> Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea> <br><br> <input type="submit" name="submit" value="Submit"> </form> </body> </html> Edited by Ch0cu3r, 15 July 2014 - 03:37 PM. Reformatted post Hello JS experts,
I'm new to JS coding (self-learning) and I have just one (potenitally) simple request to ask of you wonderful folks here.
Oh BTW, I've tried searching through this forum (and the WWW as well) but couldn't seem to easily find something that fits my request, or was easy for me to understand and apply to my situation.
So what I have/want is: a Data-Entry form which (for the first record/entry for a given date) allows the user to select a date from a "Calendar Date Picker". Upon subsequent records/entries (for the same date), the date field should no longer be accessible, but the (previously entered/selected) value should be both displayed (greyed-out) and certainly carried over to the DB/Table.
I know this might be a very simple piece of code, but being that I'm a newbie, I'm not sure how to achieve this.
Would appreciate any and all help to get this done (preferably the necessary code).
If it helps, here's some of my existing code that's related to the field names:
Form field details:
<div class="control-group"> <label class='control-label'>Select Flyer Start Date:</label> <input type="text" name="datepicker" id="datepicker"> </div>DB (table) field details: $flyerDateStart = isset($_POST["datepicker"]) ? $_POST["datepicker"] : "";Thanks much. i have a form for which the data is sent to a process page via jquery like so: Code: [Select] jQuery.post('<?php echo $this->site_root; ?>/modules/new_post_process.php',{ message:jQuery("#message_contents").val() } ,function(data) {etc... new_post_process checks the contents of message like so: if (empty($message) && empty($error)) { $is_error = true; $error = 'Please Enter A Message'; } the problem is that it always throws this message even when the textarea isnt empty. however after the error has appeared if i submit again it goes through fine. I suppressed the error and tried and the database gets populated with an empty value which means it is indeed empty. so why does it work on the second time around? I am using CKEditor for the textarea. everything else gets submitted normally but this textarea. heres the full code: the textarea: Code: [Select] <textarea cols="80" rows="10" id="message_contents"></textarea> Code: [Select] jQuery("#new_post_form").submit(function() { jQuery.post('<?php echo $this->site_root; ?>/modules/new_post_process.php',{ user_name:jQuery("#user_name").val(), redirect_url:jQuery("#redirect_url").val(), subject:jQuery("#subject_field").val(), forum_id:jQuery("#fid").val(), topic_id:jQuery("#tid").val(), method:jQuery("#method").val(), message:jQuery("#message_contents").val() } ,function(data) { if (data == 1) { jQuery("#process_info").removeClass().addClass("subject_okay").html("<img src=\"<?php echo $this->template_path; ?>icons/small_tick.png\" alt=\"icon\" />Redirecting...").fadeIn("slow"); var URL = jQuery("#redirect_url").val(); document.location = URL; } else { jQuery("#reply_btn").css("visibility", "visible"); jQuery("#draft_btn").css("visibility", "visible"); jQuery("#process_info").removeClass().addClass("subject_error").html('<img src="<?php echo $this->template_path; ?>icons/small_error.png" alt="icon" /> ' + data).fadeIn("slow"); } }); and the process page: if (isset($_POST['subject'])) { $message = $_POST['message']; if (empty($message) && empty($error)) { $is_error = true; $error = 'Please Enter A Message'; } if (empty($error) && $is_error == false) { $query = $link->prepare("INSERT INTO ".TBL_PREFIX."posts (p_fid, p_tid, p_poster, p_name, p_content, p_time_posted) VALUES ('$forum_id', '$topic_id', '$user_name', '$subject', '$message', '".$config['time_now']."') ") or die(print_link_error()); echo "1"; } else { echo $error.'-'.$message; } Hi guys, I want my application to run a triggered process based on time to execute some tasks, what is the best approach? Thanks I have a full working order form in PHP. I process it and display it with a process page called "process.php." Whenever this information is displayed on the web page "process.php" I also want it to send me an e-mail with all of the information that it just processed. i.e. Checked checkboxes, text entered, etc. Whenever I try to send the contents of "process.php" to an email $message = include 'process.php'; the process page just goes through an infinite loop displaying itself over and over again instead of sending itself in an email.
Edited by AP_King7, 20 August 2014 - 10:51 AM. hi, is there a way to tell php to do a process again? example: Code: [Select] $draft_number=rand(1, 15); if($draft_number == 5){ START OVER AT TOP } else { $sql1 = "UPDATE names SET draft = '$draft_number' WHERE id = '$uid'"; $result1 = mysql_query($sql1) or die('Error, Check you fields and try again.'); } I have been trying to figure out how this is done? One php file and all that changes is the name of the brand and the logo. This has to be clickable from a menu and also if a user changes the brand name it changes to the appropriate name and logo. Any ideas as to how this is done? If you can guide me in the right direction or give me an example of how this is done would be greatly appreciated. Thanks. http://www.drivermanager.com/en/download-confirmation.php?brand=compaq&logo= I have this code: $shell = new COM('WScript.Shell'); $shell->Run("C:\WINDOWS\system32\cmd.exe /K ".$ini['indexer']['command'], 0, false); When it runs, it opens the command line, but then when it is done, it leaves the process open. How can I close it when the process is complete? Hey guys, I've hit a huge obstacle in my coding process of a script I am writing. It is basically an uploading interface script and it works like this. I have files on my server and I want a user to click a button which fires a php script which in turn fires a bash script which IN TURN fires the uploading program (plowshare). So to make it simple: user logs in, sees upload button. Clicks it, file starts uploading. I then want the user to see "upload initiated" and that's it. The problem is that with what I have now, the script just won't finish loading until the file has been uploaded and as a matter of fact I don't even think it is uploading anything :S Here are the scripts: PHP interface to call the bash script: Code: [Select] <?php error_reporting(E_ALL); function run_in_background($Command, $Priority = 0) { if ($Priority) $PID = shell_exec("nohup nice -n $Priority $Command 2> /dev/null & echo $!"); else $PID = shell_exec("nohup $Command 2> /dev/null & echo $!"); return($PID); } function is_process_running($PID) { exec("ps $PID", $ProcessState); return(count($ProcessState) >= 2); } $file = $_GET['file']; // Location of file relative to the index $where = $_GET['where']; // Absolute index location $absolute = '/var/www/vhosts/animekyun.com/httpdocs/icarus/'; $where = $absolute . $where; //$outfile ='log'; echo $where . $file . '<br>'; echo "<h2>The upload has been initiated!</h2>"; $ps = run_in_background("/bin/sh uploadparser.sh $file $where > $outfile"); while(is_process_running($ps)) //echo $output; ?> Bash script to call uploading program: Code: [Select] #!/bin/sh { FILE=$1 WHERE=$2 FILENAME="/var/www/vhosts/animekyun.com/httpdocs/icarus/debug/debug_mu_$FILE" FILENAME2="/var/www/vhosts/animekyun.com/httpdocs/icarus/debug/debug_multi_$FILE" /usr/local/bin/plowup megaupload "$WHERE$FILE" >> "$FILENAME".txt 2>&1 /usr/local/bin/plowup multiupload "$WHERE$FILE" >> "$FILENAME2".txt 2>&1 } & this works fine when I pass the variables as arguments in CLI I hope i have been clear enough, it does seem rather confusing This may spill over into java, just not quite sure yet! Basically what I am trying to do, is fill a box with text, click a button which runs a function which send the text in the box via a JSON request to an external server. The JSON works fine, I just want a way of submitting the string which hopefully doesnt involve a form, but its the only way I can think of! Any other ideas? I have this 3 tables
users (id_user)
music_styles (id_style, style) ex. (1) - (Blues)
user_styles (id_user, id_style)
I'm trying to create a form in which the user ($user = $_SESSION['id_user']) chooses through a multiple select the styles of preference to store them in the database using mysqli statements.
If the styles prefered are selected they should be displayed in the select input later, how can i accomplish this?
Thanks.
Hey guys my code is like this Code: [Select] <?php if( $_POST["name"] || $_POST["age"] ) { echo "Welcome ". $_POST['name']. "<br />"; echo "You are ". $_POST['age']. " years old."; exit(); } ?> <html> <body> <form action="<?php $_PHP_SELF ?>" method="POST"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> The Inputs are taken from form.How do I make it display somewhere at the bottom of the form in the same page.The Output of this code comes up in a new page. Hi Im doing a login for a website I've built and Im having troubles, The connection to the actual database works fine, no errors, but when trying to verify data in the database to log on and get to a secure area i just get the incorrect username or password that i created for when details are incorrect. heres the code where the problem lies Any help would be appreciated <?php session_start(); require("db_connect.php"); $username = $_POST['uname']; $password = $_POST['pword']; $sql = "SELECT * FROM login_details WHERE username='$username' AND password='$password'"; $results = mysql_query($sql, $connect); $numofrows = mysql_num_rows($results); if ($numofrows == 1) { $_SESSION['username'] = $row['username']; $_SESSION['loggedin'] = true; header ("Location: secure_page.php"); die(); } else { $_SESSION['error']= "Icorrect Username Or Password"; header("Location: login.php"); die(); } ?> |