Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

If error submit can I use php & it returns with kept details?

Guest
Aug 08, 2006 Aug 08, 2006
Hi I was wondering if using php I can check the registration form for errors e.g. not filled out when required and upon return they can still have the details they already submitted still there so they don't have to re-fill the form.
Thanks for you help.
TOPICS
Server side applications
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 09, 2006 Aug 09, 2006
Sure.

<input name="firstname" type="text" id="firstname" value="<?php
echo(array_key_exists('firstname',$_POST))?$_POST['firstname']:'Enter Your
First Name'); ?>">

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"jjjhbj111" <webforumsuser@macromedia.com> wrote in message
news:ebb7ed$i7n$1@forums.macromedia.com...
> Hi I was wondering if using php I can check the registration form for
> errors
> e.g. not filled out when required and upon return they can still have the
> details they already submitted still there so they don't have to re-fill
> the
> form.
> Thanks for you help.
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 16, 2006 Aug 16, 2006
Hi Murray I tried this out but all I get is a white screen. Any suggestions?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 17, 2006 Aug 17, 2006
jjjhbj111 wrote:
> Hi Murray I tried this out but all I get is a white screen. Any suggestions?

There's a closing parenthesis causing a parse error. The correct code
should be this:

<input name="firstname" type="text" id="firstname" value="<?php echo
(array_key_exists('firstname',$_POST)) ? $_POST['firstname'] : 'Enter
Your First Name'; ?>">

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 09, 2006 Aug 09, 2006
Thank you I will try that.
array_key_exists is a new term for me. I just read about it.
Now will I have to use anything with the submit button to return the form for this process or will php take care of that as is?
Thank you.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 10, 2006 Aug 10, 2006
jjjhbj111 wrote:
> array_key_exists is a new term for me. I just read about it.
> Now will I have to use anything with the submit button to return the form for
> this process or will php take care of that as is?

PHP takes care of it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 10, 2006 Aug 10, 2006
Thank you I will try it out now.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 05, 2006 Sep 05, 2006
Hi thanks guys I have tried this again but it doesn't help with validating the form, it only gives me the 'Enter Your First Name' in the text box and that is it.
What I want to do is validate the form on submit but being able to have the form returned filled out with the correct items but give error for those not filled out.
I have a javascript already but if someone may have javascript turned off and I want to try and prevent someone tampering with the form. I am wanting to learn how to accomplish this. I will have many types of forms on my site.
Any other suggestions are greatly appreciated.
Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 06, 2006 Sep 06, 2006
jjjhbj111 wrote:
> What I want to do is validate the form on submit but being able to have the
> form returned filled out with the correct items but give error for those not
> filled out.

The code that Murray gave you does that. The first time you load the
page, it displays "Enter your first name". When you submit the form, it
displays whatever was inserted into that field.

The principle of validation is quite simple, but it involves quite a bit
of coding. Basically, you create a self-processing form (one that
submits to the same page), which checks the contents of the $_POST
array. If any items are incomplete, the details are stored in an array
called $error or $missing, and the page is redisplayed with the existing
details already filled out. Otherwise the form is processed as normal.

I show how to do this in "Foundation PHP for Dreamweaver 8", which also
shows you how to create server behaviors of your own to automate the
create of the code. However, the code itself is simple:

<input value="<?php if (isset($_POST['first_name'])) {
echo $_POST['first_name'];} ?>" type="text" name="first_name"
id="first_name" />

You need to do that for every form field, which is why creating a custom
server behavior is quite useful.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 06, 2006 Sep 06, 2006
Thanks for the help. Sorry David I don't use Dreamweaver8 and still on php4.

So I gather I will need to set up a variable $error first but do I still use key_array_exists()
Sorry for being a noob I am very slowly learning php and mysql.
I would love to learn much quicker.
Thanks again
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2006 Sep 07, 2006
jjjhbj111 wrote:
> Thanks for the help. Sorry David I don't use Dreamweaver8 and still on php4.

The necessary code needs to be inserted by hand or using the Server
Behavior Builder, which is also in MX 2004 (and possible MX, too). The
code involved is compatible with both PHP 4 and PHP 5.

> So I gather I will need to set up a variable $error first but do I still use
> key_array_exists()

Personally, I think that the code Murray gave you is unnecessarily
complex for this scenario. Follow the pattern that I gave you and test
it to see how it works.

