Jump to content

garyed

Members
  • Posts

    176
  • Joined

  • Last visited

Everything posted by garyed

  1. I posted a little while back & got some help with a page I'm working on with about 50 session variables. I used a function as suggested & everything works fine except when I blank out a field that had data already input into it & was posted to the page the old data returns after posted again. If I put a zero in the input field then the zero will stay after posted but if i leave the field blank whatever was last posted returns to the input field. It's been driving me crazy. Any ideas what I'm doing wrong? Here's an example of the code: <?php session_start(); function get_value($var) { if ($_POST[$var]!="") { $_SESSION[$var]=$_POST[$var];} if (isset($_SESSION[$var])){ echo $_SESSION[$var];}else{ echo $_POST[$var];} } ?> <form method="POST" action=""> <table> <tbody> <tr> <td style="text-align: right;"> Windows </td> <td><input name="windows" style="background-color:#FFFFCC;width:60px;" maxlength="10" value="<?php get_value('windows'); ?>"type="text"> </td> </tr> <tr><td> <input type="submit" value="Calculate"></td></tr> </tbody></table> </form>
  2. Thanks to both of you for the help, I really like the idea of using a function too.
  3. Since no one has replied can I assume that there is nothing wrong with my code & I just need to do the same thing for all my variables that I want used in the session?
  4. I have a php page that has about 50 separate data entries that I want to have the user be able to leave the page & return without losing all the data already entered. I'm assuming I would need to use session variables to make that happen so someone please correct me if I'm wrong. Below is a sample of the the code I'm using for just one variable. <?php /* Start session & put variables into session so the user can leave page & return without losing everything */ session_start(); if ($_POST['windows']!="") { $_SESSION['windows']=$_POST['windows'];} ?> <form method="POST" action=""> <table> <tbody> <tr> <td style="text-align: right;"> Windows </td> <td><input name="windows" style="background-color:#FFFFCC;width:60px;" maxlength="10" value="<?php if (isset($_SESSION['windows'])){ echo $_SESSION['windows'];}else{echo $_POST['windows'];} ?>"type="text"> </td> </tr> <tr><td> <input type="submit" value="Calculate"></td></tr> </tbody></table> </form> All the data entered is then used for calculations so my questions are: 1 - Is there an easier way to do this without repeating the code for all 50 separate variables? 2 - Once data is entered into a field it still comes back even if I empty out the field. Any help appreciated
  5. I like that idea but it's a little over my head right now. I know how to do a while loop & populate a drop down menu from a database but I don't know how I could get the order exactly right for each input field & that would be a must. The site I'm working on is: http://www.loadcalc.net . Its a series of four pages where each choice goes to the next page. The last page has the most fields & that is the one where I have the most complaints about losing data when leaving the page & returning. Also the problem I have with this code: session_start(); if ($_POST['test']!=""){ $_SESSION['test']=$_POST['test'];} is once a session variable is set & then you delete the input value in the field, it gets repopulated with the session variable again instead of being blank. I assume there is a better way to do it but haven't figured it out yet.
  6. I've been trying to understand how to keep data entered into a form when the user leaves the page & returns using session variables. I've got it working to some degree but I don't think its right & I'm hoping someone can steer me in the right direction. I've got about 75 field inputs on one page so I'm trying to get it right with just one field before I change everything. Here's my code so far: <html> <head> <?php session_start(); if ($_POST['test']!=""){ $_SESSION['test']=$_POST['test'];} ?> </head> <body> <form method="post" action=""> <input type="text" name="test" value="<?php if (isset($_SESSION['test'])){echo $_SESSION['test'];} else {echo $_POST['test'];} ?>" > <input type="submit" value="submit"> </form> </body> </html>
  7. That sounds like a good idea if I can figure out how to do it. I'll try & work on it. Thanks for the idea.
  8. Maybe I didn't make myself very clear. The page where the form is filled out remains as is & the data entered into the form produces additional output on the page. A link to the page would be useless because all the data & inputs are gone when you leave the page.
  9. I know how to do an email script so I assume I could email a file without a problem but I want to email a web page. Currently I have a php page where the user enters a bunch of data in a form & the form prints the results to the screen. I use a javascript window.print() function so the user can print the page. I want to be able to have the user hit a button & email the same output that the javascript function will print. I assume I would have to print the page to a file & then have that file emailed but how can the page be printed to a file? Am I even thinking on the right track?
  10. Right now I'm using: <input type="text" name="window" value="<?php echo $_POST['window']; ?>" > to keep the data in the fields when the page is submitted. Wouldn't I have to still use the php tags to use $_SESSION ?
  11. Thanks to everyone for the ideas, I'm going to read up on all these recommendations & see how things work. My programming skills are pretty weak. I'm just learning what I need to do on an as needed basis. Probably not the best way to do it but thank God for the internet.
  12. I'm not sure if this is a php problem or not but here goes. I have an online program that consists of four php pages. Each page takes you to the next after your data is entered or selected until you get to the fourth page. That is where you get the final solution needed. The main reason I separated the pages was for looks so there wasn't too much to view or do on any one page. The problem is when you get to the last page & you enter all your data you can't change any selections from the previous page without losing all the data you just entered on the last page. There are about 50 different input boxes on that page too. The only thing I can think to do is to combine all the pages into one to solve the problem but that defeats my original purpose of separating the pages to begin with. Here's the link - http://www.loadcalc.net Any ideas welcome
  13. Now I've got it, To sort the cities in Georgia alphabetically: select * from cities where state="GA" ORDER BY city; cities is the table , state & city are fields. Thanks for the help
  14. I've got a separate field for state & city in the same table. After the state is selected then the cities from that state are in the drop down.
  15. Actually what I'm trying to do is populate a drop down menu with a bunch of US or Canadian cities & villages after a particular state or province has been selected. <option value="" selected="selected" style="width:250px;" > ---- </option> <?php // This will populate the drop down menu with the database entries for cities while ($city_row=mysql_fetch_array($new_city)) { $state=$city_row["state"]; $city=$city_row["city"]; ?> <option value="<?php echo $city; ?>" style="width:250px;"> <?php echo $city; ?> </option> <?php } ?> If they are already in alphabetical order the above code works fine. If I learn how to use ORDER BY will it work in this instance if they were not in alphabetical order already?
  16. I'm really kind of shocked that you can't just insert a record after or before another record. This problem came about because I was adding the name of some Canadian villages to an existing table in alphabetical order & for some rerason they were not being inserted to the end of the database but about 10 records before the end. Evidently I deleted about five records in that spot so every time I inserted a new record it went back to the place where the old ones were deleted. What I finally did was insert five dummy records & now when I insert a record it goes at the end of the table. When I get through with all the entries I'm going to delete the dummy ones & see if that works O.K.
  17. Is there a way to insert a record in a specific place in a table? I have about 1000 records in the table I'm working on so lets say I want to add "Jack" in between "Alex" & "Suzie": Name Age Jim 37 Gregg 29 Alex 42 Suzie 63 How would I do that?
  18. Would the php isnumeric function on all the input fields protect from sql injection since all the input should be numeric anyways?
  19. I wasn't sure where to post this so I apologize if this is the wrong forum. I have a php page with over 50 numerical inputs on a form. A lot of the inputs are used to get data out of the mysql database so I want to be safe from sql injection. Is it safe to use a javascript onsubmit function that will not allow the form to be submitted if there is any non numeric data entered by the user? I've already written the function & it works fine but I'm not sure how much protection it gives me. Any feedback welcome.
  20. Sorry about the misprint, I didn't see any place to edit the url: http://www.loadcalc.net/load.php If you click on the little drop down arrows next to the places that say "Windows" that's where the problem is. Every browser except IE will show the full text in the drop down menu after you click on it. IE only opens up the drop down menu as big as it shows on the initial screen so the text is unreadable.
  21. I didn't see the sticky but I don't know how to use css yet. My website in progress is: http://www/loadcalc.net Each choice sends you to the next page & the fourth & final page is where I'm having the main problem.
  22. I have a web page that works fine in every browser I've tried except IE. There are a bunch of them so I need them to be small to keep the look of the page but when you click on the drop down arrow I need it to open up wide enough to read the complete text. It works O.K. in Firefox, Opera, Safari & SeaMonkey but not in IE. In IE it only opens up to the same 30px width that it starts out at on the page. Here's my code: <select name="shade_gdr_s" style="width:30px;" onchange="darken();"> <option value="yes" style="width:220px;">Use overhang shading</option> <option value="no" >Do not use overhang shading </option> <option value="one" >Use shading for type 1 only</option> </select> Any ideas?
  23. Thanks, thats exactly what I needed. I also just found the answer using phpmyadmin too.
  24. I have a table with a bunch of records that each have a unique id number as one of the fields. Since I added things hap-hazardly they are all over the place order wise. Is there a command to update or alter the table where the records could be moved so that they go from lowest to highest using the id number?
  25. I finally got it!! I was using ($_produce,0) as the argument when I needed to use ($result_produce,0). Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.