Solved

PHP and html

Posted on 2000-05-04
4
178 Views
Last Modified: 2006-11-17
I have one problem. I am having two pages. In first page if I leave some mantitoy fields empty and if I click submit. The same first page must be displayed with changing the color(to red) of the names of the manditory fields that are not filled but all other data in other fields must be there. I don't know how to do it. Since I am new to php and using PHP3. Please help me.
0
Comment
Question by:balasundaram
  • 2
4 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2779841
Try the form.php3 file


<?
function TestField($f)
{
if ($f == "")
      print "<font color='#FF0000'>";
}

$field_list = array("Name", "Firstname");

if ($REQUEST_METHOD == "POST")
{ for($i=0; $i<count($field_list);$i++)
  {     if ($$field_list[$i] == "")
          $err=true;
  }
  if ($err<>true)
     header("Location: confirm.php3");
}
?>

<form action="form.php3" method="post">
<?TestField($Name)?>Name</font>
<input type="text" value="<?print $Name?>" name="Name"><br>
<?TestField($Firstname)?>Firstname</font>
<input type="text" value="<?print $Firstname?>" name="Firstname"><br>
<input type="submit" value="submit" name="submit">
</form>
0
 

Author Comment

by:balasundaram
ID: 2788131
hello sir,

  your code works perfectly. but if I refresh the previous values are maintained. How I can overcome this problem?
0
 
LVL 8

Expert Comment

by:us111
ID: 2788445
Sure, when you refresh, you post again your data.
What do you need to do ?
0
 

Accepted Solution

by:
lar_aas earned 100 total points
ID: 2821793
<?
if (!(isset($have_doen_something))
  $have_doen_something = "nope";


if ($have_doen_something == "nope") {

 ## Do all your stuff

}
?>
<input type='hidden' name='have_doen_something' value='yes'>

This will in some cases be a workaround, but not always
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now