PHP - Should I Use Php To Build A Form?
Is it overkill to use PHP/MySQL to query my database, retrieve the universe of Questions, and then dynamically build a Form?
I have a "Q&A Form" with a whopping 10 Questions. I suppose dynamically building the Form has the advantage that I always have the most up-to-date Questions and Question Text, but them again, if there is a database issue, I have a larger issue... Thoughts? Debbie Similar TutorialsOK here is what I have going on right now. Currently I'm trying to build a excel spread sheet into a dynamic form via php. The results are basically questions and are stored each week so for one section they may be asking how many visitors, employee's , etc.. now some of these values that are being entered are going to be used in another question per-say but the result may come from other values that were already submitted so these questions would not be shown in the form that needs to be made later on. The form I'm having trouble with is the initial form to help generate the formula's for these different questions. So what I was going to start doing was have it list all the questions with a check box next to the question if the formula for said question was something like add these two questions and the divide by this set of questions or a whole number then it would display a list of questions for adding together and the get the total from that set and then do a expression afterwards like adding, subtracting, multiplying or dividing. So I was thinking I should list like a set of buttons I think in the beginning. What is the first task at hand Totaling, Adding, Subtracting, Dividing, Multiplying and then when they click on this it would refresh the page and bring up a box that lists all the different questions for them. Then saving the values as which ever button they clicked and once they do this. Then they could either click on say a more button which would pass the values as a array back to the page and continue on or they could click submit and pass the values into a db field as a formula but this is my first concept and would like to know if there may be a better way of doing it. Can anyone find a glaring error with my contact form or my mailer? I previously had a form that was working (sending the email through) but stopped working. It was more complicated before and had a recaptcha in it. I've been troubleshooting this for awhile now and can't figure out what's happening. I've stripped it down to just the basics. I'm stumped because I am correctly redirected to the confirmation.html page, yet no email has come through. I even put a simple test file (mailertest.php) on the server. The file is found and echoes "Mail sent", but no email is received. I contacted the host and they claim that things are fine on their end with the PHP mailer and it must be a problem in my code. As a newbie, I don't doubt that I'm doing something wrong, but I can't figure it out!
I'm attaching three files. Contact.php, contact_mailer.php and my test PHP file called mailertest.php. I'd appreciate any help that anyone can offer.
Attached Files
mailertest.php 99bytes
3 downloads
contact_mailer.php 608bytes
1 downloads
contact.php 7.55KB
0 downloads I understand that is might be something that is already answered and I apologize if it is, I could not find it.
What I need to do is build a simple form that has two options, they will be dropdown options. Dropdown A and Dropdown B then a Submit button. This part I understand in HTML, although it may be easier in php or javascript.
Then I need it to take the two options and create a "if/then" statement that loads a specific pdf that matches the two options selected.
Example.
If someone selects Option 1 from Dropdown A and Option 2 From Dropdown B then it loads 12.pdf If someone selects Option 5 from Dropdown A and Option 3 From Dropdown B then it loads 53.pdf If someone selects Option 2 from Dropdown A and Option 1 From Dropdown B then it loads 21.pdf and so on... It does not have to be the exact thing just some way to take both inputs and have it equal a specific pdf. Here is the form I built but I don't know what to put in the form_action.php file in order to make it work <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <center> <h1> Get Directions</h1> <form action="form_action.php" method="get" name="directions" target="_new"> <select name="startpoint" size="1"> <option value="north">North Tower Entrance</option> <option value="south">South Tower Entrance</option> <option value="moba">MOB A Entrance</option></select> -----> <select name="endpoint" size="1"> <option value="onco">Oncology</option> <option value="radio">Radiology</option> <option value="pulm">Pulmanary</option></select> <br /><br /> <input type="submit" value="Submit" /> </form> </center> </body> </html>Any help is appreciated, thanks. Hey guys,
I have a PHP wrapper which I need a html form made for. It's a very small bit of work
In exchange I will give you a 15€ Gift Voucher for my online website, we are a sweets and drinks store online!
You can email me at dubplates@safe-mail.net
Many thanks,
- D
Instead of breaking down and actually learning how to use ajax, I'm thinking about trying to do something so I don't need a page refresh every time, and the filtered data is nearly instant. I just use the session array var, and build a new array from the rows that meet the conditions. I'm thinking of loading a two dimensional array into a session var, then use some input buttons, and use the post vars to filter the array based on a set of predefined conditions. ie status = 0, status = 1. It's a fairly small number of conditions applied to two different fields. So, I need to access specific fields within a row, and essentially create a new array either including or excluding that row depending on whether it met the condition. I'm struggling on several parts. 1. not sure how to build the array so that I can access specific fields, then not sure how to access those fields. Do I do this..... to build the array? .... Code: [Select] while($row = mysql_fetch_assoc($result)){ $array[] = array($row['field1'], $row['field2']); } I was thinking about using a foreach and is_array() to get to each row... Code: [Select] foreach($array as $key => $value){ if(is_array){ foreach($value as $k => $v){ if($v[0] == 1){ //stuck here $v[0] is not a field, it's the first char of the string. not sure how to access a field $new_array[] = $value; //stuck here. I need to put the whole row back into the array if the condition was true. seems like I would have to use the field selectors and rebuild the array. } } } } What would you do? Open to any ideas. I have two questions, I was wondering what would be the best method to go about building client side API functions on top of a already built API eg. http://docs.whmcs.com/API:Functions
We would like to provide our clients access to API functions related to their accounts without giving them access to the whole Admin API where they can see a lot of our other client information.
The other question we have an API built using Basic HTTP Auth for API authenication (HTTPS). eg curl username:password http://api.etc.com) If so what would be the best way to secure this method?
Thank you HI, coming from a .net background and picking up php as I go along, I was wondering what the best way of designing the following task is in php. It's part of an appointmnet reminder app and the admin can amend the message that is sent out. The default message is currently stored in a db table and displayed in a multi line box on the admin web page. for example, "This is a an appointment reminder for *patient name*. You have an appointment on *date* with *customer name*." There's two parts relating to the message process. 1. Allowing the admin to amend the message (but ensuring the *variable markers* are left in tact, so I know where to stick the variables for part 2) 2. When the messages are being sent out (for each loop), inserting the *variables* into the message. I have no problem getting hold of the *name*, *date*, *customer* for each iteration in the for each loop. I'm sure people have done stuff like this before and in .net I would use a stringbuilder object but like i say, I'm not all that groovy on php at the mo. I was thinking of maybe a function that accepts thats passed the message, name, date, customer or something.. thanks Hello again, guys! I'm trying to do this: Get $user_ID -> SELECT FROM favorites WHERE user="$user_ID" -> Now I should create an array with the ID of all the results of the previous command -> SELECT FROM books WHERE genre="$favorites_ID" -> populate a html table. The part I've no idea about how to do is building an array with the results and then using the SELECT command, find in the other tables the match. Could you please give me a hand - one more time? Hello. I would like to build a survey that I can use on an iPad so that I can go out in the field and gather data from people. What would be the best way to accomplish this? I'm not sure what limitations even exist on an iPad - like can you have a webserver like MAMP? It seems to me that using something like Angular or whatever might make sense since you can build a working app all in one, but then I don't even know traditional Javascript. Just looking for a quick way to build something to allow me to survey people without making this a major project.\ Thanks. Hi there, i have a problem regarding a editor that I am building, I am fairly new to php, but this is what i have so far: Code: [Select] <?php $dirname = "."; $dir = opendir($dirname); ?> <form action="editor.php" method="POST"> <select> <?php while(false != ($file = readdir($dir))) if (strpos($file, '.php',1)||strpos($file, '.html',1)||strpos($file, '.css',1) ) { { if(($file != ".") and ($file != "..")) { echo("<option><a href='$file'>$file</a></option>"); } }} ?> </select> <input type="submit" value="Submit" /> </form> <br /> <center> <form > <textarea rows="80" cols="130"> <?php include $_POST["$file"]; ?> </textarea> </center> The code produces a drop down list of any html, php or css files in the current directory and I want it to be able to show the selected file from the drop down list in the textarea so that I can edit it, I also am not sure how to save the file, would this be a file write method? any help would really be appreciated as I've been stuck on this issue for hours an its doing my nut in!!! Thanks SF Hi, I have to build some reports based on mysql queries. Nothing fancy, just text, columns... There are a lot of paid softwares but I can't (and don't want to) spend any $$ right now... So, considering that I want very simple reports almost like a table with heading and subtotals, I should write it myself. But I don't know how (still...). I'm looking for tips, tutorials, ebooks... anything that explains how to make a very simply report. Regards, Pedro. Hiya peeps! I can't seem to build a preg_match pattern that works. This is what I need to do. "[" . $errorID . "]='HERE IS WHAT I NEED TO DISPLAY';" Does anyone have any ideas on how I would build this regex string? Many thanks, James. So, I need to build a table based on this table: Code: [Select] create temporary table downline ( depth int, member_id int, full_name varchar(50), level int, referrer_id int, country char(2) ); I need to make a table to show each members downline (the people they referred to the site), it needs to be unlimited levels deep, and we have some members that have 25+ levels in their downline, where level 20 has 15,000+ people. Level 1 = your downline Level 2 = your donwline's downline Level 3 = your downline's downline's downline ect. I have this loop (after the temp table is built) which needs to build a table on the page. So, I can not get this table display right for the members downline, any suggestions? // Build the current users downline and add it to the temporary table $downline = mysql_query("select * from downline order by depth"); while($row = mysql_fetch_assoc($downline)){ if($row['depth'] != $depth){ $depth_id = $row['depth']; $content .= "<tr id='main_lvl_$depth_id' class='hiddenInfo' onclick='showHide(this);'><td style='text-align: center;color:#4d53c1;font-weight: bold;' class='w_border'><span class='signs_s'>".$this->dict['mLevels_Level']." $depth_id : </span><span class='signs'>".count($down)." ".$this->dict['mLevels_Members']." </span></td></tr><tr id='lvl_$depth_id' style='display:none;'><td class='w_border' style='text-align: center;'><table style='width:100%;'>"; $i = 0; $content .= "<tr> <th>Member ID (Sponsor ID)</th> <th>Member Name</th> <th>Country</th> <th>Member Level</th> </tr>"; } $class = ($i%2) ? 'color1NL' : 'color2NL'; $content .= "<tr id='_{$key}_' class='$class'><td class='width33'><a name='_".$row['member_id']."'></a><a href='?mid={$row['member_id']}'>#{$row['member_id']}</a> (<a href='?mid=".$row['referrer_id']."'>#".$row['referrer_id']."</a>)</td><td class='width33'>".$row['full_name']."</td><td>".$row['country']."</td><td class='width33'>".$row['level']."</td></tr>"; $i++; if($row['depth'] != $depth){ $content .= "</table></td></tr>"; } $depth = $row['depth']; } The following attachment has a working copy. The reason we don't stay with this is because it doesn't work with members who have large downlines, we run out of memory in php, and this hopefully will solve this problem. Hey PF. I'm trying to build some better coding habits, so what tips do you guys have? Of course there are obvious things such as well-commented code, neat structure, etc... But I'm looking for some more "TECHNICAL" tips that might be unspoken. For example, when is a good time to use a variable, opposed to a constant? I notice that a lot of programmers define their database settings with define(), while others just use a $variable. Is this personal preference or maybe its something I'm missing? I'm looking for ALL tips. Any information that you have, please share it. It will help make me (And anyone else reading this), a better coder. Thanks in advance. and if this is not the proper forum, please move it! =] Ok so I'll try to explain what I'm trying to do the best I can. I want to build an array that allows me to add/remove/modify the variables used at any point in time without having to rebuild or rewrite a ton of new code. For example, below is an example list of variables I'd like to use in the array, followed by the code I would like to be automatically repeated. Example Variables: $materialName1, $materialName2, $materialName3, $materialName4, $materialName5, $materialName6 etc etc etc Example Code to repeat: Code: [Select] echo "<tr><td>Material: $materialName1</td><td>Rate: $materialName1Rate</td><td>Weight: $materialName1Weight</td></tr>"; Hopefully that makes sense. As always, very appreciated. How could I build an interactive text system? It should work like this: Text is displayed. 1-3 options (a situational amount of them) to answer displayed. Example: Are you male? Yes No You choose yes or no and it leads you to another questions based from your previous answer. Example: (a follow up to the 1st one) So you're male. Do you like cars then? Answers. And it goes on and on. The thing I need help with is the answers. I need to show them based by the previous answer but don't know how, any help? I'm confused how to get the chat object to work with the pushes/pulls, and don't know where I'm going wrong. Here's the basics of what I need to know without reloading the page:
how do I push new data to the server
how do I push new data to the client
how do I not rebuild the data client has every time
I may need to know more, but that's what I know I need to be able to do so far.
This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=346015.0 This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=358758.0 I'm trying to build an array in a foreach loop, but when I got to echo the results it only displays the first character of the string, but if I do a print_r on the array it show the data fine. $msgColor1 = array(); foreach ($playerName1 as $value) { $msgColor1['name'] .= $value[$i]; $i = $i + 1; } print_r show the data but when i do foreach ($msgColor1 as $test) { echo $test['name']; } Only shows the first character in the string |