Re-populating A Form If Errors
I am learning php. I have created a simple Web page with a form.
After receing the POST request, I do some error checking. In case of
errors, I would like to re-post the page, but with the current values
for each field.
I have organized my files like this:
1) Webpage with the form (all in html, form action points to a php
file)
2) php file that receives the request.
View Complete Forum Thread with Replies
Related Forum Messages:
Populating Form Text Box.
I have a PHP form for entering data on-line into a mySQL table.. Because of the intended search facility, I require one field in the form to be completed with exact and precise item names and spelling. In testing, I had achieved this with look-up tables. Ideally I would like the selected item from one of five drop-down lists to autopopulate the form text field when selected. Alternatively at least the option of copy and paste. Copy and paste - for some reason will not work. Autofill worked fine on a test form with no database connection and in standard HTML and javascript, however, once the PHP is added to the page neither method works. Could anyone please point me in the direction of how to get the autofill to work?
View Replies !
Populating Form Fields
I have a online order form that does not require a user to be logged in to use, but if the user is logged in I am attempting to get certain fields to populate with information stored in the database for the user. If the user is not logged in I need the information to be sent to the database.
View Replies !
Populating Form Item From SQL Enum Set Rev#2
$sql = "SHOW COLUMNS FROM table LIKE 'subject' "; $qry = mysql_query($sql) or die("Query not valid: " . mysql_error()); $res = mysql_fetch_object($qry); // This returns a row with a field 'Type' containing 'enum(...)' $res->Type = str_replace('enum('', '', $res->Type); $res->Type = str_replace('')', '', $res->Type); //now the string is something like this: one','two','three $temp = explode('','',$res->Type); //temp is an array with as much elements as the enum while ($temp) print array_pop($temp); This way is much more easier using the elements since they are elements of an array. Cleaver isn't it?
View Replies !
Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database: $connection=mysql_connec ("localhost", "f2821842", "f2821842"); $result=mysql_select_db("QUERIES"); $query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'"); while($row=mysql_fetch_array($query)) {$empname=$row['emp_name'];} <form name="webregform" action="webadmin2.php" method="post"> <input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>"> </form> When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?
View Replies !
Populating Form Fields With Variables
The script itself works fine: mail gets sent. If there are any missing fields the form displays again with a list of the missing fields, but I can't get the form fields of the reloaded form to be populated with teh existing values. PHP Code:
View Replies !
Auto Populating Form Fields
I know this isn't a PHP thing. But, I've been unsuccessfully looking for how to populate form fields with data found in other fields. For example, I would like to populate shipping information with the billing information - if they are the same. This would save the time from entering the same address twice. Does anyone know of a javascript site that is decent at these options?
View Replies !
Conditionally Populating Form Menus
I wondered if I could ask another question: I have a form which will allow me to populate a garments table within my database. Among the elements in the form, there is a suppliers drop down menu and a categories multiple select menu. I used the following code to populate these menus. Code:
View Replies !
PHP Not Populating Form Variables Passed Through POST Or GET
I"m running: Windows Xp SP2 Apache2 PHP5 MySQL4 Everything seems fine and dandy, and I can do scripting on server side, but for some reason I cannot get data from a form to be put into a variable. I have a simple form in an html page which submits, and in the php script that handles the input, none of the data in the form is going into the variables. My php.ini file does have all the GPC's in place(ie variable_order, the way they get processed).
View Replies !
Populating An Html Form With Mysql Data.
What I have is a basic html form I have made consisting of header fields and fileds that will be populated from a mysql database. The brackets are the actual db fields and denote where I want the data to populate. Here is a small example of the form. Code:
View Replies !
Populating Form From Database, Then Passing Results To Next Page
I have a multiple select input in a form that's being populated by a row from my database as such: <input type="checkbox" name="subm[]" value="$row[ID]"> That part is working fine as I can check the displayed page using View Source and see that the value is the correct row number from the database. It is then being submitted on a form by $_POST method to another page where I want to evaluate the checkboxes and display the contents of the entire row that corresponds to each value="$row[ID]" that have been checked. But I can't seem to get it to work. I'm having a problem passing the selected value. Can someone point me in the right direction? $query = ("SELECT * FROM `table`"); $result = mysql_query($query); print "<p>Data for Selections:"; print "<table border=2><tr><th>You chose:"; foreach ($_POST['subm'] as $value) { print "<tr><td>"; print "$row[ID]; "; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print "</td></tr>"; print "</table> "; } if (!isset($_POST['subm'])){ print "<p>No matching entry "; } mysql_close();
View Replies !
Populating SELECT Multiple Form Field And Inserting Into Db
I have an update form where I'm trying to populate a SELECT multiple field with a list of 48 categories, from tbl work_cat. And show, as SELECTED, the one or many choices that the user had previously selected from the 48 categories which are stored in tbl cat_relations as $relation_cat. Then allow the user to update their selections and update the database. But I can't get my form to work. First problem, I can't get the SELECT field on the form to show the categories, and then I don't know where to go from there. Below are my form page and my processing page. Code:
View Replies !
PHP Form Submission Data Errors
One of my variables "link1" that is storing a bunch of urls is having random lines being duplicated on form submission. I just recently swithed servers from a PHP 4.3.3 to a 4.2.2 version. This error has only started appearing on the new machine. The script worked fine on the old server and still does on the test server. Any ideas? I think it might have to do with the ini config. i am stumped. here is a link to my code.
View Replies !
Contact Form - Get Too Many Parse Errors All Over
I'm struggling with this email code and I'm not php freak since I'm starting to learn php stuff. Could use some help... It seems that I get too many parse errors all over and cannot figure went wrong since most of these appears right to me... <?PHP $to = "scoobyood@jace41.com" ; $name = $_POST['name'] ; $email = $_POST['email'] ; $subject = $_POST['subject'] ; $message = $_POST['message'] ; //validate contact fields if (!strstr(trim($_POST['email']),"@")) { $email_error = "<p class='comment'>please enter your email address!</p><br>"; $contact = "no"; } if ($_POST['name'] == "") { $name_error = "<p class='comment'>name field is blank!</p><br>"; $contact = "no"; } if ($_POST['email'] == "") { $email_error = "<p class='comment'>email field is blank!</p><br>"; $contact = "no"; } if ($_POST['subject'] == "") { $subject_error = "<p class='comment'>subject field is blank!</p><br>"; $contact = "no"; } if ($_POST['message'] == "") { $message_error = "<p class='comment'>message field is blank</p><br>"; $contact = "no"; } if ($contact != "no") { //if pass, then submit email and redirect to thankyou page mail($to, $subject, $message, "From: $name <$email>"); { header("Location: contactsent.html"); exit(); } ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="css/jace2.css" rel="stylesheet" type="text/css" /> </head> <body> <p class="topic">Unable to send your message!</p><br> <?PHP //list error(s) else if $send == "no"); { echo "$name_error"; echo "$email_error"; echo "$subject_error"; echo "$message_error"; } ?>
View Replies !
Form Which Uploads A File Have Errors
I have a form which uploads a file, it refreshes the page, uploads the file and then alerts the user to if the file has uploaded. To be honest im not sure why i keep getting the error. But here is the code:
View Replies !
Thoughts On The Best Way Of Highlighting Form Input Errors?
I've been creating an application over the last few weeks and generally pleased with what I have produced but one area is irritating me, form validation. At the moment the forms are simply static html templates and the form input is checked using a validation class. Basically each form field is checked, every error is stored to an array and at the end of checking of the complete form, the array is output neatly at the top of the form. However this is just not sexy enough for me, what I would like to happen is for the input boxes with errors to be highlighted with a red border (or something along those lines). I would also like to have the error messages under the box which the error occured, not altogether at the top of the page. So I am currently wondering how to achieve this and what choices are open to me on methods available? I've had a google around the web and found some form validation classes but they basically do what I already achieved. I've thought of creating the forms dynamically but that in itself doesn't address how to achieve my goal. I am sure many people have already successfully done this, if you have the please could give me an outline (the theory) of how you did it. I don't want or need code, I am simply stuck at the moment on how to approach this.
View Replies !
Contact Form - Errors Saying 'others Can Write File'
Here's what I'm looking for; echo here Name * (validate) Email Address * (validate) Subject Message Submit I'd like "(*) is a required field" or "Your email has been sent" to echo above "Name" on the same page (like above). When the email is sent, I'd like it to display users Email and Subject (not Nobody and blank Subject), then in the body the Name & Message. PHP would be nice, since it hides the Email. I have Perl, but not used to that as I tried a script and I get errors saying 'others can write file' and 'can not execute' on the .pl file. Here's some info on the server; Apache 1.3.37 (unix) PHP 4.4.4 Perl 5.8.7 MySQL 4.1.21-standard
View Replies !
Populating Form In Parent Window With Value From Popup Window
I have a text box in the parent window.. now i want to populate this text box with a user_id that i will get from query within a popup window.. How do i get the value from the popup window to be passed to the main window form field in php. I know how it can be done in javascript but when i tried combining javascript and php i dont get the desired result.
View Replies !
Errors To Appear On The Same Page As The Form Where The User Puts In The Data
I want my errors to appear on the same page as the form where the user puts in the data, and I want "non-error" results generated to appear on a different page. Right now, both the errors and any actual results appear on the new page, requiring the user to use the "Back" button when an error is made in order to re-enter the values on the form. I want the errors to appear on the same page as the actual form. On the page where the user enters stuff into the form, I've got: <FORM method="POST" action="res_search.php"> which is the page that the results and the error messages are being shown. Is there any way I can jig that second page so's the error messages show on the originating page instead.
View Replies !
Supress Errors At The Page Level? Undefined Index Errors.
I'm creating a simple reply form, and if a form item isn't answered I get an error: "Notice: Undefined index: rb_amntspent in c:inetpubwwwrootmackinawsurvey.php on line 36" even if in the code I allow for an unselected item. (Code at the bottom here.) It works fine otherwise. Now in the past I've made a change to php.ini to repress errors, but for this project I don't have access to the php.ini. Is there a way to supress errors on that page for that session? Or, is there a way to just not get that error at all? Here's a sample of the code that gets the form response. If an item is selected, no error for that question, but if an item is not selected I get the error above even though I still get a successful echo for the "else" or "default" option which occurs if nothing is selected: $rb_visited = $_POST["rb_visited"]; //Have you ever visited Mackinaw City, Michigan? if ($rb_visited == "1") { $rb_visited_reply = "Yes"; } elseif ($rb_visited == "0") { $rb_visited_reply = "No"; } else { $rb_visited_reply = "You did not answer this question"; }; $rb_lastvisit = $_POST["rb_lastvisit"]; //When was your last visit to Mackinaw ity? switch ($rb_lastvisit) { case "1": $rb_lastvisit_reply = "Earlier this year (2003)"; break; case "2": $rb_lastvisit_reply = "Last year (2002)"; break; case "3": $rb_lastvisit_reply = "2 years ago (2001)"; break; case "4": $rb_lastvisit_reply = "3 years ago (2000)"; break; case "5": $rb_lastvisit_reply = "4 or more years ago (1999)"; break; default: $rb_lastvisit_reply = "You did not answer this uestion"; }
View Replies !
Populating A Select Box
What I want to do for members of my website is to allow them to click a button that will add their name to a list that populates a select box. I can do this on my own, but I was curious if I have to use a database in order for this to be possible.
View Replies !
Populating Drop Down
How do I do this drop down box ? Making an edit page. I have 2 tables groups id || categoryname program id || cateogry_id I need to populate the groups in it at same time show the selected choice from program. Not showing id but needs to show categoryname with of course the values being the id of groups.
View Replies !
Populating Dropdown Box.
I have been looking around the internet for an example of what I need to do but cant find anything was wondering if someone here might be able to help. What I need to do is to connect to a mysql db select a table and then a field from that table and put all the contents of that field into a dropdown box.
View Replies !
Populating A Webpage
I am trying to create a webpage that will allow me to view my 'email' website whilst I'm at work. The firewall blocks the page and I was hoping that there was some surreptitious way to get around this problem. My thoughts for a solution to this would be to create a variable with the website's name in pieces. Then send it to a function that opens it in a frame or something.
View Replies !
Populating Tables
I'm trying to populate an HTML table using the data in MySQL. "how to do format it to where I can make shipping labels?" There will be three lines of text for each label but I will have three columns of labels X 10 rows. Code: line A1 line B1 line C1 line A2 line B2 line C2 line A3 line B3 line C3 line D1 line E1 line F1 line D2 line E2 line F2 line D3 line E3 line F3 ....
View Replies !
Populating Two Combo Boxes
I have one combo box (Category) which is populated by a MySQL table using php. I am trying to use the onchange javascript to submit the value selected so that I can populate the other combo box (sub-category) based on what was previously choosen. So can anybody give me a clue on how to submit the first boxes value so that the second can see what was selected (javascript function).
View Replies !
Populating Dropdown List
I am wanting to know how to populate the <SELECT> dropdown menu with all existing values from the DB and also have the value associated with that id selected. This is an updating area of my admin. Any ideas? Here's the code so far. At the moment it only retrieves the value assigned to that id. PHP Code:
View Replies !
Populating A Drop Down Menu
How would I go about populating a Drop Down menu from data in MySQL? If you can show me wither a URL to learn this, or if you feel like telling me here, that would be great.
View Replies !
Dymanic Populating Checkboxes
i like to retrieve a value from DB, accordingly i like to display the checkbox, either checked or not. Now im able to retrieve the value from DB, i can show even show the checkbox, but i cant make it checked???? the Code i used to display as follows, #Require the database class require_once('../dbinfoinc.php'); #Get an array containing the resulting record $query = "SELECT * FROM event"; $result = mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { if(($i % 2) == 0) { $c = '"TableDetail"' } else { $c = '"TableDetail2"' } $event_id=mysql_result($result,$i,"event_id"); $event_name=mysql_result($result,$i,"event_name"); $event_publish=mysql_result($result,$i,"publish"); // if(($event_publish) == 0) { $event_publish = 'No' } // else { $event_publish = 'YES' } $take_action = 'Delete' echo "<tr> <td Class='navText' align='center' class=$c>$event_id</td> <td class='navText' class=$c>$event_name</td> <td class='navText' align='center' class=$c><input type='checkbox' name='publish' if($event_publish==1){'CHECKED'}?></td> <td class='navText' align='center' class=$c><a href='delete_event.php?event_id=$event_id'>$take_action</a></td></tr>"; $i++; } ?>
View Replies !
Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it. The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like: Green Red Blue Green Black How can I make it so that Green only shows up once?
View Replies !
Populating Drop Down And Table
I have a database with the following fields. Name | Company | Date values in each column could be repeated, or not. as in there could be several same names with the same company with different dates, or different names with same company. How do I populate a table with this info and have drop down boxes, so that I can narrow down the search? For example: Name | Company | Date 12 | 1 | 1929 13 | 1 | 1929 14 | 1 | 1929 12 | 2 | 1929 12 | 4 | 1929 13 | 1 | 1941 12 | 6 | 1929 So if in the drop down I select '12' under name, only those entries with 12 are shown, and then I can further sort it by selecting only '1' under Company. Hope I'm clear, I manage to complicate things when I post them.
View Replies !
Populating An Auto_increament Attribute
I have just designed a BD. there are companies with auto increament which are integer. When I try to populate it after i tool value from another form and try to insert it into a table i recieve an error! I don't ask the companyID value from user as it is auto increament. Don't tell me to put NULL for that entry as it didn't work as well! Code:
View Replies !
Auto Populating A Drop Down Box
Basically I'm setting up a website which needs an populated drop down box made up from all fields in a specific column of a table in a mysql db.... Here's the code I've made up using various tutorials.... <?php $user = ""; $host = "" $password = "" $dbName = "" /* make connection to database */ mysql_connect($host, $user, $password) OR DIE( "Unable to connect to database"); mysql_select_db($dbName); //did you forget this line? $sql = "SELECT model FROM usedVehicles"; $query = mysql_query($sql) or die(mysql_error() . "<br>$sql"); //use the or die(...) part ONLY IN DEVELOPMENT ?> <form action="action" method="post"> <select name="option"> <?php while ($row = mysql_fetch_array($result)) { echo "<option value="" . $row['model'] . "">" . $row['model'] . "</option> "; } ?> </select> <input type="submit"> </form> I've left out the connection details for obvious reasons... When I upload and try to test this, jus a blank drop down appears... there are definately fields in the column as I have tried the query on phpMyAdmin.
View Replies !
Populating Fresh Data
Im building a live web chat using php, mysql, javascript, ajax I am fine with sending and retreiving data in real time using ajax as the transfer protocol However, my problem, which is becoming a nightmare, is how to I display it !! Lets say the below is the chat screen, <div id="messages"> Jamie - Hello Peter = Hi Jamie = Nice Day Peter = I know </div> Lets say Jamie's next message is "What are you doing today". I can send that off to the database no problem and I can get peters live chat to pull that message in, however, how do I get it to display underneath Peter = I know As a practice I was using document.getelementbyid('messages').innerHTML = document.getelementbyid('messages').innerHTML + "<BR>What are you doing today" That works, but, lets just say the chat gets to 1000 lines, for each new message those 1000 lines have to be pulled out via javascript, a new line written to it and then printed back in the div Im not sure but I'd take a good guess at this not being optimal and will cause CPU load on the users machine What is the best way to do this! Chat messages are deleted after 1 minute, but that doesnt matter because by then they have already been sent the the users chat. Just incase you are thinking of completely repopulating there chat with every message they have sent since the chat started..
View Replies !
Populating A Dropdown From A Database
I have put together a script that populates a dropdown menu from a database. My database contains a table called casinocredit, and it contains records that have been enterend over 2 different months (may and june). There is a field in the database that contains the date in this format: 2006-05-12 00:00:00 So The drop down is currently showing a month for each of those records. I was hoping that it would only display one. (the plan is when a user selects a month (say May) and hits submit, then I would display all of Mays records on a different page) See the image i have attached for a view of what is happening. Code:
View Replies !
Populating A Drop Down List With Php
I am trying to get a drop down list to populate vbia php. What I have a is a script that allows a airline/user to enter airfare and price for tickets. It dumps them into a database and then allows the user to view/delete/add. I want the user to be able to edit the airfare. I have a drop down list that is set as a variable $ticket_from, $ticket_to. The list contains around 400 cities. When the user clicks 'edit' I have the price population but no the drop down list. How do you go about something like that? I have this right now: Code:
View Replies !
Populating Drop Down Lists
Could anyone help me on populating database driven drop down menus. I am trying to populate a second drop down list based on the selection of the first drop down list. I have the first drop down list running. Not sure about getting the second now.
View Replies !
Populating Combo Box Dynamically
when I click on a Country name in the first combo box the name should be checked on the database and the name of the respective states. should be populated in the next combo box dynamically. please give us the basic code and the way to go ahead to develop the code. We are new to PHP ,we have read the basics but how to develop now?
View Replies !
Re-populating Text Fields
When a user submits a form on my page and there are errors, the page returns the errors and re-populates the correct fields - So the user doesnt have to complete them again. I using the below code to do that... <input style="width:200px; "Â name="userfile" type="file"Â id="menu_textbox" value="<?print $file_path; ?>" /> However, for the file upload field above it doesnt seem to work and the user must select the file they wish to upload from there computer again. Should the code for this be a little different or is there something I am missing?
View Replies !
Populating Drop Down From A Query
I'm trying to populate a drop-down box from the results of a query. I end up with the first option coming through and then blanks in the rest. Something like this... <option value=Acevedo>Acevedo</option> <option value=></option> <option value=></option> <option value=></option> <option value=></option> .......
View Replies !
Self Populating Drop Down Menus
i am trying to do is the following: I have a MySQL database that (very simplified) has a schema like this 'Students(Name, id, Course)' I would like to have a form on a web site that has 2 linked drop down menus, one 'Please select id' and one 'Please select course'. When a user of the site selects there Id from the first drop down menu, i want the second drop down menu to populate itself with the courses held in the database for the given users Id. I would like the first drop down menu to be populated from the database with a query similar to 'SELECT id FROM students'.
View Replies !
Populating Dropdown Menu From Db
Okay, I am trying to populate a drop down menu with items from a table in my db. I have a table called "teacher" which has the following info: I use the following code to grab the info from the teacher table. Code:
View Replies !
Populating Select Boxes
I'm creating a data entry system using php/mysql that includes the standard add/update/delete forms in PHP with a MySQL backend. On the update pages I'm trying to fill the select boxes (that come from other tables) with the values in those other tables, yet defaulting the selection in each of those select boxes to the value currently stored in the main table which is being updated. For example, the main table is called 'dates' and a related table is called 'department'. So one of the select boxes should have all the various departments listed in the select box but the currently selected value should be whatever is in the department field in the 'dates' table for the record the user is trying to update. Code:
View Replies !
Populating Drop Down From MySQL
I am trying to populate a drop down menu of MySQL data using PHP and I have hit a snag. I think its probably something simple that a freah pair of eyes could pick out right away that I am just not seeing... For some reason only the "firstname" part of the data is populating in the drop down and I can't figure out why. When I try to make changes to the echo lines to correct this, nothing shows up including the "firstname" data. Code:
View Replies !
Populating Drop Down Menu
I use the following code snippet to build a drop down menu with the results of a query. How can I set the initial value of this input based on the result of another query? What I am trying to do is update records in the data base. The field WkEndDate is pulled along with the rest of the record and the drop down menu is built from a table of valid WkEndDate values. Code:
View Replies !
Populating <options> Tag With SQL Data?
I have a problem that I cannot seem to figure out. If any of you have an answer or suggestion, I would appreciate it. My HTML/PHP code needs to pull options from a database to populate the <optionstag for a drop down menu and I cannot get it to work. Basically, there is a form on the website with a drop down box. I need the options in this box to be pulled from a preexisting table in a database. That's all. Sounds very simple but I'm totally lost on how to accomplish it.
View Replies !
|