Jump to content

Scooby08

Members
  • Posts

    244
  • Joined

  • Last visited

Everything posted by Scooby08

  1. Hey thanks a bunch for that bit of code!! Now I've never used a session before.. The code didn't seem to output anything from copy paste.. I had to add the session_start() to the main page as well, and before the html, and it seemed to work. The question I have is this.. I take it the session cannot start in the process.php and carry over to the main page.. I must start a session on the main page before the process for it to be correct then? And do sessions need to be specified on all pages? And do they need to be specified in the function itself, or can it just be at the top of that process page as well?
  2. Now that's interesting.. Can you give me a more descriptive example as to how you're doing this please??
  3. I guess I just have one more question then... I am passing the error messages through the url.. Is this the way to do this?? Seems like that string could get really long being that I have a message for each field that errored. Also, when I get the string form the url and display it on the page it is displayed as so: Please enter the Bride\\\'s name! Then I added this: $message = stripslashes(mysql_escape_string($_REQUEST['message'])); Which still left one slash like so: Please enter the Bride\'s name! So I added another stripslashes around the other stripslashes: $message = stripslashes(stripslashes(mysql_escape_string($_REQUEST['message']))); That got rid of all slashes, but that seems like stripslash overkill.. Is this the correct way to do that as well??
  4. It passes both those tests and gets inside the add() function.. It's just not recognizing the check_for_errors() function.. I have info below that from the form that is inserted into the database, so I know it's getting there, but that dang function is hiding for some reason.. If I take the code out of the function it works fine.. I might just end up doing it that way..
  5. No, you were right the first time.. It was my typing error.. I was just trying to give example code because it all works up until it doesnt call the function..
  6. Yes typing error.. Here is path.. index.php (the form), process.php (the action), functions.inc.php (calls the error check function into process.php)
  7. Here is the form action line <form action="process.php?action=add" method="post"> Here is process.php <?php // Connect to database include ('config.inc.php'); include ('database.inc.php'); include ('functions.inc.php'); // Actions function main() { if ($_REQUEST['action'] == 'add'){ add(); } elseif ($_REQUEST['action'] == 'update'){ update(); } elseif ($_REQUEST['action'] == 'delete'){ delete(); } } // Call actions function main(); function add() { check_for_errors(); } ?>
  8. I have a form that I'm trying to validate.. I have 3 files involved: index.php; process.php; functions.php.. When submitted it runs through process.php.. In that file I call on a function from the functions.php file to check for errors, but my problem is that the function is not actually getting called.. For some reason it is overlooked and I can't figure out why. Here is the function code.. <?php function check_for_errors() { if ($_REQUEST['firstname'] == '') { $message = "Please enter firstname!" . "<br />"; } if ($_REQUEST['lastname'] == '') { $message .= "Please enter lastname!" . "<br />"; } return $message; header("Location: index.php?message=$message"); exit(); } ?> What am I overlooking here? Or maybe I'm just not supposed to call on validate form function like that?? Im not sure??
  9. Wow!! Matt really is the best!! Thanks a bunch..
  10. Im trying to add up totals for each order and display that total.. The problem is that this code adds up all totals for all orders.. What would I need to do to display the total for each order_id?? <?php $query_total = "SELECT dw_order_items.order_id, dw_order_items.item_id, dw_order_items.item_qty, dw_items.item_price "; $query_total .= "FROM dw_order_items, dw_items "; $query_total .= "WHERE dw_order_items.order_id = '$order_id' "; $query_total .= "AND dw_order_items.item_id = dw_items.item_id "; $result_total = mysql_query($query_total) or die(mysql_error()); while($row_total = mysql_fetch_array($result_total)) { $item_id = $row_total['item_id']; $item_qty = $row_total['item_qty']; $item_price = $row_total['item_price']; $total_item_price += $item_qty * $item_price; // This is the line that adds all totals } echo show_price($total_item_price); ?> I know that line I have marked keeps adding all totals, but I don't know what else to do??? Any ideas out there??
  11. I was wondering how to store this date into the database: Friday, August 28, 2015 and this time: 8:00PM I have one field that collects the date and another for the time.. Im looking to store them in this format, 0000-00-00 00:00:00.. Is there some way to turn this date "Friday, August 28, 2015" into this "0000-00-00 00:00:00" so it will be inserted into the database using DATETIME??
  12. What is the proper method for one to insert future dates and times into a database.. Would you need a date picker? And a time picker if there is one?
  13. I am sorry for the lack of information.. I figured out why it wasn't working.. It was in a loop so the loop was causing it not to work for some reason.. Any ways I found another way around my problem..
  14. Can anybody tell me what's wrong with this code? <form name="formAdd"> <input type="radio" name="item_id_wp" value="5" onClick="document.formAdd.wedding_package_1.value='1';" /> <input type="hidden" name="wedding_package_1" value="" id="qty_item_1" /> </form>
  15. Hey guys.. Thanks for the reply!! I see what you are saying, but I need a value in there.. The = sign is just used to echo the value and it works just fine.. The problem is beyond that.. What you see there works just fine for entering data into the database.. Its the calculation that is getting screwed up with this.. Here is a quick example of what's going on here.. <input type="radio" name="item_id_wp" value="1" id="qty_item_1" /> <input type="radio" name="item_id_wp" value="2" id="qty_item_1" /> <input type="radio" name="item_id_wp" value="3" id="qty_item_1" /> Now there the value is just called from the database, but the jquery calculation plugin I am using uses that value to multiply the value... So those lines would be like so: <input type="radio" name="item_id_wp" value="1" id="qty_item_1" /> (1 * $10.00) = $10.00 <input type="radio" name="item_id_wp" value="2" id="qty_item_1" /> (2 * $10.00) = $20.00 <input type="radio" name="item_id_wp" value="3" id="qty_item_1" /> (3 * $10.00) = $30.00 when I need them to be like so: <input type="radio" name="item_id_wp" value="1" id="qty_item_1" /> (1 * $10.00) = $10.00 <input type="radio" name="item_id_wp" value="2" id="qty_item_1" /> (1 * $10.00) = $10.00 <input type="radio" name="item_id_wp" value="3" id="qty_item_1" /> (1 * $10.00) = $10.00 but still send the original called values to the database with their choice of which radio button was checked.. Im sorry it's so confusing, but I have no where else to go for help.. Thank you.. Can I post example links on here without problem?
  16. Im having a problem figuring this one out, and I am out of ideas.. I have this code: <table> <tr><th>Wedding Packages</th><th>Choose One</th><th>Unit Price</th><th>Cost</th></tr> <?php $query_wp = "SELECT item_id, item_description, item_price FROM dw_items WHERE item_category = 'wedding_packages'"; $result_wp = mysql_query($query_wp) or die(mysql_error()); while($row_wp = mysql_fetch_array($result_wp)) { ?> <tr> <td><?=$row_wp['item_description'];?></td> <td><input type="radio" name="item_id_wp" value="<?=$row_wd['item_id'];?>" id="qty_item_1" /></td> <td id="price_item_1">15.99</td> <td id="total_item_1"></td> </tr> <?php } ?> </table> It pulls the data from the database and displays multiple rows of radio buttons.. Works out great for me.. Here is the problem.. I need to figure out a way to get the value of each radio input to equal 1 if clicked and 0 if unclicked.. But also I am using the value to send which item was checked to the database, so as right now the value is whatever it pulls from the database.. The reason I need the value to equal 1 when checked is because each input has a dollar amt value and I am using the jquery calculation plugin which relies on each value to calculate the total.. I hope somebody can understand this.. I have tried adding this to the end of each input and it almost does what is needed.. onclick="this.value = 1;" onblur="this.value = <?=$row_wp['item_id_wp'];?>;" The value is set to 1 for the calculation, and then the onblur is the value I wish to send to the database.. Problem is when the onblur takes effect the calculation is thrown off with the original value and the total is then incorrect again.. Guess Im looking for the ultimate answer here..
×
×
  • 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.