phpForm.net

Home | Forums | PHP Tutorials | MySQL Tutorials | CSS Tutorials | PHP Forms | About Domains

Free PHP Scripts



 PHP Form Image Upload
 PHP Form File Upload
 Advanced PHP Contact Form
 Link Base L.1.0.
 Link Base 1.1.
 Link Base 2.0.
 Link Generator Script
 PHP Comments
 Comments 1.1.
 Captcha v1
 Meta Tags Generator 1.1.
 E-Cards 1.1.
 Feedback Form with Captcha
 Tell A Friend
 Contact Us - PHP Form
 Contact Us 2.0. - PHP Form
 Contact Us with Captcha
 HTML Button Generator
 PopUp Window Code Generator
 Site Recommendation
 Send This Link
 GuestBook
 Bookmark Script
 ShoutBox 1.1.
 ShoutBox 20.
 RSS Feeds

PHP Tutorials

 PHP Tutorials
 PHP Form Validation
 PHP Mail
 Sending HTML Email With Images
 Creating a CAPTCHA with PHP
 Creating a CAPTCHA with PHP 2
 Math CAPTCHA with PHP
 Bad Word Filter with PHP
 Bookmark Current Page
 Timed Redirect JavaScript
 PHP Redirect
 Upload Image With PHP
 Upload Image With PHP 2
 Upload and Resize with PHP
 Upload File With PHP
 PHP Cookies and Sessions

PHP Basic

 PHP Date
 PHP $_GET Function
 PHP $_POST Function
 PHP $_SESSION
 PHP str_replace
 PHP fwrite
 PHP explode
 PHP setcookie

MySQL Tutorials

 MySQL Basic Functions
 Create dynamic Web Pages with PHP & MySQL
 MySQL - Select from two tables
 RSS and MYSQL
 MySQL Inner Join

Image Functions

 imagecreate
 imageline

Smarty Tutorials

 Smarty Dynamic Web Pages with PHP & MySQL

CSS Tutorials

 Show/Hide Div with CSS
 Images In Textarea
 Email Link

Links

 Css Generators
 JaRobot.com
 Facesmail.com
 Hallo Oglasi
 PHP Resource Index

Create dynamic Web Pages with PHP & MySQL

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;
?>
2.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());
?>
3.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>";
}
?>
4.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
}
?>

5.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>";
}
?>

PHP Comments

         Paul                2010-08-06 22: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.

         Jas                2010-07-28 06:57:59
    
Very useful for me

         shashi kanth reddy                2010-05-27 02:37:10
    
excellent tutorial,please keep contributing in this way so that beginners w ill be benefited from sources like these , will keep posting

         Daniel                2010-05-26 06:44:43
    
Thanks for this tut, really helped me learn the basics.

Intro Text PHP Comments L.1.0. - HTML not alowed

Name:


Comment:




powered by phpform.net



© PHPForm.net 2007 All Rights Reserved | Privacy Policy