I inserted the default value for $custid = 0; before the first 'if'. It worked.
However, my previous carts are not emptied and there's a problem with the total - it only gives the total of the last cart.
And it's now giving this error :
Notice: Undefined variable: customers_custnum in C:\Xamp\htdocs\chapter15\checkout3.php on line 96
(which is '$total', )