If you're still at the beginning stages of PHP, you would probably get a
lot out of my book, even if you're using MX 2004. Chapters 5 and 6 are
devoted entirely to hand coding, and most of the Dreamweaver server
behaviors are common to MX 2004 and DW8.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2006 Sep 07, 2006
> Personally, I think that the code Murray gave you is unnecessarily complex
> for this scenario.

<input name="firstname" type="text" id="firstname" value="<?php
echo(array_key_exists('firstname',$_POST))?$_POST['firstname']:'Enter Your
First Name'); ?>">

There's no doubt! It's home-grown.... 8)

You recommend this -

<input value="<?php if (isset($_POST['first_name'])) {
echo $_POST['first_name'];} ?>" type="text" name="first_name"
id="first_name" />

Is there any real difference (other than the letter count) in using
array_key_exists() and isset()?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:edoo03$k40$1@forums.macromedia.com...
> jjjhbj111 wrote:
>> Thanks for the help. Sorry David I don't use Dreamweaver8 and still on
>> php4.
>
> The necessary code needs to be inserted by hand or using the Server
> Behavior Builder, which is also in MX 2004 (and possible MX, too). The
> code involved is compatible with both PHP 4 and PHP 5.
>
>> So I gather I will need to set up a variable $error first but do I still
>> use key_array_exists()
>
> Personally, I think that the code Murray gave you is unnecessarily complex
> for this scenario. Follow the pattern that I gave you and test it to see
> how it works.
>
> If you're still at the beginning stages of PHP, you would probably get a
> lot out of my book, even if you're using MX 2004. Chapters 5 and 6 are
> devoted entirely to hand coding, and most of the Dreamweaver server
> behaviors are common to MX 2004 and DW8.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2006 Sep 07, 2006
Murray *ACE* wrote:
> Is there any real difference (other than the letter count) in using
> array_key_exists() and isset()?

I don't think so. As you will know from my books, I tend to use
array_key_exists() to control the code that runs after a form has been
submitted. It's a technique that I have used for several years, so I
stick with it. Using isset() should work equally well.

What I find unnecessarily complicated about the code you suggest is not
so much the use of array_key_exists(), but the use of the conditional
operator. Although I tend to use the conditional operator quite
frequently myself, I remember that it took me a long time to understand
what it meant. When teaching beginners, using if... else is much easier
for them to understand. In the case of form validation, you rarely need
to have a default value for a text field, so if
(isset($_POST['whatever'])) is all you need.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2006 Sep 07, 2006
Thanks....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:edp05q$t4j$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Is there any real difference (other than the letter count) in using
>> array_key_exists() and isset()?
>
> I don't think so. As you will know from my books, I tend to use
> array_key_exists() to control the code that runs after a form has been
> submitted. It's a technique that I have used for several years, so I stick
> with it. Using isset() should work equally well.
>
> What I find unnecessarily complicated about the code you suggest is not so
> much the use of array_key_exists(), but the use of the conditional
> operator. Although I tend to use the conditional operator quite frequently
> myself, I remember that it took me a long time to understand what it
> meant. When teaching beginners, using if... else is much easier for them
> to understand. In the case of form validation, you rarely need to have a
> default value for a text field, so if (isset($_POST['whatever'])) is all
> you need.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 14, 2006 Sep 14, 2006
Hi thanks guys I have been trying ideas and but I don't seem to be having any success with the form returning with the fields to be filled. So I am thinking I need to do this:
Somewhere above the form to place a
if(isset($_POST['send']))
{
$formfield = $_POST[''];
$formfield['Name'] || $formfield['Address'] || $formfield['Phone']
} else if(trim($formfield) == '')
{
echo ' You need to fill this section please'
}
; ?>

Where send is the name of the form button - submit.
I figure I need to place trim() to preserve white space but not sure if its needed.

I also have a search text field that works really well but with using $_GET and need to have it return so that the user actually places a search word.
I can do all of these forms with the javascript script I have but I want to learn how to hard code this using php in case someone has javascript turned off.

Sometimes when I try these conditionals I am getting testing server errors with dreamweaver.
Hope this makes sense above, I am sure it will finally sink in.

Also one last question, just regarding sequence of events with code on the page. Is this the appropriate way -
1: Connection
2: Session Start
3: Restrict Access or Log In Behaviour
4: Log Out Behaviour
5: All recordsets
6: Conditional Form Data
7: Email To ? On Form Submission
8: Insert/Update Form Data
9: The Actual Form

