Skip to main content
August 8, 2006
Question

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

  • August 8, 2006
  • 22 replies
  • 1258 views
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.
This topic has been closed for replies.

22 replies

October 14, 2006
Any suggestions? I can't understand how everything worked one day and now it doesn't work at all
Thanks for your time.
Inspiring
October 2, 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/
October 6, 2006
Help what am I doing wrong.
It worked perfectly yesterday, now it won't work at all. When you hit the submit button on the registration page, regardless of filling anything out it goes straight to the sign in page.
I will place the code, I have removed some contact details etc.
October 2, 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........
Inspiring
October 1, 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/
Inspiring
September 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/
Inspiring
September 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/
Inspiring
September 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/
Inspiring
September 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/
Inspiring
September 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/
Inspiring
September 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/