Jump to content

WesleyA

Members
  • Posts

    172
  • Joined

  • Last visited

Everything posted by WesleyA

  1. I think using <SELECT> is a better option. <SELECT> gives the opportunity to choose only 1 option and obliges a choice.
  2. Im looking for a solution to direct the visitor to a page so they can have a message that the checkbox should be checked. Submit action offers the possibility to direct someone to one page. (or am i wrong?) The idea is that the decision whether the checkbox is checked has to be made in advance. If checked it shoud go on using the submit action (if this is the only solution ???) It works like this: the user gets a list of several choices (taken from a list of mysql database tables) and they have to check. Only 1 is allowed to be chosen. You have to choose one (not 2 or 5 but 1) else the parser gives an error and/or nothing will be added to the database. If the checkbox is chosen the user can add records to the table. What I want is actually free and is also a matter of possibilties there are with HTML/PHP (not javascript). So they can be sent to an error_page and the completed page was one option. Maybe its also an option to have it echoed on the same page but it depends on what is possible and how that is done. What is the difference in approach between these 2 different pieces of script?
  3. But include makes that the page content is showed on the same page.
  4. Yeah my idea is that 2 pages are a good solution. I tried to add the code with include but it doesnt open the pages in a new window or new tab which I would rather have. ( I heard of COBOL as a very old programming language as I'm born in the sixties and COBOL is from that period or so, but now I program PHP, as far as I know I only use the most common library of instructions. I now have WAMP installed I dont use tools or API's, dialect etc. at the moment.)
  5. And what should be done with the action attribute in the form element which directs the the data to a new page?
  6. Can someone give an example of a php script that lets a form with checkbox input choose between 2 different pages when it is checked or not. Actually the dilemma is that the action attribute is sending form data to another pages (2 pages) - but dont know what code to use - . So if the checkbox isnt checked a third page should load in the browser.
  7. Hi all, Im pretty much a noob to javascript. I try to get how the statements work together. if you have a javascript command like this: document.all.myFile.innerText Then document is an object and so is all myFIle is a variable but what is innerText ? Is that a property or a method? Are there any obligations in writing these commands? like this: object.subobject.property.method? Or are you free to use these through each other?
  8. But do you think it is possible to check with php or maybe just with html; if a html form gets the right input ?
  9. What is the best way to delete empty input fields, should I use php or javascript or another language? In the script the user can fill 3 or 5 input fields in the browser by html. The data will be stored in the database. But empty fields shouldnt be stored. Finally I also want to stop other crappy input, like mistakes etc. Im not sure which language is used for this matter. Is it possible to use php or is javascript better? My first focus is deleting empty input fields.
  10. No! forget the word fault. It has to do with wanting to understand how PHP works. But back to the issue: how should I instruct PHP how to process the data that I have retrieved once for echoing, for the second time in an SQL command?
  11. Yeah But do I have to set it twice then? As I told before. The form input is another script. First I use this form input and make the user choose the table. Now I want the choice the user made first printed on the screen. Then this choice should be used in the SQL code. But on the new screen the user can also choose five values. Here it stucks, when I use an if condition. It is the same if condition as when I echo it on the screen. But embedded or wrapped around the existing if condition concerning SQL code for adding the values to the table seems to demand another if condition. I don't understand for what reason PHP works this way?
  12. Now I got an errormessage saying Undefined index: forminput $tab = $_POST['forminput'] when is this error given? Can I use it only once? (as i used it before wih succes)
  13. I think the mistake is that the $tab is empty when I embed in in a condition. I can check that with var_dump or echo. I was not 100% certain about that but it might be. So I asked this question what the errorcode could be if $tab would be empty in the php/mysql query I posted.
  14. To read data from an input field yoiu use post (method post) and it can be used to put it on screen in the browser with ech or with var_dump. Using this variable again and using PHP to instruct MYSQL in this way $sql = "INSERT INTO $tab (var1, var2) VALUES ('$var4', '$var3')" ; doesnt seem to work. Is it necessary to use other PHP commands to put a variable like $tab into a MYSQl query?
  15. 1) I want to know it. It is for my script. The users are allowed to make a table 2) I asked that to find out if there could be an error report IF $tab was empty.
  16. What exactly do you mean with specified? If I place var_dump($tab); outside the condition then it is printed. So after the first or second echo "test"; in the part of the script I uploaded here. Does that mean it is specified? Or is that done in another way?
  17. My problem is not in the first part of the code. This code worked. I guess it wont change when I embed another if statement.
  18. But one way or another is the code after { not executed. The echo between the { } also not. What other options are there for if ?
  19. Maybe at the moment the form fields are distracting from the core of our problem. The problem is that I cant get this part fixed. $tab = $_POST['kolom2']; var_dump($tab); // dump gives null both isset as !isset. But maybe I'm thinking wrong. If I get the data from the form field which I am able to put on screen in an earlier part of the script then have set them or not? Or are these data only available once? I would like to know how to use data from any form inputs throughout the whole script (or even other php files). My problem is that if I use isset the variable is not set so the code after the { is not executed. So I use !isset, then it is executed, but then unfortuantely the variable is not set. here is a greater part of the script: If (isset($_POST['linkoms']) && (is_array($_POST['linkoms'])) && ($linkoms = " ") && isset($_POST['linkadd']) && (is_array($_POST['linkadd'])) && ($linkadd = " ") ) { echo "test"; // is echoed if ($_SERVER['REQUEST_METHOD'] == 'POST') { echo "test"; // is echoed if (!isset($_POST['kolom2']) && !isset($tab) ) { echo "test"; // not echoed at isset, is echoed at !isset $tab = $_POST['kolom2']; var_dump($tab); // dump gives null both isset as !isset. foreach($_POST['linkoms'] as $key => $dummy) { $oms = $conn->real_escape_string($_POST['linkoms'][$key]); $add = $conn->real_escape_string($_POST['linkadd'][$key]); $sql = "INSERT INTO $tab (linkoms, linkadd) VALUES ('$oms', '$add')" ; // the error is because $tab doesnt have a value So I was thinking maybe I overlook how a variable is set. Could you explain more about that?
  20. No I'm not sending data from one form in another form. I have two different form fields The first is to determine the table variable (for a mysql query). The second separate file is reading the values (also for the same mysql query) in a loop. But my problem is that I can not use the same if/!isset condition twice. The first works, the second with the same code doesnt work.
  21. The scripts I wrote have 2 form fields. It are 2 different php files. The first form fields gets data from the database and lets the user choose from a checkbox form. The choice is transferred to the second script. I'm able to print it there on screen. Now in the second file a new form file is offered. After that I have a second form field to put data in the database with mysql. Here I use if ($_SERVER['REQUEST_METHOD'] == 'POST') and then I check with if isset all the values. ( I actually dont want to echo the checkbox choice on screen at all, I want this choice in an mysql query). So I have for this one request method 'Post' actually data from two different form fields. Is it possible to do that with PHP? Or should another script language be used? Because I F# dont understand why an if isset works in the second file to grab the data from the first checkbox form field, but not a second time in exactly the same way. Why sould I use another if /isset while its the same?
  22. I made query with a variable $sql = "INSERT INTO $tab (var1, var2) VALUES ('$var4', '$var3')" ; Is it true that if $tab doesnt have a value, the error code mentioned above is given?
  23. I get an error code You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near I found this is error 1149 ? is that right? I'm looking for the meaning of this error. What is the reason I'm having this? Does it mean the mysq code in my php script is wrong? Is a solution changing the MYSQL line or can the error also be made in the php part of the script?
  24. This code doesnt work for instance $sql = "INSERT INTO " . $col . " (vara, varb) VALUES (`$varc`, `$vard`)" ;
×
×
  • Create New...