|
Posted by "Mark Rees" on 07/21/05 14:19
>Hello Mark
>An alternative (and more user-friendly) approach is to have the form's
>action as itself (i.e. the form on contact.php submits to contact.php). You
>can then identify which fields are incomplete and highlight them in the
>form. This will make it easier for users to see what they have done wrong
>and make the necessary corrections.
>in regards to this response on my contact form issues, how would I do
>these which you mention.
>currentlly the form is:
><form method="post" action="Thankyou.php" class="info_request">
>and the Thankyou.php code consit of what I posted on the forum.
>thanks for all of your help!!
A sample set up is as follows, with much room for improvement and
refinement, but it should give you the basic idea.
contact.php
<?php
#check that the form has been posted
$email=isset($_POST['email'])?$_POST['email']:'';
$emailerror=false;
if($email!=''){
#basic validation passed, so redirect
header("Location: Thankyou.php");
}else{
$emailerror=true;
}?>
email<br>
<form method="post" action="contact.php" class="info_request">
<input type="text" name="email" value="<?=$email;?>"
<?
if($_POST){
#show the input with a red background if the form has been posted and
if($emailerror==true)print 'style="background-color:red;"';
}
?>>
<input type="submit" value="submit">
</form>
Navigation:
[Reply to this message]
|