PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, October 11, 2022

[FIXED] How to combine product details and booking details in php

 October 11, 2022     mysql, php, phpmyadmin     No comments   

Issue

I'm making a website for renting a car using PHP and MySQL .But I'm stuck, because I don't know how to combine car details and booking form details and show it in PHPMyAdmin when user submits the form.


Solution

Representation

You need to create relational representation in your MySQL database, like a table for cars, of the like of

cars(id, ...)

Where the ... represents whatever details you intend to store.

Storing a car

You need to create a PHP script that takes car details as input and stores cars as output. Since you already told us that you have a form, you will most likely use $_POST (an array with your named form elements for the form that you have submitted) as the input, but it is strongly recommended that you separate your functionality part from the definition of your input. So, you will most likely have a function/method (a standalone function or a method of a class) that will look something like this:

function storeCar($input) {
    //...
}

where $input is an associative array and you actually store the values. Of course, pay attention to SQL injection and XSS injection as possibilities. These are possible vulnerabilities that infest the codes of most beginners. You can used parameterized queries to prevent SQL injection and htmlspecialchars to protect against XSS injection.

Your code will end up executing an insert into ... type of command once you POST your form.

Loading cars

You can execute select * from cars to see what your cars' details are (but it's better to list only the columns you are interested about) at any places that are connected to MySQL, including PHPMyAdmin. Or, in some UIs, such as PHPMyAdmin you can click on table names.



Answered By - Lajos Arpad
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing