[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

PHP Forms Populate and Save

Asked by bingie in PHP Scripting Language, PHP and Databases, Web Languages/Standards

Tags: php, form, populate

I have the following code to submit data to my database (programControl.php)

<html>
<head>

</head>

<body>
<h1>Book It Program Control Interface</h1>
<br>

<?

$db = mysql_connect("localhost","bookingapp","") or mysql_die("Unable to connect");
mysql_select_db("bookingapp",$db);
?>

<?php

if(isset($post)){

//get values from the form
$isValid = $_POST['isValid'];
$errString = $_POST['errString'];
$allowPassword = $_POST['allowPassword'];
$password = $_POST['password'];
$lockedOutText = $_POST['lockedOutText'];

$qry = mysql_query("insert into `tblProgramControl` (`isValid`, `errString`, `allowPassword`, `password`, `lockedOutText`) values ('$isValid', '$errString', '$allowPassword', '$password', '$lockedOutText')");
$result = mysql_query ($qry,$db);

               }
                 else
               {

 echo "<form method=\"post\" action=\"programControl.php\">
 Program is active?
 <input type=checkbox name=isValid><br>
 Message to display to program user:
 <input type=text name=errString><br>
 Allow password to unlock program?
 <input type=checkbox name=allowPassword><br>
 Password:
 <input type=text name=password><br>
 Text to display when locked out:
 <input type=text name=lockedOutText><br>
 <input type=submit name=post value=\"Submit\">
</form>";

         }

?>

</body>
</html>

---------------------------------------------------------------------------------------------------------------

This works correctly. The problem is in my editing page (programControlEDIT.php?id=51). Here is the code:

<html>
<head>

<?php

function mysql_die($error = "unknown")
{
echo "<H1>Error:". $error."</H1>";
   exit;
}

$db = mysql_connect("localhost","bookingapp","") or mysql_die("Unable to connect");
mysql_select_db("bookingapp",$db);


$req = "SELECT * FROM tblProgramControl WHERE id=".$id;
$requete = mysql_query($req);


$num=mysql_numrows($requete);

echo "<b>Your query return <font color=\"red\">$num</font> results.</b><br><br>";

$i=0;
while ($i < $num) {

$isValid = mysql_result($requete,$i,"isValid");
$errString = mysql_result($requete,$i,"errString");
$allowPassword = mysql_result($requete,$i,"allowPassword");
$password = mysql_result($requete,$i,"password");
$lockedOutText = mysql_result($requete,$i,"lockedOutText");

?>

</head>

<body>
<h1>Book It Program Control Interface</h1>
<br>

<?php

if(isset($post)){

//get values from the form
$isValid = $_POST['isValid'];
$errString = $_POST['errString'];
$allowPassword = $_POST['allowPassword'];
$password = $_POST['password'];
$lockedOutText = $_POST['lockedOutText'];

$qry = mysql_query("UPDATE `tblProgramControl` SET `isValid` = '$isValid', `errString` ='$errString', `allowPassword` = '$allowPassword', `password` = '$password', `lockedouttext` = '$lockedOutText' Where id = ".$id);
$result = mysql_query ($qry,$db);

}

else

{

 echo "<form method=\"post\" action=\"programControlEDIT.php\">
         Program Id:
             <input type=text name=id value=$id><br>
           Program is active?
               <input type=checkbox name=isValid value=$isValid><br>
           Message to display to program user:
               <input type=text name=errString value=$errString><br>
           Allow password to unlock program?
               <input type=checkbox name=allowPassword value=$allowPassword><br>
           Password:
               <input type=text name=password value=$password><br>
           Text to display when locked out:
               <input type=text name=lockedOutText value=$lockedOutText><br>
               <input type=submit name=post value=\"Submit\">
</form>";

}

$i++;

}

?>


</body>
</html>


Now, my two problems are
- The checkboxes are not populated correctly. Do i fix this with an IFF?
- The data is not being updated when I save the changes. How do I do that, ie make it update my changes?

Thanks in advance!
[+][-]04/21/07 04:24 PM, ID: 18952906Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: PHP Scripting Language, PHP and Databases, Web Languages/Standards
Tags: php, form, populate
Sign Up Now!
Solution Provided By: rdivilbiss
Participating Experts: 1
Solution Grade: A
 
[+][-]04/21/07 03:54 PM, ID: 18952848Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04/21/07 04:08 PM, ID: 18952869Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/05/08 06:04 AM, ID: 21718857Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]06/12/08 07:38 PM, ID: 21775362Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy