Page 1 of 1

Can anyone help-Why this code does not fill fields on form

Posted: Tue Apr 01, 2008 12:45 pm
by crimmelcp
To All:
Can anyone help-Why this code does not fill fields on form

attached 2 files
vendor_look and vendor_check
Thanks
Charlie Crimmel
'-------------------------------------
Vendor_look

Code: Select all

<?php
 
$dbservertype='mysql';
$servername='localhost';
// username and password to log onto db server
$dbusername='root';
$dbpassword='';
// name of database
$dbname='po';
?>
 
<?php
 
    include(dirname(__FILE__)."/incCommon.php");
 
    include(dirname(__FILE__)."/header.php");
 
 
////////////////////////////////////////
////// DONOT EDIT BELOW  /////////
///////////////////////////////////////
connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){die("Could not connect to MySQL");}
mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////// End of connecting to database ////////
?>
 
<!doctype html public "-//w3c//dtd html 3.2//en">
 
<html>
 
<head>
<title>Vendor Drop Down list box </title>
 
    </style>
    <script type="text/javascript" src="/AJAX/ajax.js"></script>
    <script type="text/javascript">
<SCRIPT language=JavaScript>
function reload(form)
{
var val=form.Vendor.options[form.Vendor.options.selectedIndex].value;
self.location='Vendor_look.php?Vendor=' + val ;
}
 
</script>
</head>
 
<body>
</style>
<?php
 
/*
If register_global is off in your server then after reloading of the page to get the value of Vendor from query string we have to take special care.
To read more on register_global visit.
  http://www.plus2net.com/php_tutorial/re ... lobals.php
*/
@$Vendor=$_GET['Vendor_name']; // Use this line or below line if register_global is off
//@$Vendor=$HTTP_GET_VARS['Vendor_name']; // Use this line or above line if register_global is off
 
///////// Getting the data from Mysql table for first list box//////////
$quer2=mysql_query("SELECT DISTINCT Vendor_name,IDVendor FROM Vendor order by Vendor_name"); 
///////////// End of query for first list box////////////
 
echo "<form method=post name=f1 action='vendor_check.php'>";
 
/// Add your form processing page address to action in above line. Example  action=vendor_check.php////
//////////        Starting of first drop downlist /////////
echo "<select name='Vendor_name' onchange=\"reload(this.form)\"><option value=''>Select Vendor</option>";
while($noticia2 = mysql_fetch_array($quer2)) { 
if($noticia2['Vendor_name']==@$vendor){echo "<option selected value='$noticia2[Vendor_name]'>$noticia2[vendor_name]</option>"."<BR>";}
else{echo  "<option value='$noticia2[Vendor_name]'>$noticia2[Vendor_name]</option>";}
}
echo "</select>";
//////////////////  This will end the first drop down list ///////////
 
 
//// Add your other form fields as needed here/////
 
echo "</form>";
?>
<form action="Post" method="get">
Vendor ID:<input type="text" size="10" name="txtIDVendor" id="IDVendor" />
<p>
Name:<input type="text" size="25" name="txtvendname" id="vendname" />
<p>
Address1:<input type="text" size="25" name="txtaddress1" id="address1" />
<p>
Address2:<input type="text" size="25" name="txtaddress2" id="address2" />
<p>
City: <input type="text" size="15" name="txtcity" id="city" />
<p>
State: <input type="text" size="2" name="txtstate" id="state" />
<p>
ZIP code: <input type="text" size="15" name="txtzip" id="zip" />
</form>
 
</body>
 
</html>
'----------------------------------------
Vendor_check
 
<!doctype html public "-//w3c//dtd html 3.2//en">
 
<html>
 
<head>
<title>Demo Vendor drop down list box</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
 
<body>
<?
$vendor=$_POST['vendor'];
$vendorname=$_POST['vendor_name'];
 
echo "Value of \$vendor = $vendor <br>Value of \$vendorname = $vendorname ";
 
 
?>
 
</center> 
</body>
 
</html>

Re: Can anyone help-Why this code does not fill fields on form

Posted: Tue Apr 01, 2008 1:32 pm
by s.dot
Your variables have to be concatenated into the string properly. http://us2.php.net/manual/en/language.types.string.php

Re: Can anyone help-Why this code does not fill fields on form

Posted: Thu Apr 03, 2008 3:12 pm
by crimmelcp
i still need some help on this if anyone can show me some code

Thanks
Charlie Crimmel