Php if orderID exists give new order number

I am having a trouble with a shopping cart i am setting up. basically if the order is processed sucessfully it returns a value to the database of PAID and next time the order is placed a new orderID is issues, however when the order fails it return the result FAILED, what is happening is when you try to re order it is issuing the same orderID as the failed orderID do when the user try to proceed the the gateway i am getting a DUPLICATE ID error. on the failed-order.pho i have killed the orderID (session_unregister("OrderID");)
this is what i thought i would need to do so when the user is sent to failed-order.php this would kill the session then give the user a new orderID?
I have included the script on the checkout page ( only the parts relating to the orderID)
// *** Retrieve X ID ***
if (!session_id()) session_start();
$XC_OrderIdSessionVar = "OrderID";
if (!isset($_SESSION[$XC_OrderIdSessionVar])) {
  // Get a unique OrderID number and save to session.
  $XC_tableName = "LOTTIE_nextorder";
  $XC_fieldName = "NextOrderID";
  mysql_select_db($database_lotties, $lotties);
  $XC_IdSource = "select " . $XC_fieldName . " from " .  $XC_tableName;
  $XC_rsId = mysql_query($XC_IdSource, $lotties) or die(mysql_error());
  $row_XC_rsId = mysql_fetch_assoc($XC_rsId);
  $_SESSION[$XC_OrderIdSessionVar] = $row_XC_rsId[$XC_fieldName];
  $$XC_OrderIdSessionVar = $_SESSION[$XC_OrderIdSessionVar];
  session_register($XC_OrderIdSessionVar);
  $XC_next = $_SESSION[$XC_OrderIdSessionVar] + 1;
  $XC_upd = "update " . $XC_tableName . " set " . $XC_fieldName . " = " . $XC_next;
  $XC_rsId = mysql_query($XC_upd, $lotties) or die(mysql_error());
  $XC_rsId = null;
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO LOTTIE_orders (OrderID, CustomerID, OrderDate, Shipping, Discount, Tax, Total) VALUES (%s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['OrderID'], "text"),
                       GetSQLValueString($_POST['CustomerID'], "int"),
                       GetSQLValueString($_POST['OrderDate'], "date"),
                       GetSQLValueString($_POST['Shipping'], "double"),
                       GetSQLValueString($_POST['Discount'], "double"),
                       GetSQLValueString($_POST['Tax'], "double"),
                                                     GetSQLValueString($_POST['XC_Amount'], "double"));
