
bossman
Members-
Posts
98 -
Joined
-
Last visited
Never
Everything posted by bossman
-
admin question regarding, edit and delete function...
bossman replied to bossman's topic in PHP Coding Help
thats what i thought but i just needed the confirmation, i knew i was on the right track, THANK YOU!! -
Hi all, I am currently in the process of building an admin for a directory website we are currently working on.. here is a link to the admin... http://mediagenius.biz/test/hairlossdir/index_test_admin.php as you can see, there are 3 basic functions. Add, edit, and delete...universal among content management systems. The problem i am having, is that i stopped coding for a short while, and i need a point in the right direction regarding the edit and delete functions... so far the add function works fine. here is the code for the add... <? require("db_connect.php"); $new_name = $_POST['name']; $new_contact = $_POST['contact']; $new_streetaddress = $_POST['streetaddress']; $new_city = $_POST['city']; $new_state = $_POST['state']; $new_zipcode = $_POST['zipcode']; $new_country = $_POST['country']; $new_phonenumber = $_POST['phonenumber']; $new_email = $_POST['email']; $new_website = $_POST['website']; //query to insert files and info into database $query = "INSERT INTO hair_loss_clients (name, contact_name, street_address, city, state, zipcode, country, phone_number, email, website) VALUES ('$new_name', '$new_contact', '$new_streetaddress', '$new_city', '$new_state', '$new_zipcode', '$new_country', '$new_phonenumber', '$new_email', '$new_website' )"; $result=mysql_query($query); mysql_close($link); header("Location: http://mediagenius.biz/test/hairlossdir/index_test_admin.php"); ?> when i click the 'edit' button, i want it to pull in all the information into the text fields based on the id. I have done this before, but im not positive how to put the code together... i know that in the 'edit' link, i will have to pass the $id so that it knows which information to pull into the text fields...once i do that i know what to do... any help is appreciated!
-
thank you very much!!!! that helped alot!
-
hello all, haven't been in here in a while, took a break from developing but now im back at it and a bit rusty :/ i'm trying to write a query so that when a user clicks a link that says "A" , it will grab all the names in the database that start with an "A". I wanna do the same thing with the whole alphabet. Anyone have any suggestions on a query? something like "Select id, name, contact_name, street_address, city, state, zipcode, country, phone_number, email, website FROM hair_loss_clients ORDER BY name ASC ----- ??? " what would go at the end there to make it select only titles that start with "A"? THANK YOU IN ADVANCE!
-
yes that makes sense thank you!!!
-
hello all... i have a php calendar that we made, and when you click an event on it, a popup window opens up with all the event information in it. But...some of the events have a contact, and some dont... what i want to do is write an if, else statement to display the contact if it exists, and if it doesnt, display nothing... if (what do i put here) { echo "<div style='contact'><strong>• Contact</strong></div><br/><p class='show_desc'> ".$contact."</p>\n"; }else{ echo "<br />" } the question is in the example if statement above... what do i put there? the name of the column in my table is 'contact' (pretty simple) i assume it would be something like if $row['contact'] > 0 , but i think im wrong... any suggestions?
-
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
ok cool i thought maybe i was just looking too hard!! haha Thanks again for your help -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
o and i would li ke to mark this topic solved where is the new button at? still getting used to the new layout.. -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
omg i totally just did that and then i come back to the post and you had just posted to do exactly what i did hahahaha THIS WORKED PERFECT!! I APPRECIATE ALL YOUR HELP MAN! -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
hmm...that code is working. I slightly modified it, and im very close to getting the functionality i need. It's very cleanly and efficiently displaying the 'results from .. ' but it is still displaying the empty ones. <div style="font-family:Verdana, Geneva, sans-serif;font-size:14px;padding-left:20px;"> <?php echo (count($error) > 0)?"<br /><strong>The following had errors:</strong><br />" . implode("<br />", $error) . "<br /><br />":""; ?> <?php $search[0] = 'Results for <strong>'.$searchTerms[0].'</strong><br />'; $search[1] = 'Results for <strong>'.$searchTerms[1].'</strong><br />'; $search[2] = 'Results for <strong>'.$searchTerms[2].'</strong><br />'; $search[3] = 'Results for <strong>'.$searchTerms[3].'</strong><br />'; $search[4] = 'Results for <strong>'.$searchTerms[4].'</strong><br />'; $search[5] = 'Results for <strong>'.$searchTerms[5].'</strong><br />'; //echo (count($results) > 0)?"<br />Results for <strong>'{$searchTerms[0]}'</strong><br /><br />" . implode("", $results):""; echo (count($results) > 0)?''.$search[0].''.$search[1].''.$search[2].''.$search[3].''.$search[4].''.$search[5].'<br />'.implode("", $results):""; ?> </div> Here's a link. Search a city. Then when the results pop up, pick one and fill out all the information for it in the search box. It's picking up everything and displaying it, but theres still empty results strings up there. You think perhaps an if statement would be the way to go? http://wesco.jp-clients.com/fasttrack_locator/new_test/ -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
this seems right on track and makes perfect sense. I'm going to begin to implement this in ASAP THANK YOU SO MUCH FOR YOUR HELP!!!!!!!!! -
you might need to change some settings in your php.ini file. Or your not specifying your SMTP server correctly
-
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
i made some changes to my code.... go to the link again from above...(it is pasted again below).... http://wesco.jp-clients.com/fasttrack_locator/new_test/ go to the FIRST input at the top, and type in 'Pittsburgh'..... submit.... now look at what happens... got a bunch of "results for "" ". I want it to only display the "results for..." for whatever fields were entered...here's what i have tried so far... <?php echo (count($results) > 0)?"<br />Results for <strong>'{$searchTerms[0]}'</strong><br />" . "<br />Results for <strong>'{$searchTerms[1]}'</strong><br />" . "<br />Results for <strong>'{$searchTerms[2]}'</strong><br />" . "<br />Results for <strong>'{$searchTerms[3]}'</strong><br />" . "<br />Results for <strong>'{$searchTerms[4]}'</strong><br />" . "<br />Results for <strong>'{$searchTerms[5]}'</strong><br /><br />" . implode("", $results):""; ?> -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
displaying the "results for <strong>'{$searchTerms[0]}" isn't the problem. What i'm trying to figure out, is a code to write to make the page figure out which fields were entered, and only display "results for...." from the fields that text was entered into... lets say someone entered information into search0 and search1 on the form... once the search is submitted, it will display "results for (search0)" ....then skip to the next line and display "results for (search1)" .... if nothing is entered for search2 and search3 etc...then nothing is displayed because nothing was entered -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
hmm after further review im not sure if that code snippet will help. I have a feeling i need to manipulate this statement in some way... <?php echo (count($results) > 0)?"<br />Results for <strong>'{$searchTerms[0]}'</strong><br /><br />" . implode("", $results):""; ?> specifically im trying to get it so that no matter which field they enter some data into...(only at least one field is required), it will display "Results for '(whichever input they filled in to search)' " i tried manipulating the statement to include $searchTerms[0], $searchTerms[1], $searchTerms[2], etc..... Does this make more sense? How can i manipulate the statement above? Would it be a large if/else statement? Something like, "if searchTerms[0] is empty, display nothing, but if data is entered, display "results for $searchTerms[0]", and check to see if $searchTerms[1] contains any data" ...and so on and so on through all 5 fields... I appreciate the responses thus far but i feel that i wasnt elaborate enough on my original post and i apologize for that. -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
ok sweet im gonna give that a shot thanks for the reply! -
How to return user errors on multi-input search form?
bossman replied to bossman's topic in PHP Coding Help
ok i understand what your saying and it makes sense, but i think i perhaps worded my question wrong. It's not only for the errors, but for the "results for '(whichever field you entered)' ", trying to get that to be determined based on what inputs you entered. The user is not required to fill in all fields. -
Hello all, I have constructed a fairly simple search function using PHP, it can be seen here... http://wesco.jp-clients.com/fasttrack_locator/new_test/ I have managed to get the actual SEARCH function working great. You can fill in any of those fields and get the results your looking for. The problem that I'm having now tho....is how to return an error to the user if they have entered invalid information into any of the inputs. Having the multiple inputs for the form was not how it was originally. So in the beginning, I simply used this to return the error... <div style="font-family:Verdana, Geneva, sans-serif;font-size:14px;padding-left:20px;"> <?php echo (count($error) > 0)?"<br /><strong>The following had errors:</strong><br />" . implode("<br />", $error) . "<br /><br />":""; ?> <?php echo (count($results) > 0)?"<br />Results for <strong>'{$searchTerms[0]}'</strong><br /><br />" . implode("", $results):""; ?> </div> But now, having multiple inputs is making this a little more complicated. Feel free to run a few searches in the form to understand what I am talking about. Here is my code for the form itself (index.php) <div id="form_container"> <form method="GET" action="search.php" name="searchForm" style="padding-left:20px;padding-top:7px;"> <table width="400" cellpadding="0" cellspacing="0"> <tr> <td><label><strong>Branch Name:</strong></label></td> <td><input type="text" size="19" name="search0" value="<?php echo isset($searchTerms[0])?$searchTerms[0]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>Branch ID:</strong></label></td> <td><input type="text" size="19" name="search1" value="<?php echo isset($searchTerms[1])?$searchTerms[1]:''; ?>"/></input></td> </tr> <tr> <td><label><strong>Address:</strong></label></td> <td><input type="text" size="19" name="search2" value="<?php echo isset($searchTerms[2])?$searchTerms[2]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>State:</strong></label></td> <td><input type="text" size="19" name="search3" value="<?php echo isset($searchTerms[3])?$searchTerms[3]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>Company:</strong></label></td> <td><input type="text" size="19" name="search4" value="<?php echo isset($searchTerms[4])?$searchTerms[4]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>Region Code:</strong></label></td> <td><input type="text" size="19" name="search5" value="<?php echo isset($searchTerms[5])?$searchTerms[5]:''; ?>" /></input></td> </tr> </table><br/> <input type="Submit" id="Search" alt="Search" value="Search"> </form> </div> from there, the form passes to this page, which searches the database and returns results.... <?php $h="localhost"; $u="-----"; $p="-----"; $d="-----"; $link = mysql_connect ($h, $u, $p) or die ("Could not connect to database, try again later"); mysql_select_db($d, $link); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search0'])||isset($_GET['search1'])||isset($_GET['search2'])||isset($_GET['search3'])||isset($_GET['search4'])||isset($_GET['search5'])) { $searchTerms = array(); $searchTerms[0] = trim($_GET['search0']); $searchTerms[1] = trim($_GET['search1']); $searchTerms[2] = trim($_GET['search2']); $searchTerms[3] = trim($_GET['search3']); $searchTerms[4] = trim($_GET['search4']); $searchTerms[5] = trim($_GET['search5']); for ($i=0; $i<=5; $i++) { $searchTerms[$i] = strip_tags($searchTerms[$i]); // remove any html/javascript. if (strlen($searchTerms[$i]) < 2 && strlen($searchTerms[$i]) > 0) { $error[] = "<br />Search terms must be at least <strong>2</strong> characters."; } else { $searchTerms[$i] = mysql_real_escape_string($searchTerms[$i]); // prevent sql injection. } } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT id, name, branch_id, address, state, phone, fax, company, region_code FROM markers_csv WHERE "; // grab the search types. $types = array(); $types[0] = "`name` LIKE '%{$searchTerms[0]}%'"; $types[1] = "`branch_id` LIKE '%{$searchTerms[1]}%'"; $types[2] = "`address` LIKE '%{$searchTerms[2]}%'"; $types[3] = "`state` LIKE '%{$searchTerms[3]}%'"; $types[4] = "`company` LIKE '%{$searchTerms[4]}%'"; $types[5] = "`region_code` LIKE '%{$searchTerms[5]}%'"; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) //if (count($types) < 1) //$types[] = "`name` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked //$andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" AND ", $types) . " ORDER BY `name`"; // order by title. $searchResult = mysql_query($searchSQL) or die("<br />There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "<br />The search term '<strong>{$searchTerm}</strong>' yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "<div style='font-family:Verdana, Geneva, sans-serif;padding-bottom:20px;'> <div style='font-size:14px; color:#036;'> <strong>{$row['name']}</strong></div> <div style='font-size:12px; color:#000000;'> <strong>Branch ID:</strong> {$row['branch_id']}<br /> <strong>Address:</strong> {$row['address']}<br /> <strong>State:</strong> {$row['state']}<br /> <strong>Phone:</strong> {$row['phone']}<br /> <strong>Fax:</strong> {$row['fax']}<br /> <strong>Company:</strong> {$row['company']}<br /> <strong>Region Code:</strong> {$row['region_code']}</div> </div>"; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> and then here is where the user errors are returned, if there are any.... <div id="form_container"> <form method="GET" action="search.php" name="searchForm" style="padding-left:20px;padding-top:7px;"> <table width="400" cellpadding="0" cellspacing="0"> <tr> <td><label><strong>Branch Name:</strong></label></td> <td><input type="text" size="19" name="search0" value="<?php echo isset($searchTerms[0])?$searchTerms[0]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>Branch ID:</strong></label></td> <td><input type="text" size="19" name="search1" value="<?php echo isset($searchTerms[1])?$searchTerms[1]:''; ?>"/></input></td> </tr> <tr> <td><label><strong>Address:</strong></label></td> <td><input type="text" size="19" name="search2" value="<?php echo isset($searchTerms[2])?$searchTerms[2]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>State:</strong></label></td> <td><input type="text" size="19" name="search3" value="<?php echo isset($searchTerms[3])?$searchTerms[3]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>Company:</strong></label></td> <td><input type="text" size="19" name="search4" value="<?php echo isset($searchTerms[4])?$searchTerms[4]:''; ?>" /></input></td> </tr> <tr> <td><label><strong>Region Code:</strong></label></td> <td><input type="text" size="19" name="search5" value="<?php echo isset($searchTerms[5])?$searchTerms[5]:''; ?>" /></input></td> </tr> </table><br/> <input type="Submit" id="Search" alt="Search" value="Search"> </form> </div> <div style="font-family:Verdana, Geneva, sans-serif;font-size:14px;padding-left:20px;"> <?php echo (count($error) > 0)?"<br /><strong>The following had errors:</strong><br />" . implode("<br />", $error) . "<br /><br />":""; ?> <?php echo (count($results) > 0)?"<br />Results for <strong>'{$searchTerms[0]}'</strong><br /><br />" . implode("", $results):""; ?> </div> Can anybody shed some light on my problem? i'm sure it's been done before. I searched the forum before posting, but couldn't find anything that could help me with this specific problem.... THANK YOU IN ADVANCE!!
-
does anyone have any experience with the SuperCali PHP Event Calendar? I could use some assistance in writing a custom function for it, anyone ever messed with it before?
-
Probably Easy, Need help with Check Boxes in PHP Code
bossman replied to winuser2003's topic in PHP Coding Help
use the CODE tags for posting code like this -
PHP Header Attachment Alternative (convert to CSV file)
bossman replied to j.smith1981's topic in PHP Coding Help
good stuf -
i apologize for being vague. I was thikning the if statement would go on the form...i have a .php page that i wrote that handles the form, it is a big lengthy, so i will post the code relevent to the file upload functions.. this grabs the files from the form fields.... $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['upload_materials']['name']); if(move_uploaded_file($_FILES['upload_materials']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['upload_materials']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } //////////////////////////////////////////////////// //////////////////////////////////////////////////// //BEGIN stuff to upload second file to directory $target_path2 = "applicable_lists/"; $target_path2 = $target_path2 . basename( $_FILES['upload_lists']['name']); if(move_uploaded_file($_FILES['upload_lists']['tmp_name'], $target_path2)) { echo "The file ". basename( $_FILES['upload_lists']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } this code uplodas the files to a database along with the date from the form... //////////////////////////////////////////////////// //post file to database $new_upload =$HTTP_POST_FILES['upload_materials']['name']; $new_list=$HTTP_POST_FILES['upload_lists']['name']; //////////////////////////////////////////////////// //query to insert files and info into database $query = "INSERT INTO uploads (month, day, year, upload_file, upload_list) VALUES ('$due_date_month', '$due_date_day', '$due_date_year', '$new_upload', '$new_list')"; $result=mysql_query($query); mysql_close($link); this is the code that compiles the file uploads n such to the email that is sent... //////////////////////////////////////////////////// //code to call all the variables and compile the email message $message = "<strong>Thank you</strong> for initiating a new project with JP Enterprises.<br /> We appreciate your business. The information you submited is summarized below for your review. If you need to change or update any of it, please contact me.<br /><br /> <strong>Field Marketing Manager:</strong> $field_mark_manager<br /> <strong>Company/Customer Name:</strong> $comp_cust_name<br /> <strong>ICF Source Code:</strong> $icf_source_code<br /> <strong>Lead Code:</strong> $lead_code<br /> <strong>Product Interest:</strong> $product_interest<br /> <strong>Additional Product Interest:</strong> $add_product_interest<br /> <strong>Number of Units:</strong> $number_of_units<br /> <strong>Purchase Timeline:</strong> $purchase_timeline<br /> <strong>Industry:</strong> $industry<br /> <strong>Employee Range:</strong> $employee_range<br /> <strong>Revenue Range:</strong> $revenue_range<br /> <strong>Due Date:</strong> $due_date_month $due_date_day, $due_date_year<br /> <strong>Additional Comments:</strong> $additional_comm<br /><br /> <strong>Uploaded Files:</strong><br /><br /> $new_upload<br /><br /> <strong>Uploaded Applicable Lists:</strong><br /><br /> $new_list<br /><br /> <strong>Materials Required:</strong><br /><br />"; $bottomcopy = "<br /><br />Our standard turnaround for most projects is 2-3 business days. If we have any questions for you in the meantime, we'll be in touch sooner.<br /><br /> Again, thank you for your business. We look forward to working with you to complete a successful project<br /><br /> Sincerely,<br /><br /> Scott Gebhart<br /> [email protected]<br /> 724.916.3034";
-
Hello all, I have recently put together a form for a client, which not only compiles the form contents into an email, but it saves a file and a date to a database. All this is complete. What i need some help on tho, is some way to figure out to have the email say "no files uploaded yet" if the user doesnt upload a file, and if they did upload a file, then it says the name of the file they uploaded. So far, i have it displaying the name of the file they uploaded in the email, but if they DON'T upload a file, then it just displays a blank. I would like it to say "no files uploaded yet" here is the form fields, there are two.. <label><strong>Please provide any applicable source materials related to copy<br/>and/or images:</strong></label><br/> <label>Upload the file now or email to <a style="padding-left:0px;" href="mailto:[email protected]">[email protected]</a></label><br/> <input type="file" name="upload_materials" /><br/><br/> <label><strong>Please provide any applicable mailing lists:</strong></label><br/> <label>Upload the file now or email to <a style="padding-left:0px;" href="mailto:[email protected]">[email protected]</a></label><br/> <input type="file" name="upload_lists" /><br/><br/> i thought adding value="no files uploaded yet" would work, but it didn't. Can anyone help me?
-
have you figured this out yet? i see some things in your code that i think you should change, but if you've gotten it working then i dont want to confuse you.
-
the only different between wut you posted and what i have is the fact that for the second recipient, im pulling a variable from the form. $to = "[email protected]" . ',' . $_POST['1_mark_manager']; is there a different procedure for if your doing what im trying to do with the $_POST?