Input-EN_AR site,
PHP-MYSQL Course |
In the steps of this tutorial, I will be using the XAMPP
server for Windows ... |
May
2015
| |
General
Info: |
|
Connection Name
="$conn" Server Name = "localhost" User Name
= "root" Password = "" Database Name =
"iforms" |
|
Database Name =
"iforms" 1-Table Name = "itemsi" |
| |
| |
|
If you wish to install a local testing server, you can download the
XAMPP package for Windows http://www.apachefriends.org/en/xampp.html
Once
XAMPP is a completely installed. XAMPP is an easy to install Apache
distribution containing MySQL, PHP and Perl. You can use the
XAMPP Control Panel to start your testing server.
- Click Start next to both Apache and MySQL to start the services.
Starting these services can take a few seconds. When it is complete,
'Running' will display beside each option.
To make your testing server start automatically
when your computer starts, you can check the Svc checkbox beside both
options. If the XAMPP Control Panel is not already running, go to
C:\xampp\control.exe to open the panel. |
1- XAMPP Control Panel
|
|
|
With your testing server now installed and running, there are a few
final steps you should take to make sure everything is configured to work
perfectly.
- Open a web browser such as Firefox or Internet Explorer.
- In the Address bar, enter http://localhost.
You should see a
XAMPP splash screen with language options.
- Choose your preferred language.
You should now see a confirmation
window informing you that 'You have successfully installed XAMPP on your
system' |
2-
List of Files
the php
+ sql files and Folders corresponding, stored at \29-Course,
Input-EN_AR site, PHP-MYSQL\Input-EN_AR Folder main file:
index.php |
|
|
Defining a Dreamweaver
Site |
Once a testing server is set up, either locally or using
a remote hosting service, you will need to define a site for Dynamic
Development in Dreamweaver |
|
In Dreamweaver go to Site -> New Site.
Note:
you can edit an existing site definition by going to Site -> Manage
Sites. Select the site you wish to modify, then click the edit
button. |
|
Step 2: Enter the local
Information
In the
first section of the site definition, you will set the Local Information.
This sets the Site Name, and local path for files in your
site.
When using XAMPP in a windows system, it may be that the site
root is mapped to: C:\xampp\htdocs so the new site folder would be created under
that location: C:\xampp\htdocs\Input-EN_AR-site
In this screen shot, using DW CS6 on a Windows system with XAMPP
installed. you will set the Local Information. This sets the Site Name,
and local path for files in your site. Site
Name:
Input-EN_AR-site local Site Folder: C:\xampp\htdocs\Input-EN_AR-site |
|
|
The next setting is to connect to servers. In DW CS6 and above, this
done by selecting the servers section: |
|
|
and clicking the plus icon to define a new server
connection. at Basic tab, For the Name you can enter the same
name as the Site definition, When using a local testing server, set
Connect Using to "Local/Network" |
|
Set the Server Folder to the same location as the local
files set in the initial Site Settings. Server
Name:
Input-EN_AR-site connect
using:
Local/Network Server
Folder:
C:\xampp\htdocs\Input-EN_AR-site Web
URL:
http://localhost/Input-EN_AR-site |
|
|
at Advanced tab, |
Click the advanced button and set the Application model
to PHP / MySQL Server Model: PHP MySQL |
|
then click Save. Once the connection is
defined, there are check boxes to set the connection as a testing or
remote connection, check the testing option. |
|
and then Click Save, the Dreamweaver dialog box
display: |
|
Step 4:
Manage Sites |
you can edit an existing site definition by going to Site
-> Manage Sites. Your Sites: Input-EN_AR-site |
|
then click Done |
Setup the site's Testing Server and then click
OK |
|
|
|
n this section, we'll look into how to create a database.
A database is used to store information for your site. Copy
iforms.sql file from
...\\\29-Course, Input-EN_AR site, PHP-MYSQL\Input-EN_AR Folder
to folder C:\xampp\htdocs\Input-EN_AR-site |
Most web hosts use a control panel for managing your
site, in the control panel they will have a way to create a MySQL
Database. Once a database has been created, you can use phpMyAdmin to edit
it. |
phpMyAdmin is also available using most Local Testing
server packages like XAMPP. The Start pages for those server will have a
link to open phpMyAdmin.
In phpMyAdmin, go to the Import tab. Use
this .sql script (C:\xampp\htdocs\Input-EN_AR-site\iforms.sql) to
create the iforms database that we will be using
:.
Step
1: import SQL file On the import tab, Click the chose
file button, and select the iforms.sql file that you
downloaded, and click the Go
button to have the database created: |
|
|
Message about iforms.sql display: Import has been
succcessully ... |
|
|
the Database "iforms" stores 1 table:
itemsi On the Structure tab, to be Displays: the
Table "itemsi" of Database "iforms" |
|
|
|
index.php page File |
Now that a site and a database are created, lets connect
the 2 together.
Before creating the database connection, a new PHP
file needs to be created and saved to the site |
Go to File -> New. In the File Creation dialog, select Blank Page.
From the page type section, select PHP and click the
create. |
|
|
Go to File -> Save. In the Save As option, enter
"index.php"
In the Where section, select the folder for your
site. |
|
|
Step 3: the Site has been
defined - testing server - Once the site has been
defined, at Dreamweaver - Dw display current Message: "This page
may have dynamically-related files that can only be discovered by the
server. Discover | Preferences. |
|
|
Step 4: the
software connection to the database |
connection
name: $conn MySQL
server:
localhost User
name:
root Password:
Database: iforms |
The Code of
dbi.php |
<?php //database name -->
iforms
$conn=mysql_connect("localhost","root",""); $db=mysql_select_db("iforms",$conn); ?> | | |
|
Step 5: The Designs and
Codes of 2 ... |
1st Group of operation, consists of the file:
index.php and these parts: dbi.php and
comment.php. 2nd Group of operation consists of the file:
index-AR.php and these parts: dbi.php and
comment-AR.php |
|
A- the Design and Code of
index.php 1st Group of operation
consists of the file - index.php ... |
1- The Design of
index.php |
|
|
2- The
Code of index.php |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml"> <head> <meta
http-equiv="Content-Type" content="text/html; charset=utf-8"
/> <title>Home, Service</title> <style
type="text/css"> .chkkk { font-family: Times New Roman,
Times, serif; font-size: 24px; font-weight:
bold; font-style: italic; color:
#900; } </style> </head>
<body> <table
width="90%" border="3" align="center" cellpadding="0"
cellspacing="0"> <tr> <th scope="col"><table
width="100%" border="0" cellspacing="0"
cellpadding="0"> <tr> <th scope="col"
style="background-color: #B1D8D8; font-family: 'Times New Roman',
Times, serif; font-weight: bold; font-style: italic; font-size:
xx-large; color: #003;"> <table width="100%" border="0"
cellspacing="2" cellpadding="2"> <tr> <th
scope="col" width="25%" height="80" div align="center"><a
href="index.php"><img src="imagess/I_logo.jpg" width="183"
height="90" longdesc="imagess/I_logo.jpg"
/></a></th> <th scope="col" width="75%"
height="80" >Callback
Application,English</th> </tr> </table> </th> </tr> <tr> <td><table
width="100%" border="0" cellspacing="0"
cellpadding="0"> <tr> <th scope="col" width="50%"
align="left"> <strong><em><span
class="chkkk">Send callback
request</span></em></strong></th> <th
scope="col" align="center" width="35%"> <?php $dt =
time(); $mysql_datetime = strftime("%d-%m-%Y
%H:%M:%S", $dt); echo
$mysql_datetime; ?> </th> <th scope="col"
width="15%" align="center"><a
href="index-AR.php">عربي</a></th>
</tr> </table></td> </tr> <tr> <td><table
width="100%" border="0" cellspacing="4" cellpadding="4
"style="background-color: #B1D8D8;" > <tr> <th
scope="col" align="center" width="60%">
<form
name="comment" method="post" action="comment.php" onSubmit="return
validation()">
<TABLE border="0" cellspacing="5"
cellpadding="0"> <TBODY> <TR> <TD
width="60%">Title</TD> <TD width="5%"
align="center">:</TD> <TD width="35%"><SELECT
name="title" id="title"><OPTION value="">--- Please Select
Title ---</OPTION> <OPTION
value="Mr.">Mr.</OPTION> <OPTION
value="Mrs.">Mrs.</OPTION> <OPTION
value="Miss">Miss</OPTION> </SELECT>
</TD></TR> <TR> <TD>First
Name</TD> <TD align="center"
>:</TD> <TD><INPUT name="fname" id="fname"
type="text"></TD></TR> <TR> <TD>Last
Name</TD> <TD
align="center">:</TD> <TD><INPUT name="lname"
id="lname"
type="text"></TD></TR> <TR> <TD>Country</TD> <TD
align="center">:</TD> <TD><SELECT
name="country0" id="country0"><OPTION value="">--- Please
Select Country ---</OPTION> <OPTION
value="dubai">United Arab Emirates - Dubai</OPTION>
<OPTION value="adhabi">United Arab Emirates - Abu
Dhabi</OPTION> <OPTION value="ksa">Kingdom of Saudi
Arabia</OPTION> <OPTION
value="qatar">Qatar</OPTION> <OPTION
value="oman">Oman</OPTION> <OPTION
value="lebanon">Lebanon</OPTION> <OPTION
value="jordan">Jordan</OPTION> <!--<option
value="bahrain">Bahrain</option> <option
value="kuwait">Kuwait</option>--> </SELECT>
</TD></TR> <TR> <TD>Email</TD> <TD
align="center">:</TD> <TD><INPUT name="email"
id="email"
type="text"></TD></TR> <TR> <TD>Phone</TD> <TD
align="center">:</TD> <TD><INPUT name="phone"
id="phone"
type="text"></TD></TR> <TR> <TD>Product
of Interest</TD> <TD
align="center">:</TD> <TD><SELECT
name="product" id="product"><OPTION value="">--- Please
Select Product ---</OPTION> <OPTION
value="goil">Genuine Oil</OPTION> <OPTION
value="gparts">Genuine Parts</OPTION> </SELECT>
</TD></TR> <TR> <TD>Preferred
Communication Method</TD> <TD
align="center">:</TD> <TD> <TABLE border="0"
cellspacing="5"
cellpadding="0"> <TBODY> <TR> <TD
width="100" align="center"><LABEL for="byemail">By
Email</LABEL><BR><INPUT name="com_method"
id="byemail" type="radio"
value="byemail"></TD> <TD width="100"
align="center"><LABEL for="byphone">By
Phone</LABEL><BR><INPUT name="com_method"
id="byphone" type="radio"
value="byphone"></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD>We
care to fulfill your requests and know your
feedback</TD> <TD
align="center">:</TD> <TD><TEXTAREA
name="feedback" id="feedback" style="height: 150px; resize:
none;"></TEXTAREA></TD></TR> <TR> <TD
align="center"> </TD> <TD
> </TD> <TD align="left"><INPUT
name="send" id="send" style="text-align: center; float: center;
display: block; cursor: pointer;" type="submit"
value=" Submit
Application "></TD></TR></TBODY></TABLE></FORM> </th> <th
scope="col" align="center" width="40%"><table width="90%"
border="0" cellspacing="3"
cellpadding="3"> <tr> <th scope="col"
align="center"><img src="imagess/temp.jpg" width="180"
height="120" longdesc="imagess/temp.jpg"
/></th> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td
align="center"><img src="imagess/temp-reclame.jpg" width="180"
height="120" longdesc="imagess/temp-reclame.jpg"
/></td> </tr> </table>
</th> </tr> </table></td> </tr> <tr> <td> </td> </tr> <tr> <td
bgcolor="#B1D8D8" align="center"> <table width="95%"
border="0" align="center" cellpadding="2"
cellspacing="2"> <tr></tr> <tr> <th
scope="col" align="left"> <a
href="index-AR.php">عربي</a></th> </tr> <tr> <td> Show
last Input Apply info ...
</td> </tr> <tr> <td><table
width="95%" border="0" align="center" cellpadding="2"
cellspacing="2"> <tr> <th scope="col"
align="left"> <?php include("dbi.php"); $select=mysql_query("select
ID, firstname, lastname FROM itemsi order by ID DESC limit 0, 1
");
while($row=mysql_fetch_array($select)) { echo
"<div id='sty'>"; echo "<img
src='imagess/face_001.png'"."' width='50px' height='50px'
align='left' />"; //The time is now <?php echo
date('H:i:s'); echo "<div id='ID'> ID
= ".$row['ID']."</div>" ; echo
"<div id='firstname'> First Name
= ".$row['firstname']."</div>" ; echo "<div
id='lastname'> Last Name
= ".$row['lastname']."</div>"; echo
"</div><br
/>"; } ?> </th> </tr> </table></td> </tr> </table> </td> </tr> <tr> <td> </td> </tr> </table></th> </tr> </table> </body> </html> | |
|
3- the Code, dbi.php
page File |
<?php //database name -->
iforms
$conn=mysql_connect("localhost","root",""); $db=mysql_select_db("iforms",$conn); ?> | |
|
4- the Code,
comment.php page File |
<?php include("dbi.php"); if(isset($_POST['send'])) { //SELECT
`ID`, `title`, `firstname`, `lastname`, `country0`, `email`,
`phone`, `product`, `com_method`, `feedback` FROM `itemsi` WHERE
1
$title=$_POST['title']; $firstname=$_POST['fname']; $lastname=$_POST['lname']; $country0=$_POST['country0']; $email=$_POST['email']; $phone=$_POST['phone']; $product=$_POST['product']; $com_method=$_POST['com_method']; $feedback=$_POST['feedback'];
$insert=mysql_query("insert
into
itemsi(title,firstname,lastname,country0,email,phone,product,com_method,feedback)values('$title','$firstname','$lastname','$country0','$email','$phone','$product','$tom_method','$feedback')")or
die(mysql_error());
header("Location:index.php"); } ?> | |
|
B- the Design and Code of
index-AR.php 2nd Group of operation,
consists of the file: index-AR.php and these parts: dbi.php and
comment-AR.php |
1- The Design of
index-AR.php |
|
|
2- The Code of
index-AR.php |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html
xmlns="http://www.w3.org/1999/xhtml"> <head> <meta
http-equiv="Content-Type" content="text/html; charset=utf-8"
/> <title>خدمة عملاء</title>
<style
type="text/css"> .chkkk { font-family: Times New Roman,
Times, serif; font-size: 24px; font-weight: bold; color:
#900; } .chkkar { font-family: "Times New Roman", Times,
serif; font-weight: bold ; font-size:
x-large; font-style:normal; } .chkkar { font-family:
Times New Roman, Times, serif; } .chkkar { font-family:
Times New Roman, Times,
serif; } </style> </head>
<body> <table
width="90%" border="3" align="center" cellpadding="0"
cellspacing="0"> <tr> <th scope="col"><table
width="100%" border="0" cellspacing="0"
cellpadding="0"> <tr> <th scope="col"
style="background-color: #B1D8D8; font-family: 'Times New Roman',
Times, serif; font-weight: bold; font-style: italic; font-size:
xx-large; color: #003;"> <table width="100%" border="0"
cellspacing="2" cellpadding="2"> <tr> <th
scope="col" width="25%" height="80" div align="center"><a
href="index.php"><img src="imagess/I_logo.jpg" width="183"
height="90" longdesc="imagess/I_logo.jpg"
/></a></th> <th scope="col" width="75%"
height="80" >Callback Application,
Arabic</th> </tr> </table> </th> </tr> <tr> <td><table
width="100%" border="0" cellspacing="0"
cellpadding="0"> <tr> <th scope="col" width="15%"
align="center"><a
href="index.php">English</a></th> <th
scope="col" align="center" width="35%"> <?php $dt =
time(); $mysql_datetime = strftime("%d-%m-%Y
%H:%M:%S", $dt); echo
$mysql_datetime; ?> </th> <th scope="col"
width="50%" align="right"
dir="rtl"> <span
class="chkkar"> ارسل طلب
اتصال</span> </span></em></strong></th>
</tr> </table></td> </tr> <tr> <td><table
width="100%" border="0" cellspacing="4"
cellpadding="4"style="background-color: #B1D8D8;"
> <tr> <th scope="col" align="center"
width="40%"><table width="90%" border="0" cellspacing="3"
cellpadding="3"> <tr> <th scope="col"
align="center"><img src="imagess/CARTOON_img.jpg" width="300"
height="200" longdesc="imagess/CARTOON_img.jpg"
/></th> </tr> <tr> <td> </td> </tr> <tr> <td
align="center"><img src="imagess/I-74759.jpg" width="264"
height="150" longdesc="imagess/I-74759.jpg"
/></td> </tr> </table></th> <th
scope="col" align="center" width="60%"> <form
name="comment" method="post" action="comment-AR.php"
onSubmit="return validation()"> <TABLE border="0"
align="center" cellpadding="0" cellspacing="5"
dir="rtl"> <TBODY> <TR> <TD
width="60%">اللقب</TD> <TD width="5%"
align="center">:</TD> <TD width="35%"><SELECT
name="title" id="title"><OPTION value="">--- من فضلك اختر
اللقب ---</OPTION> <OPTION
value="السيد">السيد</OPTION> <OPTION
value="السيدة">السيدة</OPTION> <OPTION
value="الآنسة">الآنسة</OPTION> </SELECT>
</TD></TR> <TR> <TD>الاسم
الأول</TD> <TD
align="center">:</TD> <TD><INPUT name="fname"
id="fname" type="text"></TD></TR>
<TR> <TD>اسم العائلة</TD> <TD
align="center">:</TD> <TD><INPUT name="lname"
id="lname"
type="text"></TD></TR> <TR> <TD>الدولة</TD> <TD
align="center">:</TD> <TD><SELECT
name="country0" id="country0"><OPTION value="">--- من فضلك
اختر الدولة ---</OPTION> <OPTION
value="dubai">الامارات - دبي</OPTION> <OPTION
value="adhabi">الامارات - أبو ظبي</OPTION>
<OPTION value="ksa">المملكة العربية
السعودية</OPTION> <OPTION
value="qatar">قطر</OPTION> <OPTION
value="oman">عمان</OPTION> <OPTION
value="lebanon">لبنان</OPTION> <OPTION
value="jordan">الاردن</OPTION> </SELECT>
</TD></TR> <TR> <TD>البريد
الالكتروني</TD> <TD
align="center">:</TD> <TD><INPUT name="email"
id="email"
type="text"></TD></TR> <TR> <TD>الهاتف</TD> <TD
align="center">:</TD> <TD><INPUT name="phone"
id="phone"
type="text"></TD></TR> <TR> <TD>مهتم
ب</TD> <TD
align="center">:</TD> <TD><SELECT
name="product" id="product"><OPTION value="">--- من فضلك
اختر المنتج ---</OPTION> <OPTION value="goil">الزيوت
الأصلية</OPTION> <OPTION value="gparts">قطع الغيار
الاصلية</OPTION> </SELECT>
</TD></TR> <TR> <TD>وسيلة الاتصال
الأفضل</TD> <TD
align="center">:</TD> <TD> <TABLE border="0"
cellspacing="5"
cellpadding="0"> <TBODY> <TR> <TD
width="100" align="center"><LABEL for="byemail">البريد
الالكتروني</LABEL><BR><INPUT name="com_method"
id="byemail" type="radio"
value="byemail"></TD> <TD width="100"
align="center"><LABEL
for="byphone">الهاتف</LABEL><BR><INPUT
name="com_method" id="byphone" type="radio"
value="byphone"></TD></TR></TBODY></TABLE></TD></TR> <TR> <TD>نهتم
بتلبية طلباتكم ومقتراحتكم</TD> <TD
align="center">:</TD> <TD><TEXTAREA
name="feedback" id="feedback" style="height: 150px; resize:
none;"></TEXTAREA></TD></TR> <TR>
<TD
align="center"> </TD> <TD
> </TD> <TD align="right"><INPUT
name="send" class="nbutton grid1" id="send" style="text-align:
center; float: right; display: block; cursor: pointer;"
type="submit" value=" ارسل
طلب"></TD></TR></TBODY></TABLE>
</FORM></th> </tr> </table></td> </tr> <tr> <td> </td> </tr> <tr> <td
bgcolor="#B1D8D8" align="center" dir="rtl"> <table
width="95%" border="0" align="center" cellpadding="2"
cellspacing="2"
dir="rtl"> <tr></tr> <tr> <th
scope="col" align="right" dir="rtl"><a
href="index.php">English</a> </th> </tr> <tr> <td
dir="rtl" align="right"> معلومات عن اخر طالب ارسال
...</td> </tr> <tr> <td><table
width="95%" border="0" align="center" cellpadding="2"
cellspacing="2" dir="rtl" > <tr> <th scope="col"
align="right"
dir="rtl"> <?php include("dbi.php"); $select=mysql_query("select
ID, firstname, lastname FROM itemsi order by ID DESC limit 0, 1
");
while($row=mysql_fetch_array($select)) { echo
"<div id='sty'>"; echo "<img
src='imagess/face_001.png'"."' width='50px' height='50px'
align='right' />"; //The time is now <?php echo
date('H:i:s'); echo "<div align='right' id='ID'
dir='rtl'> الرقم = ".$row['ID']."</div>"
; echo "<div align='right' id='firstname'
dir='rtl'> الاسم
الأول = ".$row['firstname']."</div>"
; echo "<div align='right' id='lastname'
dir='rtl'> اسم
العائلة = ".$row['lastname']."</div>"; echo
"</div><br />"; } ?>
</th> </tr> </table></td> </tr> </table> </td> </tr> <tr> <td> </td> </tr> </table></th> </tr> </table> </body> </html> | |
|
3- the Code,
comment-AR.php File |
<?php include("dbi.php"); if(isset($_POST['send'])) { //SELECT
`ID`, `title`, `firstname`, `lastname`, `country0`, `email`,
`phone`, `product`, `com_method`, `feedback` FROM `itemsi` WHERE
1
$title=$_POST['title']; $firstname=$_POST['fname']; $lastname=$_POST['lname']; $country0=$_POST['country0']; $email=$_POST['email']; $phone=$_POST['phone']; $product=$_POST['product']; $com_method=$_POST['com_method']; $feedback=$_POST['feedback'];
$insert=mysql_query("insert
into
itemsi(title,firstname,lastname,country0,email,phone,product,com_method,feedback)values('$title','$firstname','$lastname','$country0','$email','$phone','$product','$tom_method','$feedback')")or
die(mysql_error());
header("Location:index-Ar.php"); } ?> | |
|
|
in Dreamweaver, select or open (php) files, Go
to File -> Preview in Browser -> IExplore or chrome, to Show
and display the Search Operations... Note: this Google Chrome, it
is Arabic Version |
1st Group or main file - index.php, in
English |
| |
|
2nd Group - index-AR.php, in
Arabic |
|
|
|
|