I need help..Even after doing extensive research and youtube videos.. I can't seem to get this. This is just for a hypothetical situational based project i'm doing to demonstrate the functionality of storing fake credit card info in a mySQL database from a PHP file. The goal is: Once a user inputs their "credit card info" they hit "remember card" and after they hit submit button, their info gets saved in the database i created but i can't figure out how to connect them...

payment.php

<div class="wrapper">
  <div class="payment">
        <div class="payment-logo">
      <p>P</p>
    </div>
<h2>Payment Gateway</h2>
<div class="form">
  <div class="card space icon-relative">
    <label class="label">Card holder:</label>
    <input type="text" class="input" placeholder="Coding Market">
    <i class="fas fa-user"></i>
  </div>
  <div class="card space icon-relative">
    <label class="label">Card number:</label>
    <input type="text" class="input" data-mask="0000 0000 0000 0000" placeholder="Card Number">
    <i class="far fa-credit-card"></i>
  </div>
  <div class="card-grp space">
    <div class="card-item icon-relative">
      <label class="label">Expiry date:</label>
      <input type="text" name="expiry-data" class="input"  placeholder="00 / 00">
      <i class="far fa-calendar-alt"></i>
    </div>
    <div class="card-item icon-relative">
      <label class="label">CVC:</label>
      <input type="text" class="input" data-mask="000" placeholder="000">
      <i class="fas fa-lock"></i>
    </div>
  </div>
  <div class="btn">
    Pay
  </div> 
   <!-- Checkbox for storing credit card info -->
  <label class="container">Yes, I would like my credit card information stored for future purchase.
    <input type="checkbox" checked="checked">
    <span class="checkmark"></span>
  </label>
</div>
<style>

database

CREATE TABLE Patient_Payment
(
    Pat_ID int PRIMARY KEY,
    Patient_Last varchar(15),
    Patient_First varchar(15),
    Patient_MiddleInt varchar(1),
    Patient_Bal float(8),
    Patient_PaymentType varchar(15),
    Patient_PaymentNumbers varchar(19),
    Patient_PaymentExpiration varchar(5)

FOREIGN KEY (Pat_ID) REFERENCES Patient_info(Patient_ID)

);
INSERT INTO Patient_Payment VALUES(12345,'Ramas','Bob','A','0','VISA', '9678-4567-0987-3245','09/22');
INSERT INTO Patient_Payment VALUES(12346,'Caster','Leona','K','50.25','MASTERCARD','8930-2803-0289-9284','03/23');
INSERT INTO Patient_Payment VALUES(12347,'Smith','Kathy','W','345.86','VISA','8300-9379-2000-2259','02/24');
INSERT INTO Patient_Payment VALUES(12348,'Miher','Paul','F','536.75','AMERICANEXPESS','2777-038920-11190','01/22');
INSERT INTO Patient_Payment VALUES(12349,'Orlando','Myron','','0','DISCOVER','9990-3459-2018-0009','02/22');
INSERT INTO Patient_Payment VALUES(12350,'O''Brian','Amy','B','0','VISA','2803-3399-0294-1212','09/22');
INSERT INTO Patient_Payment VALUES(12351,'Brown','James','G','221.19','AMERICANEXPRESS','2777-456783-25690','06/22');
INSERT INTO Patient_Payment VALUES(12352,'Williams','George','','768.93','PAYPAL','3983-8974-9200-9129','04/23');
INSERT INTO Patient_Payment VALUES(12353,'Baxter','Julie','A','216.55','DISCOVER','7820-9932-6699-0021','03/22');
INSERT INTO Patient_Payment VALUES(12354,'Smith','Olette','K','0','VISA','8430-0192-9222-0021','09/23');

Recommended Answers

All 3 Replies

Your payment.php file just includes an HTML form for the user to see. It doesn't actually include any PHP code. You need to write PHP code to connect to the database using MySQLi.

commented: I read that I could convert my html to a php? I converted it and everything works but I’m not sure how to connect the two. I honestly don’t have any +0

I read that I could convert my html to a php? I converted it and everything works but I’m not sure how to connect the two.

I honestly don’t have any experience with PHP, could you demonstrate what you mean by that?

Sorry, I’m already in bed for the evening so I can’t really type out a long response from my phone. I’ll answer more tomorrow.

PHP is a server side scripting language in which you can write code that spits out HTML. PHP scripts can include both php code encased in php tags as well as html. Right now, your php script is all html with no php code at all.

If you have no experience at all with php, I suggest that you search the web for an intro to php tutorial and check it out. What you’re asking to do requires basic knowledge of writing php code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.