Jump to content

zimmo

Members
  • Posts

    171
  • Joined

  • Last visited

Everything posted by zimmo

  1. Thanks for all your help, yes its working now. Thanks everyone, superb forum this. Thanks to all for assistance, got there in the end.
  2. appreciate your time. I noticed that one and changed it, since posting the original code, I noticed a few issues that I corrected. I am getting no errors now, but still not submitting the data? as I found out its within the form somewhere. I have produced the same script for another site, albeit different data and this works fine, the only difference being the previous one was done in tables with standard input fields and not using the css way by using fieldsets etc..
  3. Thanks for the change in script, have to say much easier than the way I have done it and simpler. Right, after doing that still no joy, so its got to be the form. Here is the form code relating to my original code though: <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Main Details</legend> <p>Please complete the form below</p> <p><label for="venue_name">Venue Name</label> <input class="long" type="text" value="<?php echo $venue_name; ?>" name="venue_name" id="venue_name" maxlength="128" /><br><?php echo $venue_name_error; ?></p> <p><label for="address_1">Address 1</label> <input class="long" type="text" value="<?php echo $address_1; ?>" name="address_1" id="address_1" /><br><?php echo $address_1_error; ?></p> <p><label for="address_2">Address 2</label> <input class="long" type="text" value="<?php echo $address_2; ?>" name="address_2" id="address_2" /></p> <p><label for="address_3">Address 3</label> <input class="long" type="text" value="<?php echo $address_3; ?>" name="address_3" id="address_3" /></p> <p><label for="town">Town/City</label> <input class="long" type="text" value="<?php echo $town; ?>" name="town" id="town" /><br><?php echo $town_error; ?></p> <p><label for="county">County</label> <select name="county" class="long"> <option value="">Please Choose County</option> <optgroup label="England"> <option>Avon</option> <option>Bedfordshire</option> <option>Berkshire</option> <option>Buckinghamshire</option> <option>Cambridgeshire</option> <option>Cheshire</option> <option>Cleveland</option> <option>Cornwall</option> <option>Cumbria</option> <option>Derbyshire</option> <option>Devon</option> <option>Dorset</option> <option>Durham</option> <option>East Sussex</option> <option>Essex</option> <option>Gloucestershire</option> <option>Hampshire</option> <option>Herefordshire</option> <option>Hertfordshire</option> <option>Isle of Wight</option> <option>Kent</option> <option>Lancashire</option> <option>Leicestershire</option> <option>Lincolnshire</option> <option>London</option> <option>Merseyside</option> <option>Middlesex</option> <option>Norfolk</option> <option>Northamptonshire</option> <option>Northumberland</option> <option>North Humberside</option> <option>North Yorkshire</option> <option>Nottinghamshire</option> <option>Oxfordshire</option> <option>Rutland</option> <option>Shropshire</option> <option>Somerset</option> <option>South Humberside</option> <option>South Yorkshire</option> <option>Staffordshire</option> <option>Suffolk</option> <option>Surrey</option> <option>Tyne and Wear</option> <option>Warwickshire</option> <option>West Midlands</option> <option>West Sussex</option> <option>West Yorkshire</option> <option>Wiltshire</option> <option>Worcestershire</option> </optgroup> <optgroup label="Wales"> <option>Clwyd</option> <option>Dyfed</option> <option>Gwent</option> <option>Gwynedd</option> <option>Mid Glamorgan</option> <option>Powys</option> <option>South Glamorgan</option> <option>West Glamorgan</option> </optgroup> <optgroup label="Scotland"> <option>Aberdeenshire</option> <option>Angus</option> <option>Argyll</option> <option>Ayrshire</option> <option>Banffshire</option> <option>Berwickshire</option> <option>Bute</option> <option>Caithness</option> <option>Clackmannanshire</option> <option>Dumfriesshire</option> <option>Dunbartonshire</option> <option>East Lothian</option> <option>Fife</option> <option>Inverness-shire</option> <option>Kincardineshire</option> <option>Kinross-shire</option> <option>Kirkcudbrightshire</option> <option>Lanarkshire</option> <option>Midlothian</option> <option>Moray</option> <option>Nairnshire</option> <option>Orkney</option> <option>Peeblesshire</option> <option>Perthshire</option> <option>Renfrewshire</option> <option>Ross-shire</option> <option>Roxburghshire</option> <option>Selkirkshire</option> <option>Shetland</option> <option>Stirlingshire</option> <option>Sutherland</option> <option>West Lothian</option> <option>Wigtownshire</option> </optgroup> </select> <br><?php echo $county_error; ?></p> <p><label for="postcode">Postcode</label> <input class="short" type="text" value="<?php echo $postcode; ?>" name="postcode" id="postcode" /><br><?php echo $postcode_error; ?></p> <p><label for="email">Email</label> <input class="long" type="text" value="<?php echo $email; ?>" name="email" id="email" /></p> <p><label for="telephone_1">Main Telephone</label> <input class="long" type="text" value="<?php echo $telephone_1; ?>" name="telephone_1" id="telephone_1" /><br><?php echo $telephone_1_error; ?></p> <p><label for="telephone_2">Other Telephone</label> <input class="long" type="text" value="<?php echo $telephone_2; ?>" name="telephone_2" id="telephone_2" /></p> <p><label for="fax">Fax</label> <input class="long" type="text" value="<?php echo $fax; ?>" name="fax" id="fax" /></p> <p class="submit"><input type="submit" name="submit" value="next step" /></p> </fieldset> </form>
  4. Thanks people. I will change that inc to php, I forgot that bit and have been aware of that.. thanks again. Right now the problem seems to be with the valid == 1 I changed this to zero and I know that cancels out the error check, but it submitted the data, so my problem is around that area.
  5. As the form is all filled in, its not giving any errors, the errors just to make sure people fill in what is required (further error checking to be done once I get this working ie. email). what is happening now. You fill in the form and hit the submit button and the same page just reloads with the fields in the form filled in with what you typed first. So its stuck for some reason. It is supposed to send the information to a sql query to process into a database, then redirect you to the next page. I am puzzled why it wont?
  6. Yes, the form validation and processing is before the html of the page, and the submit button has the name="submit" which I double checked as thought that might be the case, its just not processing, its error checking and staying on that part? Here is one of the form input fields: <label for="address_2">Address 2</label> <input class="long" type="text" value="<?php echo $address_2; ?>" name="address_2" id="address_2" />
  7. I am using some code I have done before now its been a long day, and I am totally puzzled as to why the form will not send the data to mysql and then move onto the next page, via the header location. At the moment, when I fill the form in and click submit it just stays on the same page and does not process anything. I am not sure why and where the issue is? Any help appreciated to get this moving forward. Here is the code that processes the form to mysql etc.. <? //# Include the connections script to make a database connection. include("inc/connect.inc"); //# The form should post to itself. if ( $_POST['submit'] ) { $valid = 1; $venue_name = $_POST['venue_name']; if ( empty($venue_name) ) { $valid = 0; $venue_name_error = '<div class="formerror">Please Enter your Fishery Venue Name.</div>'; } $address_1 = $_POST['address_1']; if ( empty($address_1) ) { $valid = 0; $address_1_error = 'Please enter the first line of your address'; } $address_2 = $_POST['address_2']; $address_3 = $_POST['address_3']; $town = $_POST['town']; if ( empty($town) ) { $valid = 0; $town_error = 'Please enter your town/city'; } $county = $_POST['county']; if ( empty($county) ) { $valid = 0; $county_error = 'Please select your county'; } $postcode = $_POST['postcode']; if ( empty($postcode) ) { $valid = 0; $postcode_error = 'Please Enter your Postcode'; } $email = $_POST['email']; $telephone_1 = $_POST['telephone_1']; if ( empty($telephone1) ) { $valid = 0; $telephone1_error = 'Please Enter your Main Contact Number'; } $telephone_2 = $_POST['telephone_2']; $fax = $_POST['fax']; // End of error checking, all fields covered. if ( $valid == 1 ) { # setup SQL statement $SQL = " INSERT INTO dbtable "; $SQL = $SQL . " (venue_name, address_1, address_2, address_3, town, county, postcode, email, telephone_1, telephone_2, fax) VALUES "; $SQL = $SQL . " ('$venue_name', '$address_1', '$address_2', '$address_3', '$town', '$county', '$postcode', '$email', '$telephone_1', '$telephone_2', '$fax') "; #execute SQL statement $result = mysql_db_query( *****,"$SQL",$connection ); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } { header("Location: http://www.domain.com/admin/admin.html"); exit; } } } ?> The form is pretty standard, here is the action form action part of the form: <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  8. I have been working with Minase off here to get a script functioning, and we have it working fine in firefox and safari etc.. but there seems to be issues with internet explorer and the script is not functioning in that browser. It seems it is an inner html issue. I am very new to ajax and my javascript is limited, but Minase has been assisting me, but is not around, and I have a deadline of today. I just need to get this working in internet explorer, can anyone please help. here is the ajax code for the script. function get_XmlHttp() { var xmlHttp = null; // if a native XMLHttpRequest object exists if ( window.XMLHttpRequest ) { xmlHttp= new XMLHttpRequest; } else { // let's try an ActiveXObject try { xmlHttp= new ActiveXObject("MSXML2.XMLHTTP.6.0"); } catch(ex) { xmlHttp= new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function ajaxrequest(tagID,post) { var http = get_XmlHttp(); var info = 'request='+post; http.onreadystatechange = function() { if (http.readyState == 4) { document.getElementById(tagID).innerHTML = http.responseText; } } http.open("POST", 'destinations.ajax.regions.php', true); // edit php.php to your actual php file path http.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http.send(info); }
  9. Hi again, nothing is appearing in that second menu at all still. I will send you a message with the url, due to security etc..
  10. Hi Minase, The first menu is fine, it loads around 15 different locations. Now when I select the location it does not populate anything in the second menu, it just stays blank. Just another question which may throw a spanner in the works. What I need after the selections is to still be able to submit the data to query on another page for results. When you say change the php file, is this just at the top section? dont understand using that new code.
  11. Hi Minase.. sorry to take up your time appreciate the help as been stuck on this all day. I have changed it to the actual file path for index.php but it is still not doing anything in the second drop down. I know that a few locations have bed and breakfast, but nothing appearing. Do we still need the actual form to post? Just noticed that has been stripped out.
  12. Hi is it the index.php or the other file?
  13. Many thanks for the help. It is not loading anything into the second menu, I know for example one of the fields has bed and breakfast in, but it is not loading anything into that second drop down.
  14. Hi Minase, Here is the index page with the form on, and also the new php code for the form that is pulled in, the ajax code has not changed so wont post that up. 1: index page with the form <? include("inc/connect.inc"); ?> <html> <head> <script type="text/javascript" src="ajax.js"></script> </head> <body> <form action ="search_results.html" method=post> <div id="dropdownregion" class="leftmenu"> <select name="region" style="width: 196px; margin-bottom: 2px;" class="userinput" onchange="postAjax_RequestString('/dropdown/destinations.ajax.regions.php', 'strLocationRefs=' + this.value, 'dropdownregion')"> <? $sql = "select distinct region from clients ORDER BY region ASC"; $makes_result = mysql_query($sql); while($row = mysql_fetch_row($makes_result)) { print("<option value=\"$row[0]\">$row[0]</option>\n"); } ?></select> <div id="type" class="leftmenu"> <select name="type" style="width: 196px; margin-bottom: 2px;" class="userinput"> <option value="">- Type -</option> <? echo "$type_options";?> </select> </div> </div> </form> </body> </html> The php page with the query etc. <?php include("inc/connect.inc"); /* $strLocationRefs = numberFormat($_POST["strLocationRefs"], 0); */ $variable = $_POST["strLocationRefs"]; $sql = "select * from clients WHERE region = '" . $variable . "' "; $sql_result = mysql_query($sql); while ($row = mysql_fetch_array($sql_result)){ $bed_and_breakfast = $row["bed_and_breakfast"]; $type_options .= "<option value=\"$bed_and_breakfast\">$bed_and_breakfast</option>"; } echo $type_options; ?> Thanks for your kind help.
  15. Dennis I dont know enough yet on ajax to use jquery, but hopefully that will come with experience. Hi Minase Thanks for the reply, I am not getting errors now, so thats a start. I am not sure I have the actual form page set up correct, as now when you select the location it is redirecting but then I completely lose the first menu and the second menu? It just dissapears and leaves a blank page?
  16. I have never dealt with ajax before, but someone has kindly sent me code to work with. This is my situation and what I am trying to achieve. I have 2 drop down menus. The first menu is populated with locations taken from the database, they are pulled into the drop down using distinct, to just list all locations in order. Now I need the second menu to populate based on what they select in the first, I have kept it simple for now to get it working. My problem is that I am getting mysql errors, but I think this is due to the way I have this set up. I have 3 files for this, the index page which has the form, an ajax script and finally a php file to process and get the results for the second drop down. Having never done this before I feel I have it wrong, as I am getting errors all the time. My code is below. Please can anyone assist me, really desperate as spent all day trying different things. 1: The index page with the form <? include("inc/connect.inc"); ?> <html> <head> <script type="text/javascript" src="ajax.js"></script> </head> <body> <form action ="search_results.html" method=post> <div id="dropdownregion" class="leftmenu"> <select name="region" style="width: 196px; margin-bottom: 2px;" class="userinput" onchange="postAjax_RequestString('/dropdown/destinations.ajax.regions.php', 'strLocationRefs=' + this.value, 'dropdownregion')"> <? $sql = "select distinct region from clients ORDER BY region ASC"; $makes_result = mysql_query($sql); while($row = mysql_fetch_row($makes_result)) { print("<option value=\"$row[0]\">$row[0]</option>\n"); } ?></select> <div id="type" class="leftmenu"> <select name="type" style="width: 196px; margin-bottom: 2px;" class="userinput"> <option value="">- Type -</option> <? echo "$type_options";?> </select> </div> </div> </form> </body> </html> 2: The php form that is used to get the results for the second menu <?php include("inc/connect.inc"); /* $strLocationRefs = numberFormat($_POST["strLocationRefs"], 0); */ $sql = "select * from clients WHERE $region = 'region' ORDER BY type ASC"; $sql_result = mysql_query($sql); if (mysql_num_rows($sql_result) ==0) { echo (" <p>An error Occured</p>\n"); } else { while ($row = mysql_fetch_array($sql_result)){ $bed_and_breakfast = $row["bed_and_breakfast"]; } $type_options .= "<option value=\"$bed_and_breakfast\">$bed_and_breakfast</option>"; } echo $type_options; ?> Finally the ajax code //Ajax functionality function sendHttpRequest(url, reqstr, objx){ http_request = false; if(window.XMLHttpRequest){ // Mozilla, Safari, Opera 8.0+, Firefox... http_request = new XMLHttpRequest(); if(http_request.overrideMimeType) { // set type accordingly to anticipated content type // http_request.overrideMimeType('text/xml'); http_request.overrideMimeType('text/html'); } }else if(window.ActiveXObject){ // IE try{ http_request = new ActiveXObject("Msxml2.XMLHTTP"); }catch(err){ try{ http_request = new ActiveXObject("Microsoft.XMLHTTP"); }catch(err){} } } if(!http_request) { alert('Cannot create XMLHTTP instance'); } http_request.onreadystatechange = function(){ if(http_request.readyState == 4){ var ajaxDisplay = document.getElementById(objx); ajaxDisplay.innerHTML = http_request.responseText; } } http_request.open("POST", url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", reqstr.length); http_request.setRequestHeader("Connection", "close"); http_request.send(reqstr); } function postAjax_RequestForm(url, fieldId, objx){ var reqstr = ""; var fieldArr = fieldId.split(","); for(i=0 ; i < fieldArr.length; i++){ reqstr += fieldArr[i] + "=" + document.getElementById(fieldArr[i]).value + "&"; } sendHttpRequest(url, reqstr, objx); } function postAjax_RequestFormNames(fObj, url, fieldId, objx){ var reqstr = ""; var fieldArr = fieldId.split(","); for(i=0 ; i < fieldArr.length; i++){ objval = eval("document." + fObj + "." + fieldArr[i] + ".value"); reqstr += fieldArr[i] + "=" + objval + "&"; } sendHttpRequest(url, reqstr, objx); } function postAjax_RequestString(url, reqstr, objx){ sendHttpRequest(url, reqstr, objx); } function postAjax_ClearObject(reqstr, objx){ var ajaxDisplay = document.getElementById(objx); ajaxDisplay.innerHTML = ''; } Any help please to get this working.
  17. Sorry just noticed a problem my fault the following was incorrect while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { should have been while($row = mysql_fetch_array($sql_result, MYSQL_ASSOC)) { Am now getting results back and they look fine to me having multiple updates. They seem to work fine now I have fixed that problem, no wonder I was getting nothing returning. Thanks cags, have now got this working.
  18. I have tried to echo out the result, but its showing nothing at all on the page? No error, no result nothing?
  19. Thanks cags... I changed that before, but just done again and getting no errors but the stock is not changing, I have a feeling I have this set up wrong for what it needs to do
  20. The bottom bit was in error please ignore this section ***** in are stored with the php session as the grouping tool to keep all the orders together. The customer can order any of the 20 items or all of them if they wish. Each item in the ******* I have been reading and it seems sum is what I need to look at, but not sure how to work it
  21. I have built an ordering system and trying to get the values in the stock level field to change based on customers ordering. The set up is as follows: 1 table called 'products'. There are 20 items in the table and all have a stock level field with number values. I then have another table which stores the customers orders as they use the ordering system this table is called 'orders' The table called 'orders' uses a php session to identify the customer and their order. The customer can order any or all of the 20 items from the 'products' table. Each item though has an option for the quanity. The customer can enter any quantity for the item. The quantity is stored in a field in the 'orders' table. Once the customer has finished they go to the checkout page and enter some personal information and then submit the order. SOLUTION NEEDED???? What I need is that when the submit the order the quantity of each of the items they ordered needs to be subtracted from the 'products' table. The field 'stock_level' is what needs to be updated so that the numbers are correct. The identifier for each table is a field called 'pnumber' this contains a unique number for each product. I do not know how to perform this, I have tried the following which I know is completely wrong, as this is above my sql skill level, its the first time I have been stumped, somebody out there will have a solution or point me in the right direction. here is the code I tried which does nothing $sql = "SELECT * FROM orders WHERE sid = '$PHPSESSID' "; $sql_result = mysql_query($sql); if (mysql_num_rows($sql_result) ==0) { header("Location: http://www.*****.co.uk/index.php"); exit; } else { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $pnumber = $row['pnumber']; $qty = $row['qty']; $SQL = " UPDATE products SET stock_level = stock_level - '$qty' WHERE pnumber = '$pnumber' "; #execute SQL statement $result = mysql_db_query( *****,"$SQL",$connection ); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } } } in are stored with the php session as the grouping tool to keep all the orders together. The customer can order any of the 20 items or all of them if they wish. Each item in the
  22. I had also tried that, but it is still not deducing the stock level number. That is what I am stuck on getting it to reduce. I dont get any errors either though??
  23. I have a site set up where customers come in order multiple products in numbers and then place an order. What I am trying to do is reduce the stock levels in the literature table from the results of the ordering table. The set up I have is. One table with all products in, there are 20 products in here. The products table has a field for the stock levels that the client controls. They can adjust this as they see fit via a cms, but I need the levels to adjust as people order. The orders are stored in a session, the orders table has a qty field in that the user chooses, so say they order 200 items of product A and 150 items of product B. I need to query the database and adjust the stock levels. I am unsure how to do this. Here is my code so far, which I probably assume is totally incorrect, as nothing is happening. I am no guru. $sql = "SELECT * FROM orders WHERE sid = '$PHPSESSID' "; $sql_result = mysql_query($sql); if (mysql_num_rows($sql_result) ==0) { header("Location: http://www.*****.co.uk/index.php"); exit; } else { $SQL = " UPDATE literature SET stock_level = 'stock_level' - '$qty' WHERE pnumber = '$pnumber' "; #execute SQL statement $result = mysql_db_query( *****,"$SQL",$connection ); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } } I know I have not got this right, just trying to understand how to sort this, have read and read all day long.
  24. Sorry to bug people with this one, just need it sorting asap. What its doing is not uploading as it see something in the database, in the database with be either 3 things, the letter A or the letter B or YOUCHOOSE!! help!!!!
  25. the database is updated also via another script which just inserts the A or B into the field in mysql. But because it does this, if the user tries to upload a picture it does not let them as it thinks its there already.
×
×
  • 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.