There were several different ways to verify the card.
On The Spot
ID: Merchants could ask for an ID to match the name on the card to the name on the face. That didn't always work (especially in the US) because not everyone carries ID with them, or even has any.
Signature: The merchant would try to match the signature on the back of the card to the signature on the slip. The customer had to sign the card when it was delivered to them and provide a signature card to the issuer to verify the signature, similarly to checks.
We still have signature strips on cards until this very day, even though no-one ever bother to check them anymore because they're no longer authoritative (you apply for a card online, they don't actually have a signature sample for you anymore).
Lists of Cancelled Cards: These were published regularly by the processors, but they were not exhaustive or updated online. So you'd get a huge book (like a telephone book, remember those?) to go through to see if the card number is in there, and if it is - you'd refuse to accept it. If it isn't - it might show up in the next one, but you wouldn't know because it just got stolen.
Calling the Processor
Merchants could call their card processor to request what is called "authorization code". The processor would then call (later - communicate online) the issuer to verify the card is valid, the credit is available, get the issuer's authorization code and then provide the authorization code to the merchant. The merchant would write the authorization code on the slip as evidence that the transaction was authorized.
In some cases they'd call and the card was actually reported stolen or forged. In this case they'd get a response from the processor asking them to destroy the card on the spot. Nowadays they don't do it anymore and instead just send a "Decline" response, but I still remember days where merchants would take scissors and cut stolen cards because the processor told them to (I was working for a credit card processor for a while early in my career). The processors stop doing that because it was putting merchants at risk, but until then merchants had to comply if they wanted their indemnification.
Each merchant has a transaction value limit above which they must get an authorization code to be indemnified in case of fraud.
What Happens Nowadays
Nowadays almost no-one does physical on-the-spot verification. Lists of cards and calling the issuer are still there and are used for magnetic strip transactions (most cases instead of a phone call by a person it would be done through an online internet connection by the cash register computer itself, making it much faster). The lists of cancelled cards are now also updated online, but they're still not exhaustive (usually only have the cards cancelled recently, since otherwise the list would grow endlessly).
Newer cards with chips allow verification of the card itself on the spot, but still don't answer the questions "is the card stolen" or "is the credit available for this purchase", for which a communication to the processor has to be made. But it does allow limiting communications to higher values, making low-value purchases go faster and smoother.