Jump to content

brosskgm

Members
  • Posts

    54
  • Joined

  • Last visited

Everything posted by brosskgm

  1. What file would I put this in? Thanks
  2. Sorry. There wasn't much in there and I wasn't sure if it would have been needed. Search.php <?php require_once "dbConnect.php"; Class Search { private $ResultArray, $numRows; public function __construct() { if ($_GET['s']) { $safeQuery = mysql_real_escape_string($_GET['s']); $theQuery = "SELECT * from parts WHERE part_num LIKE '%$safeQuery%' OR dealer LIKE '%$safeQuery%' OR retail LIKE '%$safeQuery%' OR uom LIKE '%$safeQuery%' OR page LIKE '%$safeQuery%' OR product_desc LIKE '%$safeQuery%'"; $res = mysql_query($theQuery); $this->numRows = mysql_num_rows($res); $i = 0; while ($result = mysql_fetch_array($res)) { $this->ResultArray[$i] = $result; $i++; } } else { $this->numRows = -1; } } public function getResult() { return $this->ResultArray; } public function getNumRows() { return $this->numRows; } public function __destruct() { mysql_close(); } } ?>
  3. I have some PHP/Java code that was written for me that searches and displays an item(s) costs etc. Similar to a parts store but with a eCart twist. This was so long ago that I'm no longer able to contact the coder. He no longer in school and they can't tell you were he went to. I guess he got a good grade for the project and got hired. I only have about 20-25 items in the database. Can someone tell here where in the attached code I can tell it to display all the contents of the database with out using the search but leaving all the other functions usable? If you need any other files not in the attachment, let me know. There are several more, but these were most of the php files in the main directory. Thanks in advance. Bob Ross 18055_.zip
  4. I almost forgot, This is the part that calls it. <?php require_once "template.php"; require_once "Search.php"; require_once "Cookie.php"; $Cookie = new Cookie(); $Search = new Search(); $ResultArray = $Search->getResult(); $template = new Template(); $template->ResultArray = $ResultArray; $template->numRows = $Search->getNumRows(); $template->SearchPage(); $template->Generate(); unset($template); unset($Search); ?>
  5. I didn't write this, it was made for me to lookup parts and costs. <?php require_once "config.php"; require_once "recaptcha-php-1.11/recaptchalib.php"; global $captchaPublicKey; Class Template { public $ResultArray, $numRows = 0; private $tmpCurr; public function SimpleGenerate() { echo $this->tmpCurr; } public function Generate() { $captcha = new CaptchaKeys(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <LINK REL="StyleSheet" HREF="style.css" TYPE="text/css"> <LINK REL="StyleSheet" HREF="thickbox.css" TYPE="text/css"> <script type="text/javascript" src="jquery-1.6.4.min.js"></script> <script type="text/javascript" src="thickbox-compressed.js"></script> <script type="text/javascript" src="http://www.google.com/recaptcha/api/js/recaptcha_ajax.js?legacy"></script> <script language="javascript"> function removeItem (ItemId) { $('#removeImg-'+ItemId).attr("src","img/loader.gif"); $.get("deleteCart.php",{id:ItemId},function(result) { $('#'+ItemId).html(" "); $("#totalPrice").html(result); }); } function updateItem (ItemId) { $("#loading-"+ItemId).html('<img src="img/loader.gif"/>'); $.get("updateQuantity.php",{id:ItemId,q:$("#quantity-"+ItemId).val()},function(result){ $("#total-"+ItemId).html(result); $("#loading-"+ItemId).html(" "); $("#totalPriceLoading").html('<img src="img/loader.gif"/>'); $.get("totalPrice.php",{},function(result){ $("#totalPrice").html(result); $("#totalPriceLoading").html(' '); }); }); } function updateInfo () { $("#loading-info").html('<img src="img/loader.gif"/> Updating...'); $.get("updateInfo.php",{email:$("#mail").val(),name:$("#name").val(),address:$("#address").val(),city:$("#city").val(),state:$("#state").val(),zip:$("#zip").val(),phone:$("#phone").val()},function(result){ if (result == "Mail Error") { $("#error-info").html('* Please enter a valid mail address'); } if (result == "Mail Success") $("#error-info").html(''); $("#loading-info").html(''); }); } function Finish () { $("#mainloading").html('<img src="img/loader.gif"/>'); $.post("Finish.php",{recaptcha_challenge_field: Recaptcha.get_challenge(),recaptcha_response_field: Recaptcha.get_response()},function (result) { if (result == "Error") { $("#mainloading").html('<b>Please Enter Correct Code</b>'); Recaptcha.reload(); } else { $("#main").html(result); } }); } function FinishNoVal () { $("#mainloading").html('<img src="img/loader.gif"/>'); $.post("Finish.php",{},function (result) { $("#main").html(result); Recaptcha.create("<?=$captcha->getPublic()?>","Captcha",{theme: "white", callback: Recaptcha.focus_response_field}); }); } </script> </head> <body> <?=$this->tmpCurr?> </body> </html> <?php } public function SearchPage() { $this->tmpCurr = ' <div id="search"> <form action="index.php" method="GET"> Search: <input type="text" value="'.htmlentities($_GET['s']).'" name="s"/> <input type="submit" value="Search!"/> </form> </div> <br/>'; if ($this->numRows == 0) { $this->tmpCurr .= "No result"; } elseif ($this->numRows > 0) { $this->tmpCurr .= ' <div id="table_container"> <div id="table_row"> <div id="table_cell" class="header">Part #</div> <div id="table_cell" class="header">Dealer Cost</div> <div id="table_cell" class="header">Markup</div> <div id="table_cell" class="header">Retail Cost</div> <div id="table_cell" class="header">UOM Type</div> <div id="table_cell" class="header">Page#</div> <div id="table_cell" class="header">Description</div> <div id="table_cell" class="header">Add</div> </div>'; $markup = new Markup(); for ($i = 0; $i < $this->numRows; $i++) { $this->tmpCurr .= ' <div id="table_row"> <div id="table_cell" class="cell">'.$this->ResultArray[$i]['part_num'].'</div> <div id="table_cell" class="cell">'.number_format(round($this->ResultArray[$i]["dealer"], 2), 2).'</div> <div id="table_cell" class="cell">'.number_format(round($markup->Calc($this->ResultArray[$i]["dealer"]) , 2), 2).'</div> <div id="table_cell" class="cell">'.number_format(round($this->ResultArray[$i]["retail"], 2), 2).'</div> <div id="table_cell" class="cell">'.$this->ResultArray[$i]['uom'].'</div> <div id="table_cell" class="cell">'.$this->ResultArray[$i]['page'].'</div> <div id="table_cell" class="cell">'.$this->ResultArray[$i]['product_desc'].'</div> <div id="table_cell" class="cell"><a class="thickbox" href="addCart.php?id='.$this->ResultArray[$i]["id"].'&height=480">Add to cart</a></div> </div>'; } // end for $this->tmpCurr .= '</div>'; } //end No Result else } public function ListItems ($list) { $this->tmpCurr = '<div id="main"><div id="listtable_container"><div class="table_row"><div id="table_cell">Item #</div><div id="table_cell">Description</div><div id="table_cell">Quantity</div><div id="table_cell">Markup</div><div id="table_cell">Total</div><div id="table_cell">Remove</div></div>'; $ItemsArray = $list->ListItems(); if ($ItemsArray) { $markup = new Markup(); foreach ($ItemsArray as $key=>$Item) { $this->tmpCurr .= '<div id="'.$Item->id.'" class="table_row"><div id="table_cell">'.$Item->partnum.'</div><div id="table_cell">'.$Item->description.'</div><div id="table_cell"><input type="text" onChange="updateItem(\''.$Item->id.'\');" style="width:25px" id="quantity-'.$Item->id.'" value="'.$Item->quantity.'"/><span id="loading-'.$Item->id.'"></span></div><div id="table_cell">'.number_format(round($markup->Calc($Item->price),2),2).'</div><div id="table_cell"><span id="total-'.$Item->id.'">'.number_format(round($markup->Calc($Item->price),2)*$Item->quantity,2).'</span></div><div id="table_cell"><a href="javascript:removeItem(\''.$Item->id.'\')"><img border="0" id="removeImg-'.$Item->id.'" src="img/delete.gif"/></a></div></div>'; } } $this->tmpCurr .= '</div>'; $this->tmpCurr .= '<div id="dtotalPrice"><span id="totalPriceLoading"></span> Total Price: <span id="totalPrice">'.number_format($list->totalPrice(),2).'</span></div>'; $this->tmpCurr .= '<div class="leftSide" id="listtable_container">' . '<div class="table_row"><div id="table_cell">Email:</div> <div id="table_cell"><input value="'.$list->getEmail().'" onChange="updateInfo();" type="text" id="mail" /> </div></div>' . '<div class="table_row"><div id="table_cell">Name:</div> <div id="table_cell"><input value="'.$list->getName().'" onChange="updateInfo();" type="text" id="name" /></div></div>' . '<div class="table_row"><div id="table_cell">Address:</div> <div id="table_cell"><input value="'.$list->getAddress().'" onChange="updateInfo();" type="text" id="address" /></div></div>' . '<div class="table_row"><div id="table_cell">City:</div> <div id="table_cell"><input value="'.$list->getCity().'" onChange="updateInfo();" type="text" id="city" /></div></div>' . '<div class="table_row"><div id="table_cell">State:</div> <div id="table_cell"><input value="'.$list->getState().'" onChange="updateInfo();" type="text" id="state" /></div></div>' . '<div class="table_row"><div id="table_cell">ZipCode:</div> <div id="table_cell"><input value="'.$list->getZip().'" onChange="updateInfo();" type="text" id="zip" /></div></div>' . '<div class="table_row"><div id="table_cell">Phone:</div> <div id="table_cell"><input value="'.$list->getPhone().'" onChange="updateInfo();" type="text" id="phone" /></div></div>' . '</div>' . '<span id="loading-info"></span><br/><span id="error-info"></span>'; $this->tmpCurr .= '<div id="continue"><input onClick="tb_remove();" style="height:30px;padding:5px" type="button" value="Continue"></div> <div id="finish"><input style="height:30px;padding:5px;" type="button" OnClick="FinishNoVal();" value="Finish"/></div><div id="continue"><input type="button" value="Update Cart" style="height:30px;padding:5px"/></div>' . '</div>'; } public function captchaForm () { ?> Please enter the code:<br/> <form method="post" action="javascript:Finish()"> <span id="Captcha"></span> <input type="submit" value="Submit"/> <span id="mainloading"></span> </form> <?php } public function emailOutput($list) { $Items = $list->ListItems(); $html = '<table width="100%" border="0"><tr><td>Item #</td><td>Description</td><td>Quantity</td><td>Markup</td><td>Total</td></tr>'; $markup = new Markup(); foreach ($Items as $Item) { $html .= '<tr><td>'. $Item->partnum .'</td><td>' . $Item->description . '</td><td>' . $Item->quantity . '</td><td>' . number_format(round($markup->Calc($Item->price),2),2) . '</td><td>'.$Item->totalPrice.'</td></tr>'; } $html .= '</table><p align="right">Total Price: <b>' . number_format($list->totalPrice(), 2) . '</b></p>' . '<p align="left">' . '<table border="0">' . '<tr><td>Email:</td><td><b>' . $list->getEmail() . '</b></td></tr>' . '<tr><td>Name:</td><td><b>' . $list->getName() . '</b></td></tr>' . '<tr><td>Address:</td><td><b>' . $list->getAddress() . '</b></td></tr>' . '<tr><td>City:</td><td><b>' . $list->getCity() . '</b></td></tr>' . '<tr><td>State:</td><td><b>' . $list->getState() . '</b></td></tr>' . '<tr><td>ZipCode:</td><td><b>' . $list->getZip() . '</b></td></tr>' . '<tr><td>Phone:</td><td><b>' . $list->getPhone() . '</b></td></tr>' . '</table>' . '</p>'; return $html; } } ?>
  6. I have a template written for me on another project that searches a MySQL database. I'm moving this template to work with a database that only have 10 records in it and instead of having a search option I would just like it to automatically display the database when the page opens. Is this possible? The php page in close to 200 lines. This is the line of the code that has the search option. If you need more I can post it. Thanks Bob <div id="search"> <form action="parts.php" method="GET"> Search: <input type="text" value="'.htmlentities($_GET['s']).'" name="s"/> <input type="submit" value="Search!"/> </form> </div>
  7. Worked great with multiple file names selected. This will make things so much easier than typing the name of each file. Thank you again. Bob
  8. This little thing was no where to be fond on the internet. It will now. Now I'll be testing 6 file selections on one form and see how it does shortly.
  9. I'm really surprised the Web Builder people didn't want to tell me that. They said it required a different form processor to do that. Thank you so much. I've been banging my head trying to find something to work. Thanks Bob
  10. That was it. It's working. Wow!!, that easy.
  11. I tried param B1-File, FileUpload2 and also put txtB1-File, txtFileUpload2 in the cgi but those didn't work.
  12. It didn't send the name. Most likely I don't know what param to give it and put in the cgi so it process it.
  13. Ok. that's easy enough. Is there anything I need to do so it sends the file name selected with the submit button?
  14. Yes there is <form name="Form1" method="post" action="http://192.168.4.4/cgi-bin/GenerateRequest.cgi" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)">
  15. I'll look. The web builder does most of it.
  16. I use WYSIWYG Web Builder. They have a file upload option in their form wizard. But I don't want to upload the file. I only want the name of the selected file sent on submit. No matter what I try it keeps trying to send the file, or just sends a blank when I remove the var I've looked though the code and this is the only parts I can find that have anything to do with the file upload. There will be more than one select B1-File, B2-File, B3-File etc.... I put one here. I only want to get the file name that is selected not the file to be sent to the server. If someone knows of an easier way to use a file select/browse button and get the file name only and wouldn't mind sharing it. Thanks I have been searching for a solution and have not been able to find the one. Thanks Bob function ValidateForm1(theForm) { var extension = theForm.FileUpload2.value.substr(theForm.FileUpload2.value.lastIndexOf('.')); if ((extension.toLowerCase() != ".avi") && (extension.toLowerCase() != ".doc") && (extension.toLowerCase() != ".gif") && (extension.toLowerCase() != ".jpg") && (extension.toLowerCase() != ".mov") && (extension.toLowerCase() != ".mp3") && (extension.toLowerCase() != ".mp4") && (extension.toLowerCase() != ".mpeg") && (extension.toLowerCase() != ".pdf") && (extension.toLowerCase() != ".qt") && (extension.toLowerCase() != ".rtf") && (extension != "")) { alert("The \"FileUpload2\" field contains an unapproved filename."); theForm.FileUpload2.focus(); return false; } return true; } <body> <div id="container"> <input type="file" id="FileUpload2" class="Heading 5 <h5>" style="position:absolute;left:455px;top:592px;width:238px;height:22px;z-index:42" name="B1-File"> </form> </div> </body> </html>
  17. I'm still new at this, and this code was written for us. I would like to add a drop down selection box for bookings. <choice 1> <choice 2> <choice 3> etc. All the form pages are created dynamically. So this is where I'm a little lost. I can create all the files separately and not use this code, but would prefer to keep it if possible. I had to attach the files. They were to large to be pasted. 1st one is add.php, second is utils.php Thanks Bob [attachment deleted by admin]
  18. Really odd one, and I don't see it at all. It only gives the error on the screen and nothing else. Parse error: syntax error, unexpected T_STRING in forgot.php on line 74 Then in the error log it says syntax error, unexpected $end in forgot.php on line 124 Thanks in advance. Bob [attachment deleted by admin]
  19. This was written for me to replace the set of pages I had to create for each database. The new setup allows me to create a database in about 10 minutes and the add.php and add.php creates the form for me from the way it's listed under SUBDIR. I can create a database in about 10 minutes. Has been working flawless except that I can post code in a text box. Gets the form information. The page is to long. It errors out when I post it, so this is part of the section that uses it. // QueryData('names', $field_names); // date_worked // QueryData('values', $field_names, $data); // '1/1/1999' // QueryData('set', $field_names, $_POST); // date_worked = '1/1/1999' function QueryData($type, &$field_names, &$data) { $output_array = array(); foreach($field_names as $field) { if($field == 'id') { continue; } // skip id $field_value = isset($data[$field]) ? $data[$field] : ''; if($type == 'names') { $output_array[] = $field; } // date_worked else if($type == 'values') { $output_array[] = "'$field_value'"; } // '1/1/1999' else if($type == 'set') { $output_array[] = "$field = '$field_value'"; } // date_worked = '1/1/1999' } return join(', ', $output_array); } // DeletePhotos($id); // needs $id escaped // if SUBDIR has them, delete photo_upload and associated thumbnail for this id and $_SESSION['username'] // Assumes already connected to db, and $id has been escaped for db. function DeletePhotos($id) { global $fields; $field = 'photo_upload'; if(SUBDIR != 'contacts') { return; } // this SUBDIR doesn't have a photo_upload field $query = "SELECT * FROM `".SUBDIR."` WHERE id='$id' AND username='{$_SESSION['username']}'"; $result = mysql_query($query) or die("DeletePhotos: query failed<br>\n"); if(mysql_num_rows($result) == 1) { // if you got the row $data = mysql_fetch_assoc($result); $img_name = $data[$field]; $fname = HOME ."/". CONFIG_UPLOAD_DIR . "/{$_SESSION['username']}.$img_name"; // regular @unlink($fname); // delete the file. It's OK if $img_name is '' } else { die("No such record exists"); } }
  20. In your paypal setup make sure the notification URL points to signup.php and the web site payment preferences have auto return on also pointing to signup.php. All the code sent to you has the sandbox url for testing. I didn't put the live link in there. I believe there are two or three places just search for "sandbox" and remove it from the url when you go live.
  21. There is only a couple files that handle all the databases so I thought it was add. Here is added.php <?php require_once('../check_logged_in.php'); require_once('../utils.php'); require_once("../db.php"); if(!defined('ACTION')) { define('ACTION', 'ADDED'); } echo '<a href="index.php">Back to List</a><br>' . "\n"; // Prep the fields for db use. When this loop is done, variables will be created for each field // with the same name as the field (ie $id, $date_added, etc). // Prep the fields for db use. Data will be put in $data. $data = array(); foreach($fields as $index => $field_info) { $field = $field_info['name']; $type = $field_info['type']; $d = isset($_POST[$field]) ? $_POST[$field] : ''; if($type == 'date') { // Handle all date fields if(!IsValidDate($d)) { die("${field}[$d] must look like 1/1/1999 or 01/01/1999 (no extra whitespace)"); } // will do [9/8/1976] => [1976-9-8], then call mysql_real_escape_string() $d = MakeDBDate($d); } else if($field == 'photo_upload') { // Handle photo_upload // This will die if get invalid file or encounter any other issue. It will also create the // thumbnail. It returns the value to be stored in the db (it calls mysql_real_escape_string) $d = HandlePhotoUpload($field, $data); } else { // Handle all non-date non-photo_upload fields $d = mysql_real_escape_string($d); } $data[$field] = $d; } // now perform the query if(ACTION == 'ADDED') { //add $query = "INSERT INTO `".SUBDIR."` (id, username, ".QueryData('names', $field_names, $data).") ". "VALUES ('', '{$_SESSION["username"]}', " .QueryData('values', $field_names, $data). ")"; $results = mysql_query($query); if ($results) { echo "Details added."; } else { die("error adding details"); } } else { //update $query = "UPDATE `".SUBDIR."` SET " .QueryData('set', $field_names, $data). " WHERE id='{$data['id']}' AND username='{$_SESSION['username']}' "; $results = mysql_query($query); if ($results) { echo "Update successful."; } else { die("error updating details"); } } mysql_close(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.