Get Free Hacks, Skins , addons and Support! and uploads everyday with scriptznulled and EVEN MORE! AND ITS ALL FREE!!!!

 

Scriptz Nulled

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more!

This message will be removed once you have signed in.

Attention: No Leeching Allowed! Anyone caught leeching content will be banned!

If you encounter any errors while browsing the forum please post here (technical support) so it can be resolved immediately 

waha005

Coding lession(s)

9 posts in this topic

Posted (edited)

Hello, in this first lession we will learn about mysql and php, in this case mysqli functions will be used in coding, because most of hostings is on php7, which mysql functions have been removed.

But it's not hard to understand that, if you already know php and mysql functions.

 

 

First, we will make configuration php file

 




	<?php 



	define("DB_HOST", "localhost");



	define("DB_USER", "root");



	define("DB_PASS", "");



	define("DB_NAME", "testing");



	 



	$db = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);



	if($db->connect_errno > 0 ) 



	{



	die("There is a problem with mysql database!");



	} else {



	$db->connect(DB_HOST,DB_USER,DB_PASS,DB_NAME);



	}



	?>



	[/CODE]


 

Note: The database hosts depending on web hostings. Some hostings the database host isn't localhost. Like 000webhost, and similar to that hosting is not localhost.

 

In this lession we learned how to connect to database.

DB_NAME "" - Name of the database.

DB_USER "" - User of the database
DB_PASS "" - Password of the user 
DB_HOST "" - Database Host.

In next post i will post tutorial for selecting from database, inserting, deleting.

 

 

Merged: added 41 minutes later
 

In this lession we will learn how to select from database, insert or delete from database defined in the previously created configuration file.

So, let's start.

 

<?php
ob_start();
session_start();
require_once("config.php"); // Our configuration file, if you saved as configuration.php, so you need to change the name here.
?>

<html>
  <head>
    <title>Tutorial #2</title>
  </head>
  <body>
    <form action="" METHOD="POST">
      <label>Full Name:</label> <input type="text" name="fullname" placeholder="First Name and Last" required="true"></input><br/>
    <label>Email Address:</label> <input type="email" name="email" placeholder="[email protected]" required="true"></input><br/>
  <input type="submit" name="submit" value="Insert in Database"></input>
</form>
</body>
</html>

    

<?php 

function specialcharts($string)
{
$string = htmlspecialcharts($string);
return $string;
}
function tr($string)
{
$string = trim($string)
return $string;
}
if(isset($_POST["submit"])) 
{
$fname = $_POST["fullname"];
$email = $_POST["email"];
// Protection agains XSS and SQLI
$fname = specialcharts($db->escape_string(addslash(tr($_POST["fullname"]))));
$email = specialcharts($db->escape_string(addslash(tr($_POST["email"]))));

// Checking if the data is emptyy!
if($fname == "" or $email == "")
{
 echo "All fields are required!"; 
 exit;
}
else {
$result = $db->query("INSERT INTO `table_name` (`Full Name`, `Email Address`) VALUES ('$fname', '$email')");
// If the query didn't success, to print error what happened.
if(!$result) 
{
die("Error:" . $db->error);
}
header("Location:index.php");
echo "Successfully saved data in the database";
}
}

?>


Now save the file as index.php

Now we need to create table_name in our database.

 

CREATE TABLE IF NOT EXISTS `table_name` (
`id` int(11) NOT NULL,
  `Full Name` text NOT NULL,
  `Email Address` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `table_name`
--
ALTER TABLE `table_name`
 ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `table_name`
--
ALTER TABLE `table_name`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;
/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;
/*!40101 SET [email protected]_COLLATION_CONNECTION */;


In next lession i will post tutorial for Selecting from database.

Edited by waha005
3 people like this

Share this post


Link to post
Share on other sites

Fantastic tutorial buddy

Share this post


Link to post
Share on other sites

Very thanks good post :) 

Share this post


Link to post
Share on other sites

Woow! Very liked this one tutorial.

Share this post


Link to post
Share on other sites

Very good tutorial.

If you want, I may help you creating more tutorials on specific subjects.

 

Share this post


Link to post
Share on other sites

Nice one, but im searching some tutorials about codeigniter 3 framework ! and some advices anyone knows about this ?

Share this post


Link to post
Share on other sites

Nice basic PHP+HTML tutorial :) Great start for anyone!

 

Thanks!

Share this post


Link to post
Share on other sites

total noob when it comes to these kind of stuff but im starting to understand this helped a lot thx!

Share this post


Link to post
Share on other sites
9 hours ago, league said:

total noob when it comes to these kind of stuff but im starting to understand this helped a lot thx!

 

 

This tutorial is for newbies (beginners).

 

 

#closed to prevent spam.

Share this post


Link to post
Share on other sites
D
This topic is now closed to further replies.