HomeSaturday, October 1, 2016, 01:26:52
16

Create dynamic Web Pages with PHP & MySQL

Tuesday, February 10, 15, 11:26:22, 2 Yaers Ago Via wain, Hits: 1536
Create dynamic Web Pages with PHP & MySQL, Requirement(s): PHP Server, MySQL
Download source code (tutorial):
http://phpform.net/download.php?f=dynamic.zip

config.php
Code:
<?php
//MySQL Configuration
//DB Host (Normally 'localhost')
$dbhost = 'localhost';
//DB Database Username
$dbusername = 'root';
//DB Database User Password
$dbpassword = 'mypassword';
//DB Database Name
$dbname = 'mydbname';
//mysql_connect function
$conn=mysql_connect($dbhost, $dbusername, $dbpassword);
if(!$conn) :
die('Could not connect: ' . mysql_error());
endif;
$db=mysql_select_db($dbname, $conn);
if(!$db) :
die ('Cant connect to database : ' . mysql_error());
endif;
?>


install.php
Code:
<?php
//make a MySQL connection
include('config.php');
//create a MySQL table in the selected database
mysql_query("CREATE TABLE `page` (
`linkid` int(11) NOT NULL auto_increment,
`text` text collate utf8_unicode_ci,
`linkurl` text collate utf8_unicode_ci,
PRIMARY KEY (`linkid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
COLLATE=utf8_unicode_ci AUTO_INCREMENT=1")
or die(mysql_error());
?>


index.php
Code:
<title>Index Page</title>
<center><h2>INDEX</h2></center><BR>
<?php
//make a MySQL connection
include('config.php');
echo "&nbsp;<a href=\"insert.php\">INSERT PHP</a><br>";
//get all the data from the page table
//*=select everything from the table page
$result = mysql_query("SELECT * FROM page")
or die(mysql_error());
while($link=mysql_fetch_array($result)){
//echo (display) a link using $link[linkid]
echo "&nbsp;<a href=\"webpage.php?id=$link[linkid]\">Web Page 1</a><br>";
}
?>


insert.php
Code:
<title>Insert Page</title>
<center><h2>INSERT PAGE</h2></center><BR>
<?php
//make a MySQL connection
include('config.php');
//to check if a submit button was clicked, use this...
if(isset($_POST['submit']))
{
$text = $_POST['text'];
$linkurl = $_POST['linkurl'];
//the INSERT INTO statement is used
//to add new records to a database table
mysql_query("INSERT INTO page (text,linkurl) VALUES
('$text','$linkurl')")
or die(mysql_error());
}else{
?>
<form method="post" action="insert.php">
<table><tr><td>
Title:
</td>
<td>
<input name="text" size="60" maxlength="255">
</td></tr>
<tr><td>
URL:
</td>
<td>
<input name="linkurl" size="60" maxlength="255">
</td></tr>
<tr><td>
<input type="submit" name="submit" value="submit">
</td></tr></table>
</form>
<?php
}
?>


webpage.php
Code:
<?php
////make a MySQL connection
include('config.php');
//get ID from URL
$id = $_GET['id'];
//get linkid, text, linkurl from the page table
//..or..*=select everything from the table page
$result = mysql_query("SELECT linkid, text, linkurl FROM page
WHERE linkid='$id' ")
or die(mysql_error());
while($myrow = mysql_fetch_assoc($result))
{
//the meta title tag is used to declare
//the title of the page
echo "<title>Web Page $myrow[text]</title>";
echo "<center><h2>Web Page $myrow[text]</center><BR>";
echo "<a href=\"$myrow[linkurl]\">$myrow[text]</a>";
}
?>

shashi kanth reddy Wednesday, November 24, 2010, 14:28:09

excellent tutorial, please keep contributing in this way so that beginners will be benefited from sources like these , will keep posting

Daniel Wednesday, May 26, 2010, 10:44:43

Thanks for this tut, really helped me learn the basics.

Jas Wednesday, July 28, 2010, 10:57:59

Very useful for me

Paul Saturday, August 7, 2010, 02:21:31

this is very useful. I am about as new as they come to PHP and I found these scripts very educational, I learned more by playing with these scripts then all the tutorials I have read on the met put together. thank you so much for the time and effort.

Timothy Saturday, October 2, 2010, 07:16:26

Thanks for the tut, really helped a lot. though I have a question, how can I make the Web Page 1 change name? because it's awkward if you have thousands of links with Web Page 1 as their names.

sam Friday, October 22, 2010, 15:18:25

big ups,the tuts is very very helpful..

Vanja Tuesday, December 14, 2010, 07:38:35

Static Pages
Web Page

htaccess
RewriteEngine on
RewriteRule (.*)\\.html$ webpage.php?id=$1

Mihail Saturday, January 22, 2011, 05:42:52

Very useful tut, thank you.

dani Monday, February 14, 2011, 09:38:29

thanks man

sandra Sunday, May 22, 2011, 16:45:15

Useful, clean, detailed tutorial. Thank you very much.

diweng Saturday, June 4, 2011, 07:30:56

Nice work! Thanks for tut.

Nehemiah c Monday, April 16, 2012, 06:07:19

This is very Use full to me. Thank U

Sign In

Web Hosting
First Month Free with Coupon Code phpmonth
Unlimited Domains - Unlimited Storage
Unlimited Transfer - Unlimited Email
Related

Stack Overflow Clone Script - Ja2BU

Open source question and answer script written in PHP, MySQL and jQuery. Main features are: SEO friendly url's, private message system, rating system, comments system.

PHPBB3 Shoutbox

Vesion: 1.1. Released: 08/08/10, Licence GNU, Price: Free

Addslashes - Stripslashes

addslashes — quote string with slashes, stripslashes — un-quotes a quoted string

Link Base L.1.1.

This script allows you to manage your links using a MySQL database. It features easy install, user submission, and an admin panel to add, edit and remove categories and links. The script is easy to customize to suit your needs.

PHP File Create

Create and write data to a file using the php frwite function.

Sending HTML Email With Images - PHP Tutorial

Sending HTML Email With Images - Upload Image with PHP - Creating Dynamic Webpages Using PHP and MySQL - Select, Delete, Update..

Upload and Resize an Image with PHP

Tutorial - How to upload and resize image with PHP

Preg_Match - PHP Form Validation

PHP form validation with preg_match

PHP Tutorials

Useful step-by-step PHP tutorials for beginners

How to insert new line (IP Address) with fwrite

How to insert new line (IP Address) with fwrite, Get IP address and write to file.
About Author

wain

Date Registered: Sun, Feb 8, 15
Last Time Online: Sun, Sep 18, 16
So far has created 115 entries.
wain
This author has not yet filled in any details.