// *** Save XCart contents to table ***
require_once('XCInc/XCsaveAction.inc');
if (isset($_GET['XC_SaveCartToTable']) && ($_GET['XC_SaveCartToTable'] == "1")) {
  $XC_destColName = array("ProductID","Quantity","","","Total");
  $XC_destColType = array("str","str","str","num","num");
  $XC_orderId = $_SESSION['OrderID'];
  $XC_tableName = "LOTTIE_orderdetails";
  $XC_OrderIDCol = "OrderID";
  $XC_OrderIDType = "num";
  $XC_AddToTableRedirect = "../HostedSample/Process.php?$x_reqstr";
  $XC_conName = "lotties";
  require_once('XCInc/SaveXCartToTable.inc');
  mysql_select_db($database_lotties, $lotties);
  $Result1 = mysql_query($insertSQL, $lotties) or die(mysql_error());
what do i need to do to rectify this issue
thanks in advance

I have found another issue with this though, basically when the user clicks through to the gateway they send the orderID to the database, then they land on the gateway page and if they decide to you the back button then return to the checkout page they are still on the same orderID so if they try to use this again they are shown the duplicate key, what is the best method to overcome this and issued a new orderID?
thanks

Similar Messages

  • Please cancel my order and give refund, order number correction in this one

    Hi,
    There was a missing zero, this is the correct order number:
    Please cancel Order number : AD001157755EDU
    And Refund.
    Thanks

    Hi angrylion,
    Kindly contact our chat support:http://helpx.adobe.com/x-productkb/global/service-b.html
    Regards,
    Florence

  • How to give two spaces after new order in alv

    hi
    my issue is after every new order number they need two blank spaces, i know the procedure of giving new page for every new order but they need only two blank lines. (This is in ALV List format).
    second thing is how to give footer
    thanks

    hi
    use this variant of appendf for inserting blank lines
    Append INITIAL LINE TO ITAB.
    Effect
    Appends a new line to the end of the internal table itab. You can only use this variant with index tables (standard or sorted table).
    If you specify wa TO , the new line is taken from the contents of the explicitly specified work area wa.
    If you use INITIAL LINE TO, a line filled with the correct initial value for the type is added.
    If the part before itab is omitted, the new line is taken from the header line of the internal table itab.
    If you use the ASSIGNING <fs> addition, the field symbol, <wa>, points to the line you have just appended. If you use the REFERENCE INTO ref addition, the data reference, dref, is filled with the reference of the line you have just appended.
    If the target table itab is a SORTED TABLE, it must be sorted correctly after the append, otherwise a runtime error results.
    After the statement has been executed, the system field SY-TABIX is filled with the index of the last line in the table.
    Cheers
    Snehi

  • Stock transfer of QM stock thereby creating a new batch number

    Dear Experts,
    I have searched for this content but didn't get content which match my requirement.
    My client has placed a requirement.When they receive a material against a purchase order through movement type 101 they receive it to quality inspection stock.After quality inspection this material is taken to unrestricted area through movement type 321.
    Now after this material comes to unrestricted area,this material is again subject to quality inspection.Quality testing is done after a particular period.
    Next quality testing date is calculated based on this formula:-321 movement type posting date + quality inspection interval days maintained in material master.
    i.e:-If for a material 321 movement type is 16th July 2014 & if quality inspection interval days for that material is maintained as 365 days then next quality inspection of that material will be after a year.
    Now client has placed a requirement when this material comes to quality testing,15 days prior to quality testing this material should move to quality inspection area from the present unrestricted area thereby generating new batch number for that material.
    This changes the client will view in MMBE.
    Gurus Please help as I'm new to QM.
    Kind regards,
    Pradeesh.P

    Hi,
    This is not possible,you cannot generate a new batch number through recurring inspection.
    If you require a new batch number then during stock posting in UD you post it to new material,in your
    case this will be the same materiaal and you give new batch number.
    In this way a batch material has come for inspection and after inspecting it you are changing the
    batch number of the material.
    CSN

  • Internal order number ranges

    Hi gurus
    I moved my new Order type into QE and also the new number range to be used with this new Ordertype.
    However when I look in the "Define Order type" configuration , the number range interval is "Not assigned".
    If I go into "Maintain Number Ranges for Orders" and add my new order number interval
    on transction KONK and click on  Interval > transport, I get the message..
    " In the target system, all intervals          of selected number range object are         
    deleted first so that only the exported      intervals exist after the import.           
    The number statuses are imported with    the value that they had when exported       
    Dependent tables are not transported or     
    converted.                                                                               
    Do you want to transport the intervals?     
    Yes...NO  cancel.
    When I click Yes It is prompting for transport. My question, IF I move this transport into target client, will SAP erase all number intervals?, I am not sure as  how to assign my new number interval for my new Internal Order type.
    Many thanks in advance.
    MSJ

    HI,
    In case of internal order, the number ranges are not transported to QA or Prod servers we have to configure the number ranges. After the transport
    With Regards
    Babu
    Edited by: Babu on Feb 27, 2009 2:46 AM

  • Process Order Number Range

    Hi Gurus,
    How do you exactly add/create Number Range Groups for process orders?
    Thanks,
    Kumar

    Hi Kumar,
    Assigning number range
    There are two types of number assignment:
    Internal
    When saving a data record, the SAP System assigns a sequential number that lies within the corresponding number range interval.
    External
    When saving a data record, either you or an external system assigns a number. You need to ensure that the number lies within the corresponding number range interval.
    In CO82..
    Menu path Group -->maintain
    In maintain number range group screen,
    Group --> insert
    Give text and from number and to number
    say text = new order say For FG
    range - 1xxxxxxxxx to 1999999999999 (tick ext check box if the range is external number range-manual input)
    click on +
    You can see your group at the end of list
    In Not assigned group your new order type will be present
    Place the curser on that order type and fallow the menu path as below
    Edit -->select element
    Select NEW order number range group check box
    edit --> assign element group.
    Now the number range is assigned to the order type. Save it, You will get a pop up, just ignore it.
    Please try and come back.
    Regards
    R.Brahmankar

  • I was charged for activating a new prepaid number, but still be told the number is not activated. I even don't know where to call to ask for refund because everytime I call a representive they will transfer me to another, and keep waitiing without respons

    The customer service is a nightmare`

    They also give me order number which can not be verified through the website system

  • Why after new changes in internal orders settings order number ranges lost?

    Dear Gurus,
    We have noticed that order number ranges are being lost from time to time.
    Than we have analysed that sometimes it happens after new transfers with new orders settings.
    Why the system behaves like that?
    And how can we avoid this problem?
    With best regards,
    Kamila.

    The process is as below to assign/change number ranges to order types
    Create Order type at KOT2 (KOT2_OPA) and enter Order Category ...say 01
    Enter Order type name and description and SAVE
    Select Number range Interval assingment Icon
    At last row of the number range screen you can see your newly created Order Type
    (Put the cursor on your order type and press F2) and Select the check box of group under which you need to assign and press F5
    Now the newly created order type has been assigned and new number range has been assigned
    So you can change existing order type also as mentioned above (even after posting made to that order types)
    This could be the reason for changing number ranges to order types
    Please take care while assigning number ranges to a new order types.  Do not touch number ranges of existing order types
    Srinivas

  • My old phone number is stuck on my ipod touch and I am trying to put my new phone number in but it will give me no place to do it. I have looked up all support reset things made sure my new number was attached to my apple id and still

    I have an IPOD Touch and it had my old phone number in it, I have tried absolutely everything listed on the community support that I could find, restoring factoro settings restarting phone logging out of facetime and imessage but it wont allow my to put in a new phone number even though on my apple id there is a phone number it will not correspond with the new number it doesn't give me even an option for a phone number now just email. Can someone please help me THANKS

    Where is the phone number on the iPod?
    If you have an iPhone with iOS and use the same ID for Messages and FaceTime as on the iPod the iPhone's phone number will be listed for Messages and FaceTime on the iPod.
    If you changed phone numbers on the iPhone, sign out of Messages and FaceTime and then sing back in. Then do the same a little while later on the iPod.
    For some info see:
    iOS: About Messages

  • I downloaded Lightroom version 5.7 in order to support tethered capture on my Nikon D750 and its still not working. Additionally when I was prompted to give my serial number for the update it was no where to be found on my Adobe profile although I purchas

    I downloaded Lightroom version 5.7 in order to support tethered capture on my Nikon D750 and its still not working. Additionally when I was prompted to give my serial number for the update it was no where to be found on my Adobe profile although I purchased, and am paying monthly for my creative cloud for photography. Please help

    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page
    If yes
    Some general information for a Cloud subscription
    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp
    -http://helpx.adobe.com/creative-cloud/kb/license-this-software.html
    If no
    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • I have purchased Adobe Acrobat and my order number is 281998924. My previous Sony computer which used to Windows 7 crashed. I purchased a new Toshiba computer with Windows 8. How can I download the Adobe acrobat? I assume I don't have to pay for the progr

    I have purchased Adobe Acrobat and my order number is 281998924. My previous Sony computer which used to Windows 7 crashed. I purchased a new Toshiba computer with Windows 8. How can I download the Adobe acrobat? I assume I don't have to pay for the program again? Thank you for all your help! Angelo.

    If you had purchased Acrobat Standard subscription.
    You need to download the application from below website :
    www.cloud.acrobat.com
    Sign in with Adobe ID and Password and once signed in click on Acrobat tab and download the application.
    Sign in - Adobe ID

  • Internal Order number is copied while cretaing new SC from Old PO

    Hi,
    We are on SRM 5.0. When i tried to create a new shopping cart through by copying the old shopping cart from 'Old Purchase Orders and templates' the Internal Order number is also being copied which is a problem.
    I appreciate any help.
    Thank you

    Hi..
    Thanks for the response. Yes we are using using internal order(IO) in account assignment.
    This creates a problem, because the approver is unable to identify if the PR is  one which is already approved that was rejected by someone else (so therefore doesn't need a new IO), or whether it's a brand new PR that needs a new IO.
    So is there someway so that the cost assignment does NOT get copied onto the new PR? Any relevant BADI's that can be used ?
    Thanks.

  • I have an old version of the Logic in cds. Can I just download a new version and give the serial number so I don't have to pay twice?

    I have an old version of the Logic in cds. Can I just download a new version and give the serial number so I don't have to pay twice?

    No..
    You cannot download any version of Logic that you bought on CDs.... You must reinstall it using the disks that came with the boxed set.
    The only downloadable version now is Logic Pro X....which, like everyone else.... you must buy via the App Store... as it is a new version and there is no upgrade from any other version.

  • Where are my order number and new number?!

    So I ordered a sim card kit and go phone plan. And I never receive any email about my order numbers and new phone number. I thought my order didn't went through. So I checked my bank statement saying at&t took out the amount I paid for the stuff I bought. But where are my order number? And when I called customer service, they put me on hold for over 20 minutes. I called them 3 times and all they did was put me on hold or transferred my calls to this department and then they hung up me. I'm over here, clueless about my order.

    Hi there
    I’m sorry to hear you have not received a confirmation of your order! I’d be happy to help! Can you please send me a private message by Clicking Here and include the following information?
    Full name
    Cell number
    Best time to reach you
    Thanks,
    Charise

  • Non existent order number in, "My Orders!" Frustrated!

    So frustrated! My iphone 6 plus order number doesn't exist when i click in "My Orders," yet my internet order number that was emailed to me continues to read "Processing." Anyone know what to do?

        I can understand why you're concerned KKarma, but I assure you there's no need to be. The order will not show in My Verizon until it ships and there's a tracking number for it. You can check the status here http://bit.ly/RjmCUB. You will see it's processing until it ships as well.
    AdaS_VZW
    Follow us on Twitter at @VZWSupport 

Maybe you are looking for