While the city slept, David (da********@gma il.com) feverishly typed...
hi
Ay up,
i have a basic signup POST form, with php on the same page. how do i
return to this page with all the entries still present, yet with a
message at the top, for when the user enters one invalid entry?
If you are posting the results to the page, then write them into the default
values for the input elements. Something like;
<html>
<head>
<!-- head stuff here -->
</head>
<body>
<?php
$defaultName = "Enter your name here"
$defaultEmail = "Enter your email address here"
$formError = false;
if($_POST['update'] == 1) {
$name = $_POST['name'];
$email = $_POST['email'];
if(($name == "") || ($email == "")) {
$formError = true;
print("<p>Error on form.</p>");
if($name == "") {
print("<p>Pleas e enter a value for Name</p>");
}
else {
$defaultName = $name;
}
if($email == "") {
print("<p>Pleas e enter a value for Email Address</p>");
}
else {
$defaultEmail = $email;
}
}
else {
print("<p>Thank s for your input!</p>");
// write the form contents to your database, or whatever
}
}
if ((!isset($updat e)) || ($formError)) {
?>
<form action = "thispage.php?u pdate=1" method="post">
<p>Name: <input type="text" name="name" value="<?=$defa ultName?>"></p>
<p>Email Address: <input type="text" name="email"
value="<?=$defa ultEmail?>"></p>
<input type = "submit" name="submit" value="Submit">
</form>
<?
}
?>
</body>
</html>
.... Note: This is straight off the top of my head! Not tested or anything!
Hope that helps,
Nige
--
Nigel Moss
http://www.nigenet.org.uk
Mail address not valid.
ni***@DOG.nigen et.org.uk, take the DOG. out!
In the land of the blind, the one-eyed man is very, very busy!