In this section we will develop PHP PHP Form for accepting some information from the guest.
PHP email form
HTML form
It's not a good idea to leave your private e-mail address on your web-site due
to impossible activity of spammers. But nevertheless you need some way to get
feedback from your visitors. In the three parts of this tutorial I'll tell you
in details how to create a mailbox, that would be spam-protected, and will
recieve text messages from you visitors. We'll create 2 small PHP files, one
would send messages, the other will recieve them and simultaneuously delete them
from the server. Realization of this project requires about 2 kbs of space on a
server that supports PHP. Despite the fact, that these example files lack any
ornamentation of programming or any other nature, they must just work without
requiring any additional settings.
Let's create the first file,
index.php
<html><head><title>BRIEF MESSAGE</title></head><body><br>
<table width="100%" height="100%"><tr><td align=center><br>
<form action="index.php"><br>
Message:<br><textarea name="mes"></textarea><br><br><br>
<input name="yes" type="hidden" value="1"><br>
<input type="reset" value="Clean"><br>
<input type="submit" value="Send"><br>
</form><br>
<?php
//php-code from the Part 2<br>
?>
<br>
</td></tr></table></body></html>
The first two lines and the last one - are well-known HTML tags with their
attributes, their purpose is to place the input form into the center of the
screen. The visible part of the form (
form) contains a named multi-line
input field
textarea and two standard controlling buttons - one for
clearing the form (
reset) and the other for sending the message (
submit).
Their captions (
value) match their purpose. The
action attribute
of
form tag links to itself, so for controlling the
php-script,
that we'll write in the second part of the tutorial, let's add a
hidden
field named
yes to the tutorial. As we'll see later, what really matters
is not it's value, but the fact of it's existence. But in order not to make the
variable empty, let's assign it some value, for example, 1.
If you see our new-created file in some browser, you'll see an input field with
two buttons in the center of screen. Though that won't work yet.
receiving
the message
Let's now examine the code of PHP script that is to be entered into the file
that we've created in the fist part of the tutorial. Now let's give names to 2
simple text files, that will be being created and deleted dynamically by our
scripts. Let it be
n.txt to store the current number of messages, and
m.txt - to store their text.
In order for our script to be executed only in return to the sending button (
submit)
being pressed, let's state the main condition. If a non-empty variable
yes
is received, then do work. That's how this rule will look from the point of view
of PHP interpretation. After pressing
Send button, this rule is held
automatically.
if (!empty($_GET['yes'])){
//php code
}
Inside this rule we process the pressure of
Send button. If there is an
input, let's assign the value entered (text) to the
$mes variable, or, if
no input is made, we quit the script and inform user about it.
if(!empty($_GET['mes']))$mes=($_GET['mes']);else exit("Input message!");
Now let's write a code for the counter file -
n.txt
if (!file_exists("n.txt")){//if there is no counter file,
// let's create it, write into it value "1" and close it.
$fp = fopen("n.txt","w+");
fputs($fp,1);
fclose($fp);
$n[0]=1;//it' s the value of the first and the only one lement of the array.
}else{//if there is a counter file,
//let's read it's value to the array $n, add 1 and close the file
$fp = @fopen("n.txt","r+");
$n = file("n.txt");
$n[0]++; // increase the counter onto 1
fputs($fp, $n[0]);
fclose($fp);
}
Now we need only to write down or add the text, that is entered by the user
(together with it's number and date/time) from
$mes into
m.txt
file and inform user about it. Of course, the file must be closed afterwards,
and the script must be also be completed.
$dat = date("d m y H:i");//enter the variable - current date and time.
$fp = fopen ("m.txt", "a+");
fwrite ($fp, $n[0].". ".$dat."\n".$mes."\n\n");
fclose ($fp);
exit("Your message is accepted.");
The whole PHP code from the first part of the tutorial will look like the
following:
if (!empty($_GET['yes'])){
if(!empty($_GET['mes']))$mes=($_GET['mes']);else exit("Input message!");
if (!file_exists("n.txt")){
$fp = fopen("n.txt","w+");
fputs($fp,1);
fclose($fp);
$n[0]=1;
}else{
$fp = @fopen("n.txt","r+");
$n = file("n.txt");
$n[0]++;
fputs($fp, $n[0]);
fclose($fp);
}
$dat = date("d m y H:i");
$fp = fopen ("m.txt", "a+");
fwrite ($fp, $n[0].". ".$dat."\n".$mes."\n\n");
fclose ($fp);
exit("Your message is accepted.");
}
?>
Reading and deleting the message
Let's create a file for reading and deleting messages. We'll call it, for
example,
read.php. As in the previous file, in this one the first and the
last lines create the html-arrangement of a table.
<html><head><title>Read messages</title></head><body>
<table><tr><td>
<?php
//php-code
?>
</td></tr></table></body></html>
The meaning of the php-code listed below is the following. If no messages (the
message file does not exist), we finish the script and inform the user about it.
If there are messages, we create an array (
$n) of
m.txt file
lines, and string by string, by the means of a loop from 0 up to the array size
(
count($n)) print the lines out to the screen. Afterwards we
delete the
n.txt and
m.txt files in order to save disk space.
<?php
if (!file_exists("m.txt")){//if there is no message file
exit("No messages!");
}else{//if there is a message file
//read messages from it into an array $n
[email protected]("m.txt","r+");
[email protected]("m.txt");
fclose($fp);
//create a loop for a line-by-line print out to the screen
for ($i=0; $i<count($n); $i++)
echo $n[$i]."<br>";
unlink("n.txt");//delete the file
unlink("m.txt");//delete the file
exit;//finish the script
}
?>
Now we place both files creates in this lesson - that is,
index.php и
read.php - into a folder, that is called, for example,
antispam, and
put the folder onto a PHP-supporting server.
Than the send-message URL will be
http://www.name_of_server.domen/antispam/,
and read-message URL -
http://www.name_of_server.domen/antispam/read.php
Keep in mind, that the information is deleted from the server, and save the
received messages on your PC, if you need them.
Just one note. On a UNIX server it may be required for normal work to add a text
files' attributes' setting
chmod(), and, if the mailbox will be used
intensely, a
flock() blockage.
More Tutorials on roseindia.net for the topic PHP Form, PHP guest form.
PHP Form, PHP guest form
PHP email
form
HTML
form
It's not a good idea to leave your private e...'ll create 2 small
PHP files, one
would send messages, the other... of this project requires about 2 kbs of space on a
server that supports
PHP. Despite
PHP form
PHP form Hi Sir/Madam,
I am developing an attendance
form using
php, which displays the name and ID of a Employees which are fetched from Db and I...
form and update them to respective coloumn...
Please any one help mo out please
php form post to mysql
php form post to mysql How to post data into mysql database from the
PHP post data
form
HTML to php form
HTML to
php form Hi,
How I can submit the HTML
form data to
PHP Script? Give me example code.
Thanks
Hi,
Please see the following tutorials:
PHP Form
PHP email
form
Thanks
php
php plz tell me code for
PHP SQL Insert,delete,update,view is used to insert the record from HTML page to Mysql database using in single
PHP form
php loging form connecitivity with mysql
php loging
form connecitivity with mysql my loging
form is not connect
php
php im beginner to
php. i faced problem with creating
form and data...;head>
<title>
Form Input Data</title>
</head>
<body>
<table border="1">
<tr>
<td align="center">
Form
php
php im beginner to
php. i faced problem with creating
form and data...;head>
<title>
Form Input Data</title>
</head>
<body>
<table border="1">
<tr>
<td align="center">
Form
PHP Sticky form problem
PHP Sticky
form problem I have done the full coding of a sticky
form... Calculator</title>
<?
php
if (isset($_POST['submitted']) && !isset...>
<
form action="simple_calculator.php" method="post">
<p>Number 1
PHP Sticky form problem
PHP Sticky
form problem I have done the full coding of a sticky
form... Calculator</title>
<?
php
if (isset($_POST['submitted']) &&...;/head>
<body>
<h1>Simple Calculator</h1>
<
form action
how to post data in mysql php form
how to post data in mysql
php form how to post data in mysql
php form
how to create a user registration form in php
how to create a user registration
form in php how to create a user registration
form in
php
php form having 2 submit buttons
php form having 2 submit buttons i have a
php form and some text boxes.and 2 buttons"approve" and "disapprove". when i click on approve button the data from
form should go in mysql database and mail should go to appropiate
value in div from php, reloading form
value in div from
php, reloading form I am having one
form with name... woth other
login.php
<?
php
include 'login2.php';
function
form($name...;
</form>
<?
php
}
?>
<?
php
form('','')
?>
Fetch the data from mysql and display it on php form
Fetch the data from mysql and display it on
php form when i press on login button, after succesful login the related data of that person should be display in other textbox
php mail
php mail how to send the submitted
form to mail after 24 hours? pls help me
How to implement Captcha in PHP Form using GD Library
How to implement Captcha in
PHP Form using GD Library Hi,
How to show Captcha in
PHP Form. So, please suggest any online reference so that i will try myself.
Thanks
connectivity with php
connectivity with php i have make one html
form and doing connectivity with
php database but when i click on submit button on html
form display all coding in
php form about connectivity instead of adding data, i used in html
PHP : Form to Email
PHP :
Form to Email
With the help of this tutorial you can send mails to a user using a
form, as
we have discussed in our earlier tutorial, it is very easy to send mails using
PHP and any
How to Create Login/ Registration Form using PHP and MYSQL
How to Create Login/ Registration
Form using
PHP and MYSQL Hi,
I am learning
PHP. I have some dilemma how to create a Login
Form and make connectivity with HTML page using
PHP and MYSQL. Is there any body can guide me
Multipage form
Multipage form I have a multipage
form in
php with 2 pages wnhen i submit the
form data from both the
pages should go in database how should i pass teh data from 1st page to 2nd page and then put the entire
form data in mysql
PHP Regular Expression
PHP regular expression allows programmer to perform various task like...
expression one can easily validate user
form or perform complex manipulations
between strings.
PHP Regular expression also allows you to validate a email, phone
project on php
project on
php suppose i have five tabels and i must
form them html then link them database and
php then i want to make query between them these five tabels and data in each one pleaze help me Table of suppliers Source
PHP Question
PHP Question I am trying to make
php Readline where it reads from line 2 and loops to the end.
> if (isset($_POST['oldpass'])) {
>
>... =
> @fopen("/home/users/".$username.".txt",
> "r"); // Open file
form read
PHP Question
PHP Question I am trying to make
php Readline where it reads from line 2 and loops to the end.
> if (isset($_POST['oldpass'])) {
>
>... =
> @fopen("/home/users/".$username.".txt",
> "r"); // Open file
form read
Sitemap PHP Tutorial
| XML Expat Library
|
PHP :
Form to Email |
Create your Email Server...
Form |
PHP MySQLI Prep Statement...
Questions |
Site
Map |
Business Software
Services India
PHP Tutorial
PHP Displaying URL Content
PHP Displaying URL Content In my
PHP application
form, on submitting the
form details it always displaying url content. Can anyone tell me what is the reason and how to restrict it from displaying
PHP Training In Delhi
arrays
Creating
form based application in
PHP
Using MySQL with
PHP...
PHP Training In Delhi
If you looking for getting trained in
PHP in Delhi, then join our
PHP
Training course which is provided at our office in Delhi. We
connection in php
connection in php <?
php
include("include/db.php");
?>
<...;div>
<
form method="get" action="result.php" enctype="multipart/
form...;categories</div>
<ul id="cate">
<?
php
connection in php
connection in php <?
php
include("include/db.php");
?>
<...;div>
<
form method="get" action="result.php" enctype="multipart/
form...;categories</div>
<ul id="cate">
<?
php
connection in php
connection in php <?
php
include("include/db.php");
?>
<...;div>
<
form method="get" action="result.php" enctype="multipart/
form...;categories</div>
<ul id="cate">
<?
php
database and php
database and
php suppose i have five tabels and i must
form them html then link them database and
php then i want to make query between them... in html or
php and insert the
form value to the msyql database.
or some thing else
checkbox value in php
checkbox value in php In my HTML,
PHP form ..we have a check box that is working fine. But anyhow i am not able to get the value of it. Can anyone suggest how to get the value of checkbox in
PHP
Ask PHP Questions
to develop web 2.0 based image gallery applications.
Guest form - Its very easy to create
guest form in
PHP and install on linux hosting server. Its... to Ask
PHP Questions?
You can use the ask questions
form to ask your questions
Invoice Form
Invoice Form How can I create an Invoice web application (preferable
PHP) with customer look-up (with option to add new customer) and a grid to add items (search for items) with a total line below the grid. The grid should have
dynamic form
dynamic form I need to make a dynamic
form using
php, for example, i... button wich once clicked we have a new list created on the same
form. Thank you very much for your help
Here is a
php application that creates
display data in php
display data in php i want data validation in javascript for my
form data and it will display in
php.
my fields are name,emailid,address,country combobox,state combo box, i want only
php page,can u wxplain process how it come
pre-populate form
pre-populate form how to pre populate
form in
php
what do you mean by pre populate
PHP MYSQL Interview Questions
we can use GET and POST method in
PHP.
Is it possible to submit the
form data...
PHP MYSQL Interview Questions What kind of questions can be asked in an
PHP, MYSQL interview? Can anyone post the
PHP interviews questions with well
php
php what is
php
PHP Tutorials
Outsourcing PHP Projects, Outsource PHP Projects
Outsourcing
PHP Projects - Outsource your
PHP development projects
Outsource your
PHP projects to our
PHP
development in India. We have dedicated team of
PHP
developers, designers and analysts to cater your
PHP
project
PHP SQL Fetch
PHP SQL Fetch
PHP SQL Fetch is used to fetch the records from Mysql database to
PHP and
print in the
form of array records in browser.
Understand with Example
php
php what is
php
project on php and database
project on
php and database write code i have five tables and i want to build them as
form html then link between them as database and
php and make... color Date of entry of the goods status
PHP MYSQL Tutorials
php
php using javasript how to set timer in
php using javasript
connection of php to MySQL.
connection of
php to MySQL. I have a query on connection of
php... of MySQL) for Database
I have a page
admin.php
<?
php
if (isset($_POST...";
}
?>
<html>
<
form action="admin.php" method="post" id="admin
php
php i want to know about
php
and
php plateform
required software to make
php program and
database that used in
php program?
Please visit the following link:
PHP database
php
php i want to know about
php
and
php plateform
required software to make
php program and
database that used in
php program?
Please visit the following link:
PHP database
displaying data for a single column from Mysql database in the list box in php form
displaying data for a single column from Mysql database in the list box in
php form I have a
form in php.want to display data from a single column in an listbox in php.thanks..
<?
php
$data = @mysql_query("select
php
php show the constructor overloading in
php
Related Tags for PHP Form, PHP guest form: