PHP - Need To Pull Not From A Table...
Hi all-
I need some help figuring out a select query... I have a view made from two tables with a user ID as the common key. I need to retrieve all rows from the view where the email address is NOT equal to the session variable stated [EMAIL]. I built it using what I thought was a fairly simple query, and what it gives me back are any rows where the EMAIL field has a value (not equal to the session variable) which is fine.. but I ALSO need to get the other rows where the email field has NO value assigned to it currently. How can I write this? Similar TutorialsI have a form that is submitting to a database currently. I would like to check the data and be able to update it with a notes section. The form is currently 80 text boxes, dropdowns, and text areas being submitted to the database. I need this info to populate after the user id is entered and a button is pressed. I will have to update this page frequently with notes. I am going to create a new table just for the notes and will attach the customer id to it also. If you can help me out with this i would appricate it. I can post my current code or an example of the code. Hi, I have a 'pre-release' sign up form, where people put in their email address and name, and it transmits to a MYSQL database. That's working fine. What I want to do is to have a piece of text that reads: (insert pre release amount of signer upperers here) have signed up. Will you? I'm guessing that the amount of rows on the table, would end up being the number. How do I do this? Thanks, Jack Hi all, I have a number of tables within a mysql database and I'm stuck on how to pull information from one based on the results being displayed by another. The site shows items for sale where by all the product information is held in tablea, when an individual item is being displayed I need to be able to pull a manufacturer profile from tableb based on the manufacturer name stored in tablea column profile. The manufacturer name is already being called into the page by existing code as the site has always shown the manufacturer name, I just can't work out out to pull the new profile information in as well from the new table. Any help appreciated Iain Hi.. been a while since I have touched php and need some help. What I am trying to do is have my links pull text from separate php files, and load them into main table. Here is my old php code..used to work.. I had my index.php with my website template on it. In the table I want my info to appear i put this code. <?php /* START MAIN AREA HERE */ if($news) include("news.php"); elseif($bio) include("bio.php"); elseif($draw) include("draw.php"); elseif($pic) include("pic.php"); else include("news.php"); /* END HERE */?> My link looks like this. <A HREF="?news=x" ONMOUSEOVER="changeImages('home', 'images/home-over.gif'); return true;" ONMOUSEOUT="changeImages('home', 'images/home.gif'); return true;"> <IMG NAME="home" SRC="images/home.gif" WIDTH=69 HEIGHT=31 BORDER=0 ALT=""></A> Any help much appreciated! I need to pull all the mysql data by the order of it's date/time . How can I write the code? I'm using this as a serverside script and I'm not a php person. But i believe the below code will not pull the data. Will it work if I remove the text marked in red? $query = "SELECT * FROM sub_db WHERE the_code = '".$abc."'" ORDER BY timestampz ASC"; This is my code. Data is been pulled from db_faq and Db_2 and then match the records against each other using array_intersect(). And as you see the data from db_faq is been pulled based on the $username. My question is how can I ignore the $username and match all rows in db_faq against the data in db_2? Basically I need to get the matching records between the 2 databases regardless of the username. $Array1 = array(); $Array2 = array(); $var1 = '$username'; $query1 = "SELECT * FROM db_faq WHERE username = '".$var1."'"; $result1 = mysql_query($query1); $score1 = mysql_fetch_assoc($result1); foreach (range('25','35') as $ltr) { $Array1[] = array($score1['roundzA' . $ltr]); } $var2 = 'new'; $query = "SELECT * FROM db_2 WHERE place = schedule"; $result = mysql_query($query); $score2 = mysql_fetch_assoc($result); foreach (range('25','35') as $ltr) { $Array2[] = array($score2['points' . $ltr]); } $count = array(); for($i=0;$i<count($Array1);++$i) { $count[$i] = count(array_intersect($Array1[$i],$Array2[$i])); } $countResult = array_sum($count); field1 / field2 10 / England 15 / Italy 20 / France 15 / France 30 / USA When searching for France: SELECT DISTINCT field2, field1 FROM $tableName would return a distinct value. I want to ensure it returns the highest value in field1. Something like this: SELECT DISTINCT field2 (but ensure returns highest field 1 value), field1 FROM $tableName how do I call only a single column in a MySQL? This is not working. $SomeVar = $_POST['finco']; $query = "SELECT * FROM idb WHERE name = '".$SomeVar."'"; $results = mysql_query($query); $psend = $results["fincos"]; echo($psend); anybody has any idea what the code is to put in a main image. So far i was able to find this but it pulls up all the images added in the album. I am only looking for the first image. Thank you. <ul class="thumbs thumbs_nocaptions"> <?php foreach( $this->paginator as $photo ): ?> <li> <a class="thumbs_photo" href="<?php echo $photo->getHref(); ?>"> <span style="background-image: url(<?php echo $photo->getPhotoUrl('thumb.normal'); ?>);"></span> </a> </li> <?php endforeach;?> </ul> I'm trying to create a mac widget that will display my college's football schedule. How do i get started pulling the table data of this page? or any webpage for that matter? It doesn't appear to wrapped in any kind of xml Code: [Select] http://www.aggieathletics.com/sports/m-footbl/sched/tam-m-footbl-sched.html The html is about 3/4 of the down in the source code. On the home page I am having a problem pulling information from the MySql here is my code...and this is what I am trying to do... i am trying to pull 10 items from the database that have today's date...I am also trying to make the user name a link to a page called backpack.php where that page can use the user name that is clicked to retrieve more information. (the problem I am having is 10 results come up but it is a repeat of the same 10 results and when you click the link it doesn't show the user that is clicked info.) PLEASE someone help I have been trying to figure this out for the longest time. Code: [Select] <form action="backpack.php" method="post"> <?php // rows to return $limit=10; $idcount=10; $date = date('Y-m-d'); $count = 0; while ($limit>=$count) { //open database $connect = mysql_connect("hostname","uname","pass") or die("Not connected"); mysql_select_db("db_name") or die("could not log in"); $query = "SELECT *,COUNT(name) FROM boox WHERE date='$date' ORDER BY date"; $idcount = $row['COUNT(name)']; $result = mysql_query($query); while($row = mysql_fetch_array($result)) echo "</br><table width='297' height='200' border='1' align='center' style='overflow:scroll'> <tr> <td width='152'>Book Title:</td> <td width='129'>$row[name]</td> </tr> <tr> <td>Author:</td> <td>$row[author]</td> </tr> <tr> <td>ISBN#</td> <td>$row[isbn]</td> </tr> <tr> <td>Date Posted:</td> <td>$row[date]</td> </tr> <tr> <td>Posted By:</td> <td><a href='backpack.php' onclick='document['packback'].submit()'>$row[username]</a></td> </tr> <tr> <td>School:</td> <td>$row[school]</td> </tr> </table></br>"; $count = $count + 1; $idcount = idcount + 1; } ?> </form> MOD EDIT: DB credentials removed, [code] . . . [/code] tags added. Hi firends, there is a store named "baslik". i try to creating photo gallery. i am saving photo and photo's name in database. Photo's name store named "baslik". Now, For example i am saving called "Summer Photos". i saved 10 photos. When i pull the images and names, all photos and names are pulling. I want to pull one image and its name from "baslik" store. "baslik" store's type "varchar" When i click the image's name, it should post other "Summer Photos". Image gallery should creating next to next like 1. image. And When i clicked the image, other images should open. For example when i clicked "meeting" image, it should go other "meeting" images. So, i want to categorize the images. You can look i put images.
Good afternoon: I have added a database field to a table that has quiz questions in it. the field I have added is for images and I have entered the image url that is stored on the server in an image folder. Please could you tell me how I can include the image in the request by adding to the code below: $Questions = $DB->query("select * from ".TABLE_PREFIX."quiz_questions where q_forquiz='{$Quiz['qid']}' order by qqid"); while($Question = $DB->fetch_array($Questions)){ $Q[$Question['qqid']] = $Question; } Fields in table quiz_questions: qqid q_question q_type q_params q_forquiz q_questionimages - This is the field I added. Thank you for helping. Amilo This is the link to pull the page http://127.0.0.1/kudos/?viewkudoid=### This is the kudo-function.php page function get_kudo_info($viewkudoid){ global $wpdb; $tablename=acikudos_table_name(); $viewsql = "SELECT * FROM $tablename WHERE kudoid='$viewkudoid'"; $viewresult = $wpdb->get_results($viewsql); #$vewrow = mysql_fetch_assoc($viewresult); return $viewresult; } This is the kudo-view.php page function show_kudos($viewkudoid) { global $wpdb; $viewkudoid = $_GET['viewkudoid']; $getthekudo = get_kudo_info($viewkudoid); if ($viewkudoid == $getthekudo['kudoid']) { echo 'Congratulations, you have successfully fixed it!'; } else { echo 'Everything is displayed'; } } add_shortcode( 'kudosview', 'show_kudos' ); I know the issue is right in front of me but I can not find it. I don't know that the subject describes exactly what I want to do so I will explain it as best as I can. I have a form that uses a select box to pull all the names of our employees from the database. I then have a submit button that opens up a page. The code from my view.php is as follows: <form onsubmit="return validateForm()" name="frmRequest" action="attendance.php" method="post" encytype="multipart/form-data"> Which employee would you like? <select> <? @ $db = mysql_connect("localhost", "db_user", "db_pass"); mysql_select_db("EmployeeInfo"); $strSQL = "SELECT Name FROM EmployeeInfo ORDER BY Name"; $rs = mysql_query($strSQL); $nr = mysql_num_rows($rs); for ($i=0; $i<$nr; $i++) { $r = mysql_fetch_array($rs); echo "<OPTION VALUE=\"".$r["Name"]."\">".$r["Name"]."</OPTION>"; } ?> </select> <input type="submit" class="submit" value="Submit" /> </form> On the attendance.php form, I need it to display that user that was pulled from the form on the page before. What would be the best way to do this? I am fairly new to PHP and i'm at a loss right now. Thanks, dmcdaniel I was wondering if anyone is aware of a php script that can pull html from a external site and create a local page with all the urls and image paths rewritten to local paths. I'm trying to create a module for Drupal that does this. Any script already written that I can adapt to Drupal would be great. If no one is aware of a current script that does this, can anyone point me in the right direction? Hi there all, I want to pull news feeds, from a web site and display them .... I have forgot what commands to use to do this. please help. Any example, i am most grateful. hi all, i have a profile page which is a form that asks users to enter there personal details such as name, location, mobile number etc and saves this info with a mysql database, however when you return to the edit profile page the fields are blank and i want them to pull the details the user has entered (if any) and display it, so if a user entered there name as Lee, then returned to the edit profile page there name field would show lee instead of being empty. heres my profiles page code, any help would be great Code: [Select] <?PHP session_start(); if (!(isset($_SESSION['username']) && $_SESSION['username'] != '')) { header ("Location: login.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Author: Reality Software Website: http://www.realitysoftware.ca Note: This is a free template released under the Creative Commons Attribution 3.0 license, which means you can use it in any way you want provided you keep the link to the author intact. --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="style.css" rel="stylesheet" type="text/css" /> <style type="text/css"> .auto-style2 { font-size: 25px; } </style> </head> <body> <div id="container"> <!-- header --> <div id="header"> <div id="logo"><a href="#"><span class="orange">SouthWest</span> LAN's</a></div> <div id="menu"> <ul> <li><a href="index.php">home</a></li> <li><a href="register.php">Register</a></li> <li><a href="account.php">My Account</a></li> <li><a href="forum.php">Forums</a></li> <li><a href="faq.php">FAQ</a></li> </ul> </div> </div> <!--end header --> <!-- main --> <div id="main"> <div id="content"> <div id="head_image"> <div id="slogan"><strong><span class="auto-style2">Organising LAN Parties in the SouthWest</span></strong><br /></div> <div id="under_slogan_text"></div> </div> <div id="text"> <h1>Edit Profile</h1> <br /> <form name="register" method="post" action="process_p.php"> <table border="0" width="225" align="center"> <tr> <td width="219" bgcolor="#999999"> <p align="center"><font color="white"><span style="font-size:12pt;">Please fill out as much as possible</span></font></p> </td> </tr> <tr> <td width="219"> <table border="0" width="282" align="center"> <tr> <td width="116"><span style="font-size:10pt;">Username: </span></td> <td width="156"><?php echo $_SESSION['username']; ?></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Email: </span></td> <td width="156"><input type="text" name="email" maxlength="30"></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Real Name: </span></td> <td width="156"><input type="text" name="real_name"></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Location: </span></td> <td width="156"><input type="text" name="location"></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Mobile Number: </span></td> <td width="156"><input type="text" name="mobile_number"></td> </tr> <tr> <td width="116"><span style="font-size:10pt;">Instant Messager: </span></td> <td width="156"><input type="text" name="instant_messaging"></td> </tr> <tr> <td width="116"> </td> <td width="156"> <p align="right"><input type="submit" name="update" value="Update Profile"></p> </td> </tr> </table> Hey Guys, I'm building a site to view images on, basically the image detail is stored in a database, the site is then accessed and a standard select query is used. I then get the image name etc pulled from the database. Is there a way to save that image name into a variable and get it to display on a form that is run from a function - completely independent to my viewing code...
Some sort of global variable, but that could change each time I viewed a different photo - and wouldn't have any effect on anyone else browsing the site etc - so the correct image name would always be passed? Code: [Select] <?php session_start(); $successMsg = ''; $staff_id = $_SESSION['sid']; include_once "scripts/connect_to_mysql.php"; $customer_id = $_GET['cid']; $customer_id = mysql_real_escape_string($customer_id ); $customer_id = eregi_replace("`", "", $customer_id); $cust_project_id = $_GET['pid']; $cust_project_id = mysql_real_escape_string($cust_project_id ); $cust_project_id = eregi_replace("`", "", $cust_project_id); if (isset($_POST['billing_contact_fax_form_field_box'])){ $billing_contact_fname_form_field_box = $_POST['billing_contact_fname_form_field_box']; $billing_contact_lname_form_field_box = $_POST['billing_contact_lname_form_field_box']; $billing_contact_address_form_field_box = $_POST['billing_contact_address_form_field_box']; $billing_contact_city_form_field_box = $_POST['billing_contact_city_form_field_box']; $billing_contact_state_form_field_box = $_POST['billing_contact_state_form_field_box']; $billing_contact_zip_form_field_box = $_POST['billing_contact_zip_form_field_box']; $billing_contact_email_form_field_box = $_POST['billing_contact_email_form_field_box']; $billing_contact_phone_form_field_box = $_POST['billing_contact_phone_form_field_box']; $billing_contact_fax_form_field_box = $_POST['billing_contact_fax_form_field_box']; $billing_contact_pref_meth_contact_form_field_box = $_POST['billing_contact_pref_meth_contact_form_field_box']; $billing_contact_cc_billed_form_field_box = $_POST['billing_contact_cc_billed_form_field_box']; $sql = mysql_query("UPDATE billing_info SET contact_fname='$billing_contact_fname_form_field_box',contact_lame='$billing_contact_lname_form_field_box',address='$billing_contact_address_form_field_box',city='$billing_contact_city_form_field_box',state='$billing_contact_state_form_field_box',zip='$billing_contact_zip_form_field_box',email='$billing_contact_email_form_field_box',phone='$billing_contact_phone_form_field_box',fax='$billing_contact_fax_form_field_box',pref_meth_contact='$billing_contact_pref_meth_contact_form_field_box',cc_billed='$billing_contact_cc_billed_form_field_box' WHERE proj_id='$cust_project_id'"); $successMsg = '<p style="font-family:Myriad Web Pro" style="font-size:10px" style="color:#666">You have successfully updated the company\'s General Information.<br /><br /> <a href="javascript:window.close();">Close</a></p>'; echo $successMsg; exit(); } ?> I have played around with this for SOOOOO long. I have 2 other scripts that are almost exact replicas of this script. Only difference is they are communicating with a different table...but its basically the EXACT same structure of code and functions. My tables consist of some int values, some varchar values, and the data submitted in these variables should get written to the table where the project ID is = to the id I'm working with. All of that seems to be working fine but whenever I enter the info into the form and submit, NOTHING gets written to my table....I'm completely STUMPED and P-O'd that I just wasted a complete 2 hours doing guess and check and cross comparing scripts. I can't find a thing!!!! Below is my html.....hopefully someone smarter than me can put 2 and 2 together because obviously I am an idiot!!!! Also its organized so well that you would think diagnosing the issue would be simple....not the case. I am totally and utterly stumped. I will even add my other code that works to show you what I mean. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.form.billing_contact_fname_form_field_box.value == "" ) { alert ( "Please fill out the First Name field." ); valid = false; } if ( document.form.billing_contact_lname_form_field_box.value == "" ) { alert ( "Please fill out the Last Name field." ); valid = false; } if ( document.form.billing_contact_address_form_field_box.value == "" ) { alert ( "Please fill out the Address field." ); valid = false; } if ( document.form.billing_contact_city_form_field_box.value == "" ) { alert ( "Please fill out the City field." ); valid = false; } if ( document.form.billing_contact_state_form_field_box.value == "" ) { alert ( "Please fill out the State field." ); valid = false; } if ( document.form.billing_contact_zip_form_field_box.value == "" ) { alert ( "Please fill out the Zip field." ); valid = false; } if ( document.form.billing_contact_email_form_field_box.value == "" ) { alert ( "Please fill out the Email field." ); valid = false; } if ( document.form.billing_contact_phone_form_field_box.value == "" ) { alert ( "Please fill out the Phone field." ); valid = false; } if ( document.form.billing_contact_fax_form_field_box.value == "" ) { alert ( "Please fill out the Fax field." ); valid = false; } return valid; } <!-- Form Validation --> </script> </head> <body> <div id="pg_container"> <!--PAGE CONTAINER--> <div id="pgbdy_container"> <div id="pgbdy"> <div id="bdy_header"></div> <div id="bdy_content_area"> <div id="bdy_content_general_info"> <div id="bdy_form_header"> <p> Please complete the Billing Information form below.<br /> <i>Fields marked with a</i> <b>*</b> <i>are required fields.</i> </p> </div> <form action="" method="post" enctype="multipart/form-data" id="form" name="form" onsubmit="return validate_form ( );"> <!--BILLING CONTACT FIRST NAME--> <div id="billing_contact_fname_form"> <div id="billing_contact_fname_form_text"> <p>*First Name:</p> </div> <div id="billing_contact_fname_form_field"> <input name="billing_contact_fname_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT FIRST NAME--> <!--BILLING CONTACT LAST NAME--> <div id="billing_contact_lname_form"> <div id="billing_contact_lname_form_text"> <p>*Last Name:</p> </div> <div id="billing_contact_lname_form_field"> <input name="billing_contact_lname_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT LAST NAME--> <!--BILLING CONTACT ADDRESS NAME--> <div id="billing_contact_address_form"> <div id="billing_contact_address_form_text"> <p>*Address:</p> </div> <div id="billing_contact_address_form_field"> <input name="billing_contact_address_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT ADDRESS NAME--> <!--BILLING CONTACT CITY NAME--> <div id="billing_contact_city_form"> <div id="billing_contact_city_form_text"> <p>*City:</p> </div> <div id="billing_contact_city_form_field"> <input name="billing_contact_city_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT CITY NAME--> <!--BILLING CONTACT STATE NAME--> <div id="billing_contact_state_form"> <div id="billing_contact_state_form_text"> <p>*State:</p> </div> <div id="billing_contact_state_form_field"> <input name="billing_contact_state_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT STATE NAME--> <!--BILLING CONTACT ZIP NAME--> <div id="billing_contact_zip_form"> <div id="billing_contact_zip_form_text"> <p>*Zip:</p> </div> <div id="billing_contact_zip_form_field"> <input name="billing_contact_zip_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT ZIP NAME--> <!--BILLING CONTACT EMAIL NAME--> <div id="billing_contact_email_form"> <div id="billing_contact_email_form_text"> <p>*Email:</p> </div> <div id="billing_contact_email_form_field"> <input name="billing_contact_email_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT EMAIL NAME--> <!--BILLING CONTACT PHONE NAME--> <div id="billing_contact_phone_form"> <div id="billing_contact_phone_form_text"> <p>*Phone:</p> </div> <div id="billing_contact_phone_form_field"> <input name="billing_contact_phone_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT PHONE NAME--> <!--BILLING CONTACT FAX NAME--> <div id="billing_contact_fax_form"> <div id="billing_contact_fax_form_text"> <p>Fax:</p> </div> <div id="billing_contact_fax_form_field"> <input name="billing_contact_fax_form_field_box" type="text" /> </div> </div> <!--BILLING CONTACT FAX NAME--> <!--BILLING CONTACT PREFERRED METHOD OF CONTACT NAME--> <div id="billing_contact_pref_meth_contact_form"> <div id="billing_contact_pref_meth_contact_form_text"> <p>*Preferred Method of Contact:</p> </div> <div id="billing_contact_pref_meth_contact_form_field"> <select name="billing_contact_pref_meth_contact_form_field_box"> <option value="Email">Email</option> <option value="Phone">Phone</option> <option value="Fax">Fax</option> <option value="">Physical Mail</option> </select> </div> </div> <!--BILLING CONTACT PREFERRED METHOD OF CONTACT NAME--> <!--BILLING CONTACT CREDIT CARD OR BILLED NAME--> <div id="billing_contact_cc_billed_form"> <div id="billing_contact_cc_billed_form_text"> <p>*Will the customer pay with Credit Card or will they be billed (Credit must be approved before ordering)?</p> </div> <div id="billing_contact_cc_billed_form_field"> <select name="billing_contact_cc_billed_form_field_box"> <option value="Credit Card">Credit Card</option> <option value="Billed">Billed</option> </select> </div> </div> <!--BILLING CONTACT CREDIT CARD OR BILLED NAME--> <!-- SUBMIT BUTTON --> <div id="submit_billing_info"> <input name="submit_billing_info" type="submit" /> </div> <!-- SUBMIT BUTTON --> </form> </div> </div> </div> </div> <!--PAGE CONTAINER--> </div> </body> </html> Now here is the code that works in its entirety....please note that the above is broken up just as it would be seen on the page. PHP at the top and then the HTML. It mimics the script I am about to paste below. Please help meeeeeeee!!!! Code: [Select] <?php session_start(); $successMsg = ''; $staff_id = $_SESSION['sid']; include_once "scripts/connect_to_mysql.php"; $customer_id = $_GET['cid']; $customer_id = mysql_real_escape_string($customer_id ); $customer_id = eregi_replace("`", "", $customer_id); $cust_project_id = $_GET['pid']; $cust_project_id = mysql_real_escape_string($cust_project_id ); $cust_project_id = eregi_replace("`", "", $cust_project_id); if (isset($_POST['company_name'])){ $company_name = ereg_replace("[[^A-Z a-z0-9]]", "", $_POST['company_name']); // filter everything but numbers and letters $customer_fname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_fname']); // filter everything but spaces, numbers, and letters $customer_lname = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_lname']); // filter everything but spaces, numbers, and letters $customer_address = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_address']); // filter everything but spaces, numbers, and letters $customer_city = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_city']); // filter everything but numbers and letters $customer_state = ereg_replace("[^A-Z a-z0-9]", "", $_POST['customer_state']); // filter everything but numbers and letters $customer_zip = ereg_replace("[^A-Za-z0-9]", "", $_POST['customer_zip']); // filter everything but numbers and letters $customer_email = stripslashes($_POST['customer_email']); $customer_email = strip_tags($customer_email); $customer_email = mysql_real_escape_string($customer_email); $customer_phone = ereg_replace("[^A-Za-z0-9]", "", $_POST['customer_phone']); // filter everything but spaces, numbers, and letters $customer_fax = ereg_replace("[^A-Za-z0-9]", "", $_POST['customer_fax']); // filter everything but spaces, numbers, and letters $cust_pre_meth_contact = $_POST['cust_pre_meth_contact']; // filter everything but spaces, numbers, and letters $date_of_entry = date("F j, Y, g:i a"); $sql = mysql_query("UPDATE company_info SET company_name='$company_name',contact_fname='$customer_fname',contact_lname='$customer_lname', address='$customer_address', city='$customer_city', state='$customer_state', zip='$customer_zip', email='$customer_email', phone='$customer_phone', fax='$customer_fax',pref_meth_contact='$cust_pre_meth_contact',entry_date='$date_of_entry' WHERE proj_id='$cust_project_id'"); $successMsg = '<p style="font-family:Myriad Web Pro" style="font-size:13px" style="color:#666">You have successfully updated <b>' . $company_name . '\'s</a></b> Company Information.<br /><br /> <a href="javascript:window.close();">Close</a></p>'; echo $successMsg; exit(); } $sql = mysql_query("SELECT * FROM company_info WHERE proj_id='$cust_project_id' LIMIT 1"); while ($row = mysql_fetch_array($sql)) { $company_name = $row["company_name"]; $company_contact_fname = $row["contact_fname"]; $company_contact_lname = $row["contact_lname"]; $company_address = $row["address"]; $customer_city = $row["city"]; $customer_state = $row["state"]; $customer_zip = $row["zip"]; $customer_email = $row["email"]; $customer_phone = $row["phone"]; $customer_fax = $row["fax"]; $cust_pre_meth_contact = $row["pref_meth_contact"]; $cust_entry_date = $row["entry_date"]; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript"> <!-- Form Validation --> function validate_form ( ) { valid = true; if ( document.form.company_name.value == "" ) { alert ( "Company Name field must not be blank." ); valid = false; } if ( document.form.customer_fname.value == "" ) { alert ( "Customer Address field must not be blank." ); valid = false; } if ( document.form.customer_lname.value == "" ) { alert ( "Customer Address field must not be blank." ); valid = false; } if ( document.form.customer_address.value == "" ) { alert ( "Customer Address field must not be blank." ); valid = false; } if ( document.form.customer_city.value == "" ) { alert ( "Customer City field must not be blank." ); valid = false; } if ( document.form.customer_state.value == "" ) { alert ( "Customer State field must not be blank." ); valid = false; } if ( document.form.customer_zip.value == "" ) { alert ( "Customer Password field must not be blank." ); valid = false; } if ( document.form.customer_email.value == "" ) { alert ( "Customer Email field must not be blank." ); valid = false; } if ( document.form.customer_phone.value == "" ) { alert ( "Customer Phone field must not be blank." ); valid = false; } if ( document.form.customer_fax.value == "" ) { alert ( "Customer Fax field must not be blank." ); valid = false; } return valid; } <!-- Form Validation --> </script> </head> <body> <div id="pg_container"> <!--PAGE CONTAINER--> <div id="pgbdy_container"> <div id="pgbdy"> <div id="bdy_header"></div> <div id="bdy_content_area"> <div id="bdy_content"> <div id="bdy_form_header"> <p> Create a new customer by filling out the form below.<br /> <i>Fields marked with a</i> <b>*</b> <i>are required fields.</i> </p> </div> <form action="edit_company_info.php?sid=<?php echo "$staff_id"; ?>&cid=<?php echo "$customer_id"; ?>&pid=<?php echo "$cust_project_id"; ?>" method="post" id="form" name="form" enctype="multipart/form-data" onsubmit="return validate_form ( );"> <!-- COMPANY NAME --> <div id="company_name_form"> <div id="company_name_text"> <p> Company Name: </p> </div> <div id="company_name_field"> <input name="company_name" type="text" id="company_name" value="<?php echo "$company_name"; ?>" /> </div> </div> <!--COMPANY NAME--> <!-- CUSTOMER FIRST NAME --> <div id="customer_fname_form"> <div id="customer_fname_text"> <p> Contact First Name: </p> </div> <div id="customer_fname_field"> <input name="customer_fname" type="text" id="customer_fname" value="<?php echo "$company_contact_fname"; ?>" /> </div> </div> <!-- CUSTOMER FIRST NAME --> <!-- CUSTOMER LAST NAME --> <div id="customer_lname_form"> <div id="customer_lname_text"> <p> Contact Last Name: </p> </div> <div id="customer_lname_field"> <input name="customer_lname" type="text" id="customer_lname" value="<?php echo "$company_contact_lname"; ?>" /> </div> </div> <!-- CUSTOMER LAST NAME --> <!-- CUSTOMER ADDRESS --> <div id="customer_address_form"> <div id="customer_address_text"> <p> Address: </p> </div> <div id="customer_address_field"> <input name="customer_address" type="text" id="customer_address" value="<?php echo "$company_address"; ?>" /> </div> </div> <!--CUSTOMER ADDRESS--> <!-- CUSTOMER CITY --> <div id="customer_city_form"> <div id="customer_city_text"> <p> City: </p> </div> <div id="company_name_field"> <input name="customer_city" type="text" id="customer_city" value="<?php echo "$customer_city"; ?>" /> </div> </div> <!--CUSTOMER CITY--> <!-- CUSTOMER STATE --> <div id="customer_state_form"> <div id="customer_state_text"> <p> State: </p> </div> <div id="customer_state_field"> <input name="customer_state" type="text" id="customer_state" value="<?php echo "$customer_state"; ?>" /> </div> </div> <!--CUSTOMER STATE--> <!-- CUSTOMER ZIP --> <div id="customer_zip_form"> <div id="customer_zip_text"> <p> Zip: </p> </div> <div id="customer_zip_field"> <input name="customer_zip" type="text" id="customer_zip" value="<?php echo "$customer_zip"; ?>" /> </div> </div> <!--CUSTOMER ZIP--> <!-- CUSTOMER EMAIL --> <div id="customer_email_form"> <div id="customer_email_text"> <p> Email: </p> </div> <div id="customer_email_field"> <input name="customer_email" type="text" id="customer_email" value="<?php echo "$customer_email"; ?>" /> </div> </div> <!--CUSTOMER EMAIL--> <!-- CUSTOMER PHONE--> <div id="customer_phone_form"> <div id="customer_phone_text"> <p> Phone: </p> </div> <div id="customer_phone_field"> <input name="customer_phone" type="text" id="customer_phone" value="<?php echo "$customer_phone"; ?>" /> </div> </div> <!--CUSTOMER PHONE--> <!-- CUSTOMER FAX--> <div id="customer_fax_form"> <div id="customer_fax_text"> <p> Fax: </p> </div> <div id="customer_fax_field"> <input name="customer_fax" type="text" id="customer_fax" value="<?php echo "$customer_fax"; ?>" /> </div> </div> <!--CUSTOMER FAX--> <!-- CUSTOMER PREFERRED METHOD OF CONTACT --> <div id="cust_pre_meth_contact_form"> <div id="cust_pre_meth_contact_text"> <p> What is the customer's preferred method of contact?<br /> <select name="cust_pre_meth_contact"> <option value="Email">Email</option> <option value="Fax">Fax</option> <option value="Phone">Phone</option> <option value="Physical Mail">Physical Mail</option> </select> </p> </div> </div> <!--CUSTOMER PREFERRED METHOD OF CONTACT --> <!-- SUBMIT BUTTON --> <div id="submit_new_customer_form"> <div id="submit_new_customer_button"> <p> <input name="submit_new_customer_info" type="submit" id="submit_new_customer" value="Update Customer Company Info" /> </p> </div> </div> </form> <!--SUBMIT BUTTON--> </div> </div> </div> </div> <!--PAGE CONTAINER--> </div> </body> </html> |