Jump to content

ale1981

Members
  • Posts

    65
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ale1981's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks, I knew there would be a regex way, I am just useless when it comes to regex! I am guessing the .replace is quicker as it is done with one function?
  2. sorry, yes, i would like the string 'products.0.name' converted to string 'products[0][name]'
  3. I have a string e.g. products.0.name and I want to change the string to; products[0][name] I have come up with some code that works but is a bit of a hack, my code is below; var array = field.split("."); field = array[0]+'['+array[1]+']['+array[2]+']'; Is there a better way, I am sure there is using regex? Thanks
  4. Thanks for the detailed response. I am adding the fields dynamically so I do not know how many the user is going to have, I guess I could use a bit of JS to determine this. Yes the SQL query will be one query, I used the above as an example of what I needed. Thanks for all responses.
  5. Thanks Ch0cu3r that worked, I knew there would be a simple answer! I have 2 input fields that use the same variable array, e.g. <input type="text" name="productVariations[name][]" /> <input type="text" name="productVariations[price][]" /> Is there a different way?
  6. It's late in the day and I can't figure this one out, I know it's going to be pretty easy! I have a form which sends the following array; array:2 [▼ "names" => array:3 [▼ 0 => "Default" 1 => "100ml" 2 => "150ml;" ] "prices" => array:3 [▼ 0 => "12.99" 1 => "9.99" 2 => "14.99" ] I want to loop the array and do an insert using this array like so, the index from "names" and "prices"; INSERT INTO DB VALUES('Default',12.99); INSERT INTO DB VALUES('100ml',9.99); INSERT INTO DB VALUES('150ml',14.99); Thanks
  7. Hi BlueSky I have since amended the files, i have removed session_id() and the second instance of session_start() in the function. I used the session_save_path to make sure the session files were being created. With more testing, if I call the function get_user_details() every time in the header.php file then $_POST works fine, however if i only call it once to store the user details then $_POST doesnt work!? Is it something inside the function that is authenticating?
  8. New update! I think it is something in the function affecting $_POST. I have removed the function call and tried to create a session and everything seems to work, what in the function could be affecting the $_POST details, could it be the header calls?
  9. Sorry by break I mean that $_POST is always empty. If i remove; session_save_path($_SERVER['DOCUMENT_ROOT']. 'tmp/sessions'); session_id(); session_start(); from the top of my header.php file then $_POST works again!
  10. UPDATE: This breaks $_POST on all pages, however $_GET seems to work fine, this is giving me a huge headache!
  11. PHP 5.2.6 Apache 2.2.9 I am trying to store windows username / domain / workstation details into a session for our company intranet. I found a script on the internet that I can use to retrieve the information which I made into a function; function get_user_details() { // loune 25/3/2006, updated 22/08/2009 // For more information see: // http://siphon9.net/loune/2007/10/simple-lightweight-ntlm-in-php/ // // This script is obsolete, you should see // http://siphon9.net/loune/2009/09/ntlm-authentication-in-php-now-with-ntlmv2-hash-checking/ // // NTLM specs http://davenport.sourceforge.net/ntlm.html $headers = apache_request_headers(); if (!isset($headers['Authorization'])){ header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: NTLM'); exit; } $auth = $headers['Authorization']; if (substr($auth,0,5) == 'NTLM ') { $msg = base64_decode(substr($auth, 5)); if (substr($msg, 0, != "NTLMSSP\x00") die('error header not recognised'); if ($msg[8] == "\x01") { $msg2 = "NTLMSSP\x00\x02\x00\x00\x00". "\x00\x00\x00\x00". // target name len/alloc "\x00\x00\x00\x00". // target name offset "\x01\x02\x81\x00". // flags "\x00\x00\x00\x00\x00\x00\x00\x00". // challenge "\x00\x00\x00\x00\x00\x00\x00\x00". // context "\x00\x00\x00\x00\x00\x00\x00\x00"; // target info len/alloc/offset header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: NTLM '.trim(base64_encode($msg2))); exit; } else if ($msg[8] == "\x03") { function get_msg_str($msg, $start, $unicode = true) { $len = (ord($msg[$start+1]) * 256) + ord($msg[$start]); $off = (ord($msg[$start+5]) * 256) + ord($msg[$start+4]); if ($unicode) return str_replace("\0", '', substr($msg, $off, $len)); else return substr($msg, $off, $len); } $user = get_msg_str($msg, 36); $domain = get_msg_str($msg, 28); $workstation = get_msg_str($msg, 44); session_start(); $_SESSION['username'] = $user; $_SESSION['domain'] = $domain; $_SESSION['workstation'] = $workstation; } } } What i would like to do is store the information in a session so I can access the information without having to call the function on every page. I have a header.php file which is called on each page, so in this file i have added; require_once 'functions.php'; session_id(); session_start(); if (!$_SESSION['username']) { get_user_details(); } This works, but seems to be breaking certain pages that retrieve $_POST details but I can not figure out why?? I have tried to work it out for the past 3 days but cant seem to get it to work, any help would be greatly appreciated!
  12. SOLUTION for anybody interested; <table> <?php while ($ord_inf = mssql_fetch_array($result)) { if($lastOrderNo != $ord_inf['ORDERNO'] || $lastOrderNo == "") { $trclass = ($trclass == 'alt2') ? 'alt1' : 'alt2'; } $lastOrderNo = $ord_inf['ORDERNO']; ?> <tr class="<?php echo $trclass; ?>"> <td><?php echo $ord_inf['ORDERNO']; ?></td> </tr> <?php } ?> </table>
  13. Hi, thanks for your reply but all rows end up the same colour, using alt1.
  14. I can not figure this out, what I want to do is alternate the row colour of a table depending on a variable when looping through results from a db query, example; ORD123 ORD123 ORD124 and so on.. <table> $trclass = 'alt1' $trclass = 'alt2' while ($ord_inf = mssql_fetch_array($result)) { if ($ordinf['ORDERNO'] == $orderNo) { 'keep same tr class as its the same order' } else { 'its a different order so change the tr class' } <tr class="$trclass"> <td>$ord_inf['ORDERNO']</td> </tr> $orderNo = $ord_inf['ORDERNO']; } </table> something like that, i just cant seem to get it to work! any help appreciated... [/]
  15. Thanks obsidian, works great; foreach ($groupID as $k => $v) { $groupID[$k] = '"' .$v. '"'; } $groupNos = implode(',', $groupID); echo $groupNos;
×
×
  • 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.