Forum Moderators: coopster
Here is the code below:
<?php
//passing the variable
$order_list=$_POST['order_list'];//Including the connection information
include "config.php";
//connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");
//select the database
mysql_select_db($database) or die ("Could not select database");
//Getting all the variables
$query = mysql_query ("SELECT * FROM clients WHERE order_id = ".$order_list, $link) or die("<center>There was an error and we could not load the Client list</center>");
//Putting the results in an array
$result = mysql_fetch_array($query);
?>
<div align="center">
<p><br>
<br>
<span class="style1"><u>Order Confirmation Form</u><br>
(Sales)
</span></p>
<form name="form1" method="post" action="update.php">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="left">Order Number: </div></td>
<td> </td>
<td><input name="order_id" type="text" value="<?php echo $result["order_id"];?>" maxlength="11" readonly="true">
<div align="left"></div></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td width="159" colspan="2"><div align="left">Date of Contact</div></td>
<td width="91"><div align="left">
<input name="date_req" type="text" id="date_req" value="<?php echo $result["date_req"];?>" maxlength="11" readonly="true">
</div></td>
<td width="91"> </td>
<td width="176"><div align="left">Phone:</div></td>
<td colspan="2"><div align="left">
<input name="client_phone" type="text" id="phone_num4" value="<?php echo $result["client_phone"];?>" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="left">Name:</div></td>
<td colspan="2"><div align="left">
<input name="client_name" type="text" id="name4" value="<?php echo $result["client_name"];?>" maxlength="50">
</div></td>
<td><div align="left">Fax:</div></td>
<td colspan="2"><div align="left">
<input name="client_fax" type="text" id="fax_num5" value="<?php echo $result["client_fax"];?>" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="left">Company:</div></td>
<td colspan="2"><div align="left">
<input name="client_company" type="text" id="company4" value="<?php echo $result["client_company"];?>" maxlength="50">
</div></td>
<td><div align="left">Department:</div></td>
<td colspan="2"><div align="left">
<input name="client_department" type="text" id="client_department2" value="<?php echo $result["client_department"];?>" size="20" maxlength="50">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="left">Address: </div></td>
<td colspan="2"><div align="left">
<textarea name="client_address" cols="20" rows="1" id="textarea6"><?php echo $result["client_address"];?></textarea>
</div></td>
<td><div align="left"></div></td>
<td colspan="2"><div align="left"></div></td>
</tr>
<tr>
<td colspan="2"><div align="left">City:</div></td>
<td colspan="2"><div align="left">
<input name="client_city" type="text" id="city4" value="<?php echo $result["client_city"];?>" maxlength="50">
</div></td>
<td><div align="left">Website:</div></td>
<td colspan="2"><div align="left">
<input name="client_website" type="text" id="website5" value="<?php echo $result["client_website"];?>" maxlength="50">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="left">State: </div></td>
<td colspan="2"><div align="left">
<select name="client_state" size="1" id="select4">
<option value="<?php echo $result["client_state"];?>"><?php echo $result["client_state"];?></option>
<option value="Alaska">AK - Alaska</option>
<option value="Arizona">AZ - Arizona</option>
<option value="Arkansas">AR - Arkansas</option>
<option value="California">CA - California</option>
<option value="Colorado">CO - Colorado</option>
<option value="Connecticut">CT - Connecticut</option>
<option value="Delaware">DE - Delaware</option>
<option value="District of Columbia">DC - District of Columbia</option>
<option value="Florida">FL - Florida</option>
<option value="Georgia">GA - Georgia</option>
<option value="Hawaii">HI - Hawaii</option>
<option value="Idaho">ID - Idaho</option>
<option value="Illinois">IL - Illinois</option>
<option value="Indiana">IN - Indiana</option>
<option value="Iowa">IA - Iowa</option>
<option value="Kansas">KS - Kansas</option>
<option value="Kentucky">KY - Kentucky</option>
<option value="Louisiana">LA - Louisiana</option>
<option value="Maine">ME - Maine</option>
<option value="Maryland">MD - Maryland</option>
<option value="Massachusetts">MA - Massachusetts</option>
<option value="Michigan">MI - Michigan</option>
<option value="Minnesota">MN - Minnesota</option>
<option value="Mississippi">MS - Mississippi</option>
<option value="Missouri">MO - Missouri</option>
<option value="Montana">MT - Montana</option>
<option value="Nebraska">NE - Nebraska</option>
<option value="Nevada">NV - Nevada</option>
<option value="New Hampshire">NH - New Hampshire</option>
<option value="New Jersey">NJ - New Jersey</option>
<option value="New Mexico">NM - New Mexico</option>
<option value="New York">NY - New York</option>
<option value="North Carolina">NC - North Carolina</option>
<option value="North Dakota">ND - North Dakota</option>
<option value="Ohio">OH - Ohio</option>
<option value="Oklahoma">OK - Oklahoma</option>
<option value="Oregon">OR - Oregon</option>
<option value="Pennsylvania">PA - Pennsylvania</option>
<option value="Rhode Island">RI - Rhode Island</option>
<option value="South Carolina">SC - South Carolina</option>
<option value="South Dakota">SD - South Dakota</option>
<option value="Tennessee">TN - Tennessee</option>
<option value="Texas">TX - Texas</option>
<option value="Utah">UT - Utah</option>
<option value="Vermont">VT - Vermont</option>
<option value="Virginia">VA - Virginia</option>
<option value="Washington">WA - Washington</option>
<option value="West Virginia">WV - West Virginia</option>
<option value="Wisconsin">WI - Wisconsin</option>
<option value="Wyoming">WY - Wyoming</option>
</select>
</div></td>
<td><div align="left">Email:</div></td>
<td colspan="2"><div align="left">
<input name="client_email" type="text" id="email4" value="<?php echo $result["client_email"];?>" maxlength="50">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="left">Zip:</div></td>
<td colspan="2"><div align="left">
<input name="client_zip" type="text" id="zip4" value="<?php echo $result["client_zip"];?>" maxlength="5">
</div></td>
<td colspan="2" align="left"><div align="left">Date Production Dept. called: </div></td>
<td width="282" align="left"><div align="right">
<input name="date_contacted " type="text" id="date_production" value="<?php echo date('M d Y');?>" maxlength="10">
</div></td>
</tr>
<tr>
<td colspan="2"> </td>
<td colspan="2"> </td>
<td colspan="3" align="left"> </td>
</tr>
</table>
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="left"><br>
<strong>Standard Deliverables Agreed To: </strong> * Please (√) Check All Features That Apply...<br>
<?php
//passing the variable
$order_list=$_POST['order_list'];
//Including the connection information
include "config.php";
//connect to the mysql server
$link2 = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");
//select the database
mysql_select_db($database) or die ("Could not select database");
//Getting all the variables
$query2 = mysql_query ("SELECT * FROM orders WHERE order_id = ".$order_list, $link2) or die("<center>There was an error and we could not load the Order list</center>");
//Putting the results in an array
$result2 = mysql_fetch_array($query2);
?>
<input name="on_camera" type="checkbox" value="1" <?php
if($result2["on_camera"] == "1") {
echo "checked";
}
?>
>
On-Camera Talent, and Voiceovers Studio Talent provided upon request<br>
<input name="graphics_animation" type="checkbox" value="1" <?php
if($result2["graphics_animation"] == "1") {
echo "checked";
}
?>
</div></td></tr>
</table>
<p><br>
<br>
<br>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
<strong><br>
</strong></div>
The other issue is with the checkboxes:
<input name="on_camera" type="checkbox" value="1" <?php
if($result2["on_camera"] == "1") {
echo "checked";
}
?>
Even with the $result2 equal to 1 it doesnt always display the check after the second time I update the page by clicking the update button. Meaning if I uncheck or check it, it writes back to the database correctly but if I pull sthe page up again through the search the boxes that I unchecked might still be check and the boxes I checked are no longer checked. I go into the database and the entery is the correct one.
Here is my update code for that:
$client_id='';
$client_name=$_POST['client_name'];
$client_company=$_POST['client_company'];
$client_address=$_POST['client_address'];
$client_city=$_POST['client_city'];
$client_state=$_POST['client_state'];
$client_zip=$_POST['client_zip'];
$client_ph=$_POST['client_phone'];
$client_email=$_POST['client_email'];
$order_id=$_POST['order_id'];
$date_contacted = date("F j, Y"); // if field is not empty
if (isset($_POST['client_fax'])) {
// set the value
$client_fax = $_POST['client_fax'];
// if it is empy
} else {
// set the value to NULL
$client_fax = '0000000000';
}
// if field is not empty
if (isset($_POST['client_department'])) {
// set the value
$client_department = $_POST['client_department'];
// if it is empy
} else {
// set the value to NULL
$client_department = 'None';
}
// if field is not empty
if (isset($_POST['client_website'])) {
// set the value
$client_website = $_POST['client_website'];
// if not checked
} else {
// set the value to NULL
$client_website = '0';
}
// if checkbox is checked
if (isset($_POST['on_camera'])) {
// set the value
$on_camera = $_POST['on_camera'];
// if not checked
} else {
// set the value to NULL
$on_camera = '0';
}
// if checkbox is checked
if (isset($_POST['graphics_animation'])) {
// set the value
$graphics_animation = $_POST['graphics_animation'];
// if not checked
} else {
// set the value to NULL
$graphics_animation = '0';
}
//if no name entered send an error
if (empty($client_name)){
die("<center>No name was entered.<br>Please hit your back button in your browser and include your name.</center><BR>");
}
//if no email entered send an error
if (empty($client_email)){
die("<center>No email was entered.<br>Please hit your back button in your browser<BR> and include your email address.</center><BR>");
}
//if no company entered send an error
if (empty($client_company)){
die("<center>No company name was entered.<br>Please hit your back button in your browser<BR> and include your companie's name.</center><BR>");
}
//if no address entered send an error
if (empty($client_address)){
die("<center>No address was entered.<br>Please hit your back button in your browser<BR> and include your address.</center><BR>");
}
//if no city entered send an error
if (empty($client_city)){
die("<center>No city was entered.<br>Please hit your back button in your browser<BR> and include the city your business is in.</center><BR>");
}
//if no zip entered send an error
if (empty($client_zip)){
die("<center>No zip code was entered.<br>Please hit your back button in your browser<BR> and include the zip code.</center><BR>");
}
//if no phone entered send an error
if (empty($client_ph)){
die("<center>No phone number was entered.<br>Please hit your back button in your browser<BR> and include your phone number.</center><BR>");
}
//Including the connection information
include "config.php";
//connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");
//select the database
mysql_select_db($database) or die ("Could not select database");
//update table orders
$query_orders = mysql_query("UPDATE orders SET on_camera='$on_camera', graphics_animation='$graphics_animation' WHERE order_id=$order_id") or die("There was a order error:" .mysql_error ());
//Close first connection
mysql_close();
//Including the connection information
include "config.php";
//connect to the mysql server
$link2 = mysql_connect($server, $db_user, $db_pass) or die("Could not connect to MySQL");
//select the database
mysql_select_db($database) or die ("Could not select database");
//update table clients
$query_clients = mysql_query ("UPDATE clients SET client_name='$client_name', client_company='$client_company', client_department='$client_department', client_address='$client_address', client_city='$client_city', client_state='$client_state', client_zip='$client_zip', client_phone='$client_ph', client_fax='$client_fax', client_website='$client_website', client_email='$client_email' WHERE order_id=$order_id") or die("There was a client error:" .mysql_error ());
//$result2 = mysql_query($query_clients) or die( "An error has ocured: " .mysql_error ());
mysql_close();
Any help would be greatly appreciated!
Modern Merlin
P.S. Sorry if the style code isnt right, new here...
If you are talking about the phone text box problem it adds an actual phone number: 2147483647 which I never entered... I enter my cell number or a full string of 1s for testing purposes, but it either always fills it in with a 0 or that phone number...
Thanks again for your prompt response!
Modern Merlin
[edited by: Modern_Merlin at 8:40 am (utc) on Nov. 15, 2007]
This part of your code might be simply running when you need it and when you don't need it.
//Getting all the variables
$query = mysql_query ("SELECT * FROM clients WHERE order_id = ".$order_list, $link) or die("<center>There was an error and we could not load the Client list</center>");//Putting the results in an array
$result = mysql_fetch_array($query);
Restrict it to the following:
if ($order_list <> '') {
//Getting all the variables
$query = mysql_query ("SELECT * FROM clients WHERE order_id = ".$order_list, $link) or die("<center>There was an error and we could not load the Client list</center>");
//Putting the results in an array
$result = mysql_fetch_array($query);
}
The if condition will ensure that the query doesn't run when your order_id is empty.
Let me know if this works for you.
//Putting the results in an array
$result = mysql_fetch_array($query);
}
Ok tried that and still nothing... Forgot to add the next page it goes to actualy displays each field and the phone field is displaying correctly, it just inst updating the DB. And for that matter even when I insert it in the original page it inserts with that wacky number. LOL
BTW! HAPPY 3 YEAR ANNIVERSARY! (look at the date you joined the forum LOL)
Remember when I apologized for so much code? Believe it or not I left some of it out... Well the issue with the check boxes has been resolved, I forgot to make all the boxes autofill from the DB even if they technically hadnt been filled out yet ... And then I also realized I had one box that in the code there was a space! Of course this was all in the code I left out :: shakes head :: LOL
So now the only thing that I need to figure out is how to get rid of that stupid phone number that I have never even heard of before!
---------------
//Getting all the variables
$query = mysql_query ("SELECT * FROM clients WHERE order_id = ".$order_list, $link) or die("<center>There was an error and we could not load the Client list</center>");
//echo the query
echo $query;
---------------
The other thing to do is copy and paste your query directly into a query browser (or sql command line) and run it, substituting $order_list, with an actual value. Look at the results and see if it comes out with the false number.