Jump to content
RizwanAhmedMemon

How to connect to database

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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...