[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

PHP and html

Posted on 2000-05-04
4
Medium Priority
?
243 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

650 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