Jump to content

How to connect to database


RizwanAhmedMemon
 Share

Recommended Posts

I am creating an admission form which will ask for the information such as name, class, level, and such other information, so, I don't know how to connect to the database and how to make the database and how the database will store all that information. Can anybody explain it with real example with the code?

Link to comment
Share on other sites

I am creating an admission form which will ask for the information such as name, class, level, and such other information, so, I don't know how to connect to the database and how to make the database and how the database will store all that information. Can anybody explain it with real example with the code?
Basically;
<?PHP mysql_connect ([color=#444444]host,username,password,dbname);[/color] [color=#ff0000]$name = $_POST['name'][/color][color=#ff0000]$class = $_POST['class'][/color][color=#ff0000]$level = $_POST['level'][/color] mysql_query("INSERT into {TABLE NAME} VALUES ('{$name}', '{$class}', '{$level}') ?>

For the bits in red; this is based on you using a HTML form using the method = POST For example;

<form type='submit.html' method='POST'>Name: <br><input type='text' name='name'><br>Class: <br><input type='text' name='class'><br>Level: <br><input type='number' name='level'><br><input type='submit' name='submit' value='Login'></form>

Edited by MarkT
Link to comment
Share on other sites

  • 1 year later...

The below 2 steps areworked in backend process for store values into database

  • First need to create database in your Phpmyadmin
  • create table with required field

Then in php

  • make form with required field
  • make connection with database using PHP
  • get values from form and store it to database

Edited by Ingolme
Advertising
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...