PHP - Oop: Html Forms?
Is it worthwhile to create an object to generate my HTML forms?
Starting out it would appear to be worthwhile but I'm not sure how things might change later down the line when I'm doing more with my forms and introducing javascript to it. It's a bunch of coding to change all my forms now so I wanted to hear some input before I started. Would this be just a complete waste of server side processing? TIA! Similar TutorialsHi, I am very new to PHP and am having trouble understanding how HTML, PHP and JavaScript work together. What I have to do is, I have a 'Choose File' option, where I select the file. Then I transfer this file to server and read the contents in an array. This is done in one form. In the other form I send the contents read from the to a different *.php for some database querying. Following is what I have. I don't know how to transfer data between different files. Code: [Select] <form name ="INPUT" method="POST" enctype="multipart/form-data" action="readInput.php"> <p id="upload_text"><br/> <textarea name="queryList" id="queryList" cols="35" rows="10" wrap="physical" value='' onclick ="document.INPUT.queryList.value='';"> Enter input here... </textarea><br/> </p> <p> <!-- <input name=INPUTS type=hidden value=$entries[]/>--> </p> <p id="upload_button"><br/> File: <input name="uploadedfile" type="file" size="30" onchange='fillTextArea(<?php echo $entries; ?>)'/><br/> </p> <iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe> <a href="javascript: submitReadForm()"></a> </form> <script type="text/javascript"> function submitReadForm() { document.INPUT.submit(); } </script> <script language="javascript" type="text/javascript"> //var inData = new Array(); function fillTextArea(inData){ if (inData == "") { document.getElementById('queryList').textContent = "No Input" alert("No Input Data Returned"); } else { document.getElementById('queryList').textContent = inData; } } </script> <form name ="GETPDB" action ="viewPDBs.php" method="POST" enctype="multipart/form-data" > <p id="submit_upload"> <input type="submit" name="submit" value="Submit" /><br/> </p> <p> <!-- #<#?php echo $entries; ?> #<#php foreach ($entries as $k => $e) : ?> <input type="hidden" name="entries[<#?php echo $k ?>]" value="<#?php echo addslashes($e) ?>"> #<#?php endforeach; ?> --> <input name=IDS type=hidden value="<?php echo $input; ?>"/> </p> <a href="javascript: submitPDBForm()"></a> </form> Please help me with this. Thanks. Hi, I have found myself in a bit of a cul-de-sac. Hope you can help as it is driving me crazy. The scenario: I have an html form (_post) which I would like to write the contents of to a one XML file using php. The problem is: The html page has three/four forms in it. Form a = (submit a writes/updates only to section a) Form b = (submit b writes/updates only to section b) Form c = (submit c writes/updates only to section c) Form d= (submit a, b, c writes/updates all sections) The XML page has three sections a, b & c To conclude, I want to be able to update the XML file in sections or update them all as a whole. How can I go about achieving this? Thanks Hi I am having a major problem with trying to get the HTML value attribute to display the a value stored in a array from SQL Query. So i have done an SQL query then outputted it all to the screen, but i cant set the value attribute on my HTML form to the variable $Name. Can anyone please tell me where i am going wrong? Thanks Nick while($nt=mysql_fetch_array($result)){ echo "$nt[photo_url] $nt[Name] $nt[Education] $nt[Skills] $nt[Aboutme] <br>"; // name class and mark will be printed with one line break at the end } $Photo_url = $_POST["photo_url"]; $Name = $_POST["Name"]; $Education = $_POST["Education"]; $Skills= $_POST["Skills"]; $Aboutme = $_POST["Aboutme"]; ?> <form method="post" action="updateaboutme.php"> Photo Url:<input type="text" size="12" maxlength="12" name="Photo_url" value="<?php echo $nt['Name'] ?>" <br /> <input type="submit" value="submit" name="submit"> </form> Hi There, Is there any way that when a user submits a form, but places a link inside - for example: It is located at this location: http://mylink.com Is there any way that PHP can pick up the fact that there is a link there and tag it correctly so it is clickable? Cheers Matt Hello friends, if i've textarea form or even input how to prevent visitors to write html codes inside it ? thanks I make a php application , it has a lot of forms. I want to avoid someones post like ?> or </html> . How can i make it. Here's a question for all you great php programmers. What I want to do is use a variable username as the name of a select input of a form. I.E echo"<select name='$user'>"; Of course this code doesn't work though I feel sure that there must be a way to do this. Anyone know it? I've been poking around online for about a day now trying to find a good way to do the following: I have an "order" I'm reading in from a MySQL database (not completely relevant, but just fyi). And, for this order there are a number of "parts" (automotive parts) that have been ordered. For each part there is data pertaining to the quantity of parts that have been ordered and the number of parts that have been allocated (based on our inventory) and then a third column that has the number of parts still in that order that are still to be allocated at a future date. Basically, I'm displaying this data in a form with each row having a checkbox to the far left. What I want to do is allow the user to check any number of check boxes. If a check box is checked the form should submit all of the input text boxes for that row (the user can update the quantities) that I talked about in the second paragraph for that "part" (each part is displayed in a row and has a checkbox). Unfortunately, most of the examples I found for checkboxes in a form submit a specific value (like a number of a letter). I need the form to submit the values that are in the textboxes. So basically, I'm thinking I need the page to update a PHP object whenever the value of a textbox is changed and then when the user clicks a button it will send the php object for each checked row through GET or POST. But, how would I get it to onchange update a PHP object (the PHP object would need to be a 2-D array where the first index allows you to select the part and the second index allows you to select which quantity you will change). I'm thinking I would need to call a script from the onchange like: onchange="somePHPfunction(partNumberIndex, whichQuantityI'mChanging, currentValueOfThatQuantity)" but of course that would require me to embed some php inside the onchange call since the partNumberIndex and whichQuantity are PHP variables.. Any ideas on how to do this sort of thing? Or any ideas on how to do this differently? I'm trying to avoid javascript because it would place a javascript constraint on the users. But, maybe there's no other way to do this sort of thing? Any help would be greatly appreciated! This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=347753.0 Hi Guys, I'm having some trouble running PHP scripts. I have two forms, each of which redirects to a PHP script (each PHP script is different, but essentially both have the same problem) as an action. The code is below. I'm hosted at Bluehost, which runs PHP on their servers so I know the tech is compatible. Thanks! Cheers! <html> <script type="text/php">include('newform.php');</script> <head> <title>TradeSquared></title> <p align="center">Trade Squared</p> </head> <body> <br> <br> <div align="center"> Create a new Listing: <form action="newform.php" method="get" name="newform"> Type:<select name="type"> <option value="book">Book</option> <option value="apt">Apartment</option> <option value="item">Class Items</option> </select> <input type="submit" value="Submit"/> </form> <br> Search current Listings: <form action="searchform.php" method="get" name="searchform"> Type:<select name="type"> <option value="book">Book</option> <option value="apt">Apartment</option> <option value="item">Class Items</option> </select> <input type="submit" value="Submit"/> </form> </div> </body> </html> This is the PHP code on which action redirects to <?php $type = $_GET=["type"]; if($type=="book") header("location:addbooklisting.html"); else if($type == "apt") header("location:aptform"); else header("location:itemform"); ?> Second page <html> <head> <title>Create New Book Listing</title> <p align="center"> <b>Create a New Book Listing</b> </p> </head> <body> <div align="center"> <br><br> <form name="addlisting" method="get" action="bookvalidation.php"> <table width="100" border="0" align="center"> <tr> <td align="center">Title </td> </tr> <tr> <td align="center"><input type="text" name="title"/> </td> </tr> <tr><td><p/></td></tr> <tr> <td align="center">Price </td> </tr> <tr> <td align="center">$<input type="text" name="dollars" size="3"/>.<input type="text" name="cents" size="2"/> </td> </tr> <tr><td><br></td></tr> <tr> <td align="center">ISBN</td> </tr> <tr> <td align="center"><input type="text" name="isbn"/></td> </tr> <tr><td><br></td></tr> <tr> <td align="center">Condition </td> </tr> <tr> <td align="center"><select name="cond"> <option name="used">Used</option> <option name="new">New</option> </select> </td> </tr> <tr><td><br></td></tr> <tr> <td align="center">Commentaries </td> </tr> <tr> <td align="center"><textarea rows="5" cols="30" name="comm"></textarea></td> </tr> <tr><td><br></td></tr> <tr> <td align="center"><input type="submit" value="Add Listing"/></td> </tr> </table> </form> </div> </body> </html> PHP code for second page <html> <head>Results</head> <body> The Following Occurred: <?php $title = $_GET["title"]; $dollar = $_GET["dollars"]; $cents = $_GET["cents"]; $price = $dollar.".".$cents $isbn = $_GET["isbn"]; $cond = $_GET["cond"]; $decide; $comments = $_GET["comm"]; for($i=0; $i<=12; i++) { if(ctype_digit($isbn)) $decide = true; else $decide = false; } if( !(($dollar && $cents)==int) ) echo "Price must be in numbers."; else if($decide == false || strlen($isbn)!=13) echo "ISBN contains 13 characters and must be numbers only" else { $db=mysql_connect("localhost","username","pass!"); mysql_select_db("db_dataabse",$db); $dbsucces=mysql_query("INSERT INTO BookListings (Title, ISBN, Price, Condition, Comments) VALUES ('$title', '$isbn', '$price', '$cond', '$comments')"); if($dbsuccess==true) echo "Posting was succesful"; else echo"Unsuccesful log."; } ?> </body> </html> My employer asked if I could change an existing contact form on their website to allow clients to enter their Social Security Number along with the normal contact information if the client decide to do so, instead of going through the motion of physically send in the form via snail mail, fax, or in person (like it is currently handled). But since this piece of information is of such delicate nature, I wonder how I should approach this from both a legal standpoint and from a programming standpoint. The form currently sends the information entered by the user to an inbox with mail(), so my initial thought was to somehow encrypt the information, limiting the risk of someone getting a hold of this information once the use user clicks "Send". But is full blown SSL really necessary for this? Are there easier options? And what should I think about before enabling this? Hi, I have made a basic html site and it has two forms on it. I have the forms linking to a file called process.php. Basically i need to know what code to put in the php file in order for the forms to save whatever is entered in them to a txt file on my server or computer. Or any other easier way to do the same thing, save the content of two forms on my site. Hope i posted this in the right forum subject. Thanks very much for anyone that helps. i need a form that is hidden until the user clicks a button on a calendar only Then the form will be visible and have a field for the day that way pressed on submit the form would go back to being invisible.
not sure how to implement this can anyone help
I need someone that is really good with php forms, looking for major help. We have this form that customers can make their own contact forms, and then it gets inserted to the database. We can show the forms with no problems, the problem lies when someone hits submit, how do I echo out the values of the form when I'm not sure what the input name or id is going to be? This sample form generated this code Code: [Select] <div class="element"> <label id="label-element-3" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Email</span> <span class="required">*</span></label> <div class="errormessage" id="errormessage-element-3"></div> <div class="option-container"> <input class="af-inputtext af-email af-formvalue " type="text" name="element-3" id="element-3" value="" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:260px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;"></div> </div> <div class="element"> <label id="label-element-4" class="label" style="color:#4DBCE9;font-family:Trebuchet MS;font-size:1.2em;font-weight:normal;"> <span class="labelelementvalue">Textarea</span></label> <div class="errormessage" id="errormessage-element-4"></div> <div class="option-container"> <textarea class="af-textarea af-formvalue " name="element-4" id="element-4" style="color:#000000;font-family:Verdana;font-size:0.8em;font-weight:normal;width:300px;border-style:solid; border-color:#dcdcdc;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;border-width:1px;padding:5px;" rows="6"></textarea></div> </div> <div class="element"> </div> If you notice, each input type is named "element-" with a number afterwards. So each input could be like "element-4", "element-21", and so forth. How would I post those values of the input fields when they are automatically named? Thanks in advance I am starting to build out a class to handle forms. I want to be able to add and edit data in some cases and just add data in other cases. Also want to do some ajax stuff to prevent from having to reload the pages in certain cases. I would like to view how some other form classes work so I can model mine to what I like about others but suit my needs. I was wondering if anyone has worked with any preexisting form classes that they could recommend. I know libraries like zend and so on have these built in and wasnt sure if anyone liked any one specifically and why. I am attempting to create a login page, but my script is giving errors in relation to the forms. Involved PHP: Code: [Select] $username = mysql_real_escape_string($_POST['username']); if ($_POST['submit']=='Login') { $md5pass = md5($_POST['password']); $sql = "SELECT id,username FROM members WHERE username = '$username' AND password = '$md5pass'"; //etc etc... Involved HTML: Code: [Select] <form id="f6" action="" method="post" onsubmit="return weCheckForm(this)"> <fieldset id="e6" class="cc32"> <label id="e5" class="cc33" for="e4"> Username </label> <input id="e4" class="cc34" type="text" name="username" title="username" size="23"><br> <label id="e3" class="cc33" for="e2"> Password </label> <input id="e2" class="cc34" type="password" name="password" title="password" size="23"><br> <input id="e1" class="cc35" type="submit" title="submit" value="Login"> </fieldset> </form> Errors received: Notice: Undefined index: username in C:\(etc etc...) on line 4 Notice: Undefined index: submit in C:\(etc etc...) on line 6 Now I know that the problem is username and submit are undefined. However, I do not know how to define them in relation to the forms. ok i have a questions i making a form so when users sign up to my website they we have an account page and in the account page the will have some more fields they need to filll in which i would use INSERT to put the things inside my db but what if they want to update there account should i use UPDATE Hi there, I'm new to php/MySQL. Just wondering how to create a multipage form with a back, save and submit button. Also, how do you stored the form data into the datebase and how do you display a list of submitted forms by the user to the user. Hello, I just assembly a form and for styling it I am using CSS in an external file. Problem is that IE8 and I don't know about 7 (in IE9 is ok) it doesn't show the styling inside the form... My structure is something like this: (in any other situation my css styling is displayed normally) Code: [Select] <form> <span class="myclass"> </span> </form>Is there any fix for it? Thank you |