Just want to make sure I am placing it all in the right way. I am not sure whether it makes a difference or not.
Thanks - many questions.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 30, 2006 Sep 30, 2006
Crickey I give up I think I will have to use javascript.
I have honestly been trying everything possible. I have gone to so many forums and read so many books and everything I try won't work with dreamweaver mx 2004. I have tried some of the code on a normal php page without dreamweaver input and it works but for the life of me I can't get the form to return and with input or errors.
Does anybody know how to trick dreamweaver to allow me to place the conditional data in the insert form?
The update record is ok because it already has input.
Hope somebody knows how to actually have the form return, thanks. this is the last part of my web design program.
Sorry to be a pain if I am taking so long to understand.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2006 Sep 30, 2006
jjjhbj111 wrote:
> I have honestly been trying everything possible. I have gone to so many forums
> and read so many books and everything I try won't work with dreamweaver mx
> 2004.

You've obviously not read mine, because this technique is covered in
detail in both "PHP Web Development with Dreamweaver MX 2004" and
"Foundation PHP for Dreamweaver 8". Both books show you how to create
Sticky Text Field and Sticky Text Area server behaviors to speed up the
process.

It's extremely simple. Above the DOCTYPE:

<?php
if (array_key_exists('submit', $_POST)) {
$name = trim($_POST['name']);
if (empty($name)) {
$error['name'] = 'Please enter your name';
}
}

if (!isset($error)) {
// Dreamweaver insert record code goes here

// if the form is to be displayed again after the record
// has been inserted, add this just before the closing brace

// if the record has been inserted, clear the POST array
$_POST = array();
}
?>

Above the form:

<?php
if ($error) {
echo '<ul>';
foreach ($error as $alert) {
echo "<li class='warning'>$alert</li>\n";
}
echo '</ul>';
}
?>

In the form itself:

<p>
<label for="name">Name:</label>
<br />
<input value="<?php if (isset($_POST['name'])) {
echo htmlentities($_POST['name']);} ?>" type="text" name="name" id="name" />
</p>

If your server uses magic quotes, you also need to pass each $_POST
variable to stripslashes() before redisplaying it.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 01, 2006 Oct 01, 2006
I don't know why all the messages keep getting repeated on this forum.
But hey thank you so much I am really impressed and it got me to think outside the box I was in.
Yes I am getting your book from Borders Book Store next week, but I didn't see the Foundation PHP for Dreamweaver 8 but I am sure I can order it.
By the way would it matter that I use Dreamweaver 4 not 8???
I understand much better now, the part checking if there is no error to allow Dreamweaver to submit the form, I didn't do that and the section where you clear the POST array, I would never have thought of that and don't recall reading about it on php.net (I must have missed something).
What does that do $_POST=array() is that mean you are not posting any more things so it doesn't loop?
Just wanting to get a better understanding of the way it works......
I also worked out how to check for duplicates in the database by your method.........just brilliant........I wasn't going to achieve results with the conditionals I was placing.
Just one more question and maybe it is in your book that I am purchasing, but if I have given a value to multiple inserts such as to checkboxes or a list box, do I do it the same per each element within???

Thank you so much for your help you are a dynamic wizard........
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 02, 2006 Oct 02, 2006
jjjhbj111 wrote:
> Yes I am getting your book from Borders Book Store next week, but I didn't see
> the Foundation PHP for Dreamweaver 8 but I am sure I can order it.
> By the way would it matter that I use Dreamweaver 4 not 8???

I think you would have considerable difficulty using my book with
Dreamweaver 4, since DW4 doesn't generate any PHP code. Although two
chapters in my book are devoted to hand coding, everything else
concentrates on Dreamweaver's automatic code generation.

> What does that do $_POST=array() is that mean you are not posting any more
> things so it doesn't loop?

It deletes everything in the $_POST array to prevent it from being
displayed in the page again.

> Just one more question and maybe it is in your book that I am purchasing, but
> if I have given a value to multiple inserts such as to checkboxes or a list
> box, do I do it the same per each element within???

I'm not quite sure what you mean. The important thing with multiple
elements is to add square brackets after the name attribute in the form.
This ensures that the multiple items are stored as an array.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines