There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.
Here we will create table in database section for which we will use programmatic method with the help of PHP and MYSQL .
Write a program to Add Content in Table with the help of PHP and MySQL ?
Syntax of PHP
<?php
//Content goes here
?>
<?php require_once("connectionstring.php"); $host = 'localhost'; $user = 'root'; $pwd = ''; $db = 'loginpanel'; $conn = mysqli_connect($host, $user, $pwd, $db); // connection check if(!$conn) { die("Connection failed : " . mysqli_connect_error()); } $sqltable = "INSERT INTO `logintable` (`id`, `email`, `password`) VALUES ('3', 'kumaratuljaiswal.com@gmail.com', 'truth@.inatul#!43')"; if(mysqli_query($conn, $sqltable)) { echo "Adding Table Content Created Successfully"; } else { echo "Error adding table content : " . mysqli_error($conn); } mysqli_close($conn); ?>
Explaination
=> $host = 'localhost'; $host is a variable which is
used to store a value like localhost and localhost
is our server.
=> $user = 'root'; $user as it same just like above the sentence but here is one
difference and the difference
is that its a user like root user of our
xampp machine localhost.
=> $pwd = '';
In this variable here is empty value of $pwd variable
because we dont want any type of problem means no need of authentication.
=> $db = 'loginpanel'; - Loginpanel is our database name.
Now you
must be thinking what is this authentication!! dont worry
click here for more information.
=> $conn is our new variable.
=> mysqli_connect()
- The mysqli_connect() function attempts to open a connection to the MySQL
Server running on host which can be either a host name or an IP address.
Passing
the NULL value or the string "localhost" or variable name to this
parameter.
Now we will check the connection whether the connection
is working successfully or not!! Actually here we will "if and
else" condition.
=> die() - The die()
function prints a message and exits the current script.
=> $sqltable - its a variable but in this variable we store the mysql query for inserting content in
table
according to our demand.
=> mysqli_query()
- mysqli_query() what it returns. The return value could be a
boolean(true/false)
Disclaimer
All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.