Jump to content

aeafisme23

Members
  • Posts

    121
  • Joined

  • Last visited

    Never

Everything posted by aeafisme23

  1. Right now I am using Javascript along with PHP to process a simple contact form. It works great but apparently some people think it is fun to press space bar on each input field to get around validation so i get alot of emails that are blank forms. So i would like to in turn put up some php programming to prevent empty fields and by empty that also means that pressing the space button <--- see spacing would get around this issue. Please go to my contact form if you want to try it yourself and i will settle with a few emails: http://www.loonar.net/contact.php I am assuming this is going to take the approach of using empty or something about testing a string? Any point in the right direction would be great ( a previous forum posting, examples, or just advice would be great. Thank you) My code can be found here for the form ( i dont think you need the processing page but if you do ill post it in a reply) Javascript validation but would like php to back up serverside if js is disabled: <script> function checkcontactus() { if (document.forms.contactus.elements['fullname'].value.length == 0) { alert('Please enter a value for the "Your Name" field'); return false; } if (document.forms.contactus.elements['email'].value.length == 0) { alert('Please enter a value for the "E-MAIL" field'); return false; } return true; } </script> More Code: [code] <td bgcolor="#FFFFFF" valign="top" width="493"><center><img src="images/welcome.jpg" width="485" height="21" border="0"></center> <p><span class="black">Please fill out all the information below and we will get back to you as quickly as possible.</span></p> <script> function checkcontactus() { if (document.forms.contactus.elements['fullname'].value.length == 0) { alert('Please enter a value for the "Your Name" field'); return false; } if (document.forms.contactus.elements['email'].value.length == 0) { alert('Please enter a value for the "E-MAIL" field'); return false; } return true; } </script> <center><img src="images/hr.gif" width="480" height="10" border="0"></center><br> <form name="contactus" method="POST" action="email.php" onSubmit="return checkcontactus()"> <center><table width="480" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="100" valign="middle"><p><span class="bold">Your Name:</span> </p></td> <td width="380"><p><input name="fullname" size="30"> *required field*</p></td> </tr> </table> <br> <table width="480" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="100" valign="middle"><p><span class="bold">Email:</span> </p></td> <td width="380"><p><input name="email" size="30"> *required field*</p></td> </tr> </table> <br> <table width="480" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="480" valign="middle"><center><p><span class="bold">Service or Request Desired:</span><br> <select size="1" name="service"> <option value="No Request Selected">Please Choose a Request</option> <option value="Business Cards">Business Cards</option> <option value="Photo Retouch">General Question</option> <option value="Logo Design">Logo Design</option> <option value="Photo Retouch">Photo Retouching</option> <option value="Web Design">Web Design</option> <option value="Web Hosting">Web Hosting</option> <option value="Video Editing">Video Editing</option> <option value="Other">- Other -</option> </select></p></center></td> </tr> </table> <br> <table width="480" cellpadding="0" cellspacing="0" border="0"> <tr> <td colspa valign="top"><center><p><span class="bold">Please explain the services you need in detail:</span></p></center></td> </tr> <tr> <td valign="top"><center><textarea cols="45" rows="7" name="other"></textarea></center></td> </tr> </table> <br> <table width="480" cellpadding="0" cellspacing="0" border="0"> <tr> <td width="115"></td> <td width="150"><input type="submit" value="Request Information"></td> <td width="45"></td> <td width="100"><input type="reset" value-"Reset"></td> <td width="75"></td> </tr> </table></center> <br> </form> <p><span class="black">* Denote a Required Field - Please fill out all fields to submit form.</span> [/code]
  2. or to this if your trying to anchor link to a Report column on a PHP page. <li><a href="houseproblems.php#report">Report a Problem</a></li> <?php if(isset($Report)) {?>
  3. I do not see you passing it through a input box hidden or not. Also if you are pulling the DATE from a database which is giving you the 00:00:00 that is more than likely meaning that there has been nothing put into that input box or through your phpmyadmin/mysql cpanel. Try inserting a date into the MYSQL to a record that has already been inserted. If it now shows a date in the correct format you are not passing the date information from your first form page. Remember php date and a field in mysql called date are two different things be careful....
  4. sorry if someone saw this as topic solved i tested it on my working server and thought to myself it worked! but then i realized it doesnt on my other server :/ ahh! THanks again for taking alook
  5. I changed Id to id and that didnt work here is my code to the page that does it all pretty much. Please bash away! [code=php:0]<html> <head> <title>Manage Contact Log</title> </head> <body> <?php /************************************************************************* control code for application *************************************************************************/ //submit button was pressed so call the process form function if (isset($_POST['submit'])) { process_form(); die(); }//end if //call the get_data function if (isset($_GET['id'])) { get_data(); }//endif //nothing chosen so list the dma's if ((empty($_POST))&&(empty($_GET))) { list_users(); die(); }//end if //request to add a new contact so call the show_form function if ((isset($_GET['action']))&&($_GET['action']=='add')) { show_form(); }//endif /************************************************************************* get the data for an individual contact *************************************************************************/ function get_data() { //validate the id has been passed at that it is a number if ((empty($_GET['id']))||(is_nan($_GET['id']))) { //there was a problem so list the users again list_users(); //kill the script die(); }else{ //all is ok and assign the data to a local variable $id = $_GET['id']; }//end if $sql = "select * from rfq where id = {$id} order by id;"; $result = conn($sql); if (mysql_num_rows($result)==1){ //call the form and pass it the handle to the resultset show_form($result); }else{ $msg = "No data found for FWA Form"; confirm($msg); //call the list users function list_users(); }//end if }//end function /************************************************************************* show the input / edit form *************************************************************************/ function show_form($handle='',$data='') { //$handle is the link to the resultset, the ='' means that the handle can be empty / null so if nothing is picked it won't blow up //set default values $id = ''; $name = ''; $company = ''; $address = ''; $city = ''; $zip = ''; $email = ''; $phone = ''; $fax = ''; $state = ''; $typeii = ''; $type3 = ''; $burnish = ''; $chromate = ''; $hex = ''; $impregnation = ''; $strip = ''; $partnumber = ''; $partdescription = ''; $alloy = ''; $quantity = ''; $specifications = ''; $color = ''; $repeat = ''; $internet = ''; $internetdirectory = ''; $referral = ''; $yellowpages = ''; $tradeshow = ''; $other = ''; $notes = ''; $value = 'Add'; //submit button value $action = 'add'; //default form action is to add a new dma/station to db //set the action based on what the user wants to do if ($handle) { //set form values for button and action $action = "edit"; $value = "Update"; //get the values from the db resultset $row = mysql_fetch_array($handle); $id = $row['id']; $name = $row['name']; $company = $row['company']; $address = $row['address']; $city = $row['city']; $zip = $row['zip']; $email = $row['email']; $phone = $row['phone']; $fax = $row['fax']; $state = $row['state']; $typeii = $row['typeii']; $type3 = $row['type3']; $burnish = $row['burnish']; $chromate = $row['chromate']; $hex = $row['hex']; $impregnation = $row['impregnation']; $strip = $row['strip']; $partnumber = $row['partnumber']; $partdescription = $row['partdescription']; $alloy = $row['alloy']; $quantity = $row['quantity']; $specifications = $row['specifications']; $color = $row['color']; $repeat = $row['repeat']; $internet = $row['internet']; $internetdirectory = $row['internetdirectory']; $referral = $row['referral']; $yellowpages = $row['yellowpages']; $tradeshow = $row['tradeshow']; $other = $row['other']; $notes = $row['notes']; }//end if //error handling from the processing form function if($data != '') { $elements = explode("|",$data); $id = $elements[0]; $name = $elements[1]; $company = $elements[2]; $address = $elements[3]; $city = $elements[4]; $zip = $elements[5]; $email = $elements[6]; $phone = $elements[7]; $fax = $elements[8]; $state = $elements[9]; $typeii = $elements[10]; $type3 = $elements[11]; $burnish = $elements[12]; $chromate = $elements[13]; $hex = $elements[14]; $impregnation = $elements[15]; $strip = $elements[16]; $partnumber = $elements[17]; $partdescription = $elements[18]; $alloy = $elements[19]; $quantity = $elements[20]; $specifications = $elements[21]; $color = $elements[22]; $repeat = $elements[23]; $internet = $elements[24]; $internetdirectory = $elements[25]; $referral = $elements[26]; $yellowpages = $elements[27]; $tradeshow = $elements[28]; $other = $elements[29]; $notes = $elements[30]; } ?> <body> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action?>"> <table align="left"> <tr valign="baseline"> <td width="116" align="right" nowrap><input type="hidden" value="<?php echo $id?>" name="id"><div align="left">Name:</div></td> <td width="193"><input type="text" name="name" value="<?php echo $name ?>" size="32"></td> <td width="113"> </td> <td width="68" align="right" nowrap><div align="left">Company:</div></td> <td width="205"><input type="text" name="company" value="<?php echo $company ?>" size="32"></td> </tr> <tr valign="baseline"> <td align="right" nowrap><div align="left">Address:</div></td> <td><input type="text" name="address" value="<?php echo $address ?>" size="32"></td> <td> </td> <td align="right" nowrap><div align="left">City:</div></td> <td><input type="text" name="city" value="<?php echo $city ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"><div align="left"></div></td> <td> </td> <td> </td> <td align="right" nowrap><div align="left">Zip:</div></td> <td><input type="text" name="zip" value="<?php echo $zip ?>" size="32"></td> </tr> <tr valign="baseline"> <td align="right" nowrap><div align="left">Email:</div></td> <td><input type="text" name="email" value="<?php echo $email ?>" size="32"></td> <td> </td> <td> </td> <td> </td> </tr> <tr valign="baseline"> <td align="right" nowrap><div align="left">Phone:</div></td> <td><input type="text" name="phone" value="<?php echo $phone ?>" size="32"></td> <td> </td> <td align="right" nowrap>Fax:</td> <td><input type="text" name="fax" value="<?php echo $fax ?>" size="32"></td> </tr> <tr valign="baseline"> <td align="right" nowrap> </td> <td><select name="state" value="<?php echo $state ?>"> <option value="alabama">Alabama</option> <option value="Alaska">Alaska</option> <option value="Arizona">Arizona</option> <option value="Arkansas">Arkansas</option> <option value="California">California</option> <option value="Colorado">Colorado</option> <option value="Connecticut">Connecticut</option> <option value="Delaware">Delaware</option> <option value="Florida">Florida</option> <option value="Georgia">Georgia</option> <option value="Hawaii">Hawaii</option> <option value="idaho">idaho</option> <option value="Illinois">Illinois</option> <option value="Indiana">Indiana</option> <option value="Iowa">Iowa</option> <option value="Kansas">Kansas</option> <option value="Kentucky">Kentucky</option> <option value="Louisiana">Louisiana</option> <option value="Maine">Maine</option> <option value="Maryland">Maryland</option> <option value="Massachusetts">Massachusetts</option> <option value="Michigan">Michigan</option> <option value="Minnesota">Minnesota</option> <option value="Mississippi">Mississippi</option> <option value="Missouri">Missouri</option> <option value="Montana">Montana</option> <option value="Nebraska">Nebraska</option> <option value="Nevada">Nevada</option> <option value="New Hampshire">New Hampshire</option> <option value="New Jersey">New Jersey</option> <option value="New Mexico">New Mexico</option> <option value="New York">New York</option> <option value="North Carolina">North Carolina</option> <option value="North Dakota">North Dakota</option> <option value="Ohio">Ohio</option> <option value="Oklahoma">Oklahoma</option> <option value="Oregon">Oregon</option> <option value="Pennsylvania">Pennsylvania</option> <option value="Rhode Island">Rhode Island</option> <option value="South Carolina">South Carolina</option> <option value="South Dakota">South Dakota</option> <option value="Tennessee">Tennessee</option> <option value="Texas">Texas</option> <option value="Utah">Utah</option> <option value="Vermont">Vermont</option> <option value="Virginia">Virginia</option> <option value="Washington">Washington</option> <option value="West Virginia">West Virginia</option> <option value="Wisconsin">Wisconsin</option> <option value="Wyoming">Wyoming</option> </select></td> <td> </td> <td align="right" nowrap> </td> <td> </td> </tr> <tr valign="baseline"> <td colspan="5" align="right" nowrap><div align="left" class="style1"> <div align="left">Process requested (please check all that apply):</div> </div></td> </tr> <tr valign="baseline"> <td colspan="2" align="right" nowrap> <?php if ($typeii != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $typeii = "NO"; } else { $typeii = "YES"; } if ($type3 != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $type3 = "NO"; } else { $type3 = "YES"; } if ($burnish != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $burnish = "NO"; } else { $burnish = "YES"; } if ($chromate != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $chromate = "NO"; } else { $chromate = "YES"; } if ($hex != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $hex = "NO"; } else { $hex = "YES"; } if ($impregnation != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $impregnation = "NO"; } else { $impregnation = "YES"; } if ($strip != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $strip = "NO"; } else { $strip = "YES"; } if ($repeat != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $repeat = "NO"; } else { $repeat = "YES"; } if ($internet != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $internet = "NO"; } else { $internet = "YES"; } if ($yellowpages != NULL) { // if not empty meaning it's selected it will be YES if not it will be NO $yellowpages = "NO"; } else { $yellowpages = "YES"; } ?> <div align="left"> <input type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox"> Type II (Conventional Anodize)</div></td> <td> </td> <td colspan="2" align="right" nowrap><div align="left"> <input type="checkbox" name="type3" value="<?php echo $type3 ?>" id="checkbox3"> Type III (Hard Coat Anodize)</div></td> </tr> <tr valign="baseline"> <td colspan="2" align="right" nowrap> <div align="left"> <input type="checkbox" name="burnish" value="<?php echo $burnish ?>" id="checkbox4"> (Burnish, Deburr)</div></td> <td> </td> <td colspan="2" align="right" nowrap><div align="left"> <input type="checkbox" name="chromate" value="<?php echo $chromate ?>" id="checkbox5"> Chromate Conversion</div></td> </tr> <tr valign="baseline"> <td colspan="2" align="right" nowrap> <div align="left"> <input type="checkbox" name="hex" value="<?php echo $hex ?>" id="checkbox7"> Chromate Conversion Hex-free</div></td> <td> </td> <td colspan="2" align="right" nowrap><div align="left"> <input type="checkbox" name="impregnation" value="<?php echo $impregnation ?>" id="checkbox6"> Impregnation</div></td> </tr> <tr valign="baseline"> <td colspan="2" align="right" nowrap> <div align="left"> <input type="checkbox" name="strip" value="<?php echo $strip ?>" id="checkbox8"> Strip</div></td> <td> </td> <td> </td> <td> </td> </tr> <tr valign="baseline"> <td colspan="2" align="right" nowrap> </td> <td> </td> <td> </td> <td> </td> </tr> <tr valign="baseline"> <td nowrap align="right"><div align="left">Part Number</div></td> <td colspan="4"><input type="text" name="partnumber" value="<?php echo $partnumber ?>" size="100"></td> </tr> <tr valign="baseline"> <td nowrap align="right"><div align="left">Part Description</div></td> <td colspan="4"><input type="text" name="partdescription" value="<?php echo $partdescription ?>" size="100"></td> </tr> <tr valign="baseline"> <td align="right" nowrap><div align="left">Alloy:</div></td> <td><input type="text" name="alloy" value="<?php echo $alloy ?>" size="32"></td> <td> </td> <td>Quantity</td> <td><input type="text" name="quantity" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"><div align="left">Specifications</div></td> <td><input type="text" name="specifications" value="<?php echo $specifications ?>" size="32"></td> <td> </td> <td>Color</td> <td><input type="text" name="color" value="<?php echo $color ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr valign="baseline"> <td colspan="5" align="right" nowrap><div align="left" class="style1"> <div align="left">How did you hear about us?</div> </div></td> </tr> <tr valign="baseline"> <td colspan="5" align="right" nowrap><div align="left"> <table width="100%" border="0" cellspacing="3" cellpadding="0"> <tr> <td><input type="checkbox" name="repeat" value="<?php echo $repeat ?>" id="checkbox22"> I am a repeat customer</td> <td><input type="checkbox" name="internet" value="<?php echo $internet ?>" id="checkbox9"></td> <td>Internet:</td> <td>Internet Directory:</td> <td><input type="text" name="internetdirectory" value="<?php echo $internetdirectory ?>" size="32"></td> </tr> <tr> <td>Referral: <input type="text" name="referral" value="" size="32"></td> <td><input type="checkbox" name="yellowpages" value="<?php echo $yellowpages ?>" id="checkbox10"></td> <td>Yellow Pages:</td> <td>Tradeshow:</td> <td><input type="text" name="tradeshow" value="<?php echo $tradeshow ?>" size="32"></td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </div></td> </tr> <tr valign="baseline"> <td colspan="5" align="right" nowrap><div align="left">Other: <textarea name="other" value="<?php echo $other ?>" cols="80"></textarea> </div></td> </tr> <tr valign="baseline"> <td nowrap align="right"><div align="left"></div></td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr valign="baseline"> <td colspan="5" align="right" valign="middle" nowrap><div align="left"></div> <div align="left">Notes/ Special Request <textarea name="notes" value="<?php echo $notes ?>" cols="80"></textarea> </div></td> </tr> <tr valign="baseline"> <td nowrap align="right"> </td> <td><input name="submit" type="submit" value="<?php echo $value ?>"> <input name="reset" type="reset" value="Clear Form"></td> <td> </td> <td> </td> <td> </td> </tr> </table> <div align="left"> </div> </form> <? }//end function /************************************************************************* list all the DMA/Stations in the db *************************************************************************/ function list_users() { $y = 0; //counter $sql = "select * from rfq order by id;"; $result = conn($sql); // include "smsinclude.php"; echo "<table width=\"700\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td style=\"font-size:18px; font-weight:bold;\">Manage Request for Quote</td></tr> <tr> <td valign=\"top\"><br><a href='".$_SERVER['PHP_SELF']."?action=add'>Add an additional Request</a><br></td> </tr> </table><br> <table width=\"800\" cellpadding=\"5\" cellspacing=\"0\">"; if (mysql_num_rows($result)){ //show a list of kids with name as a link to the prepopulated form with their data in it while($rows = mysql_fetch_array($result)){ //change row background color (($y % 2) == 0) ? $bgcolor = "#F8F7F2" : $bgcolor=" #FFFFFF"; //build strings to make life easier $id = $rows['id']; $name = $rows['name']; $company = $rows['company']; $address = $rows['address']; $city = $rows['city']; $zip = $rows['zip']; $email = $rows['email']; $phone = $rows['phone']; $fax = $rows['fax']; $state = $rows['state']; $typeii = $rows['typeii']; $type3 = $rows['type3']; $burnish = $rows['burnish']; $chromate = $rows['chromate']; $hex = $rows['hex']; $impregnation = $rows['impregnation']; $strip = $rows['strip']; $partnumber = $rows['partnumber']; $partdescription = $rows['partdescription']; $alloy = $rows['alloy']; $quantity = $rows['quantity']; $specifications = $rows['specifications']; $color = $rows['color']; $repeat = $rows['repeat']; $internet = $rows['internet']; $internetdirectory = $rows['internetdirectory']; $referral = $rows['referral']; $yellowpages = $rows['yellowpages']; $tradeshow = $rows['tradeshow']; $other = $rows['other']; $notes = $rows['notes']; //pass the url to delete the correct table NOT SURE if its RFQ or fwaform or.... $field_data = "rfq"; //convert status to readable string from 1 or 0 might need this for the checkboxes ($status == 0) ? $status = "Available to contact" : $status = "Do not contact at present."; //echo out the row echo "<tr style='background-color:$bgcolor;'> <td> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"800\" height=\"30\" valign=\"middle\"><b>Request For Quote #: $id</b></a></td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <td valign=\"top\" width=\"230\"><b>Name:</b> $name</td> <td valign=\"top\" width=\"250\"><b>Company:</b> $company</td> <td valign=\"top\" width=\"320\"><b>Address:</b> $address</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"230\"><b>City:</b> $city</td> <td valign=\"top\" width=\"250\"><b>State:</b> $state</td> <td valign=\"top\" width=\"320\"><b>Zip:</b> $zip</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"230\"><b>Email:</b> $email</td> <td valign=\"top\" width=\"250\"><b>Phone:</b> $phone</td> <td valign=\"top\" width=\"320\"><b>Fax:</b> $fax</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <td valign=\"top\" width=\"800\"><b>TypeII:</b> $typeii <b>Type3:</b> $type3 <b>Burnish:</b> $burnish <b>Chromate:</b> $chromate <b>Hex:</b> $hex <b>Impregnation:</b> $impregnation <b>Strip:</b> $strip</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"250\"><b>Part Number:</b> $partnumber</td> <td valign=\"top\" width=\"380\"><b>Part Description:</b> $partdescription</td> <td valign=\"top\" width=\"170\"><b>Alloy:</b> $alloy</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"800\"><b>Specifications:</b> $specifications</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"230\"><b>Quantity:</b> $quantity</td> <td valign=\"top\" width=\"570\"><b>Color:</b> $color</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <td valign=\"top\" width=\"800\"><b>Repeat:</b> $repeat <b>Internet:</b> $internet <b>Internet Directory:</b> $internetdirectory <b>Referral:</b> $referral <b>Yellowpages:</b> $yellowpages <b>Tradeshow:</b> $tradeshow</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"800\"><b>Other:</b> $other</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td valign=\"top\" width=\"800\"><b>Notes:</b> $notes</td> </tr> </table> <table width=800 cellpadding=5 cellspacing=5 border=0> <tr> <td width=\"800\" valign=\"top\" height=\"30\" valign=\"middle\"><a href='delete_record.php?id=$id&field_data=$field_data'><b>Delete Request for Quote #$id</b></a></td> </tr> </table> </td></tr>"; $y++; //increment the counter }//end while echo "</table><br>"; }else{ //handle no results echo "<tr><td colspan='20' align='center'><b>No data found.</b></td></tr>"; }//endif } /************************************************************************* add / update the contact's data *************************************************************************/ function process_form() { $id = ''; $name = ''; $company = ''; $address = ''; $city = ''; $zip = ''; $email = ''; $phone = ''; $fax = ''; $state = ''; $typeii = ''; $type3 = ''; $burnish = ''; $chromate = ''; $hex = ''; $impregnation = ''; $strip = ''; $partnumber = ''; $partdescription = ''; $alloy = ''; $quantity = ''; $specifications = ''; $color = ''; $repeat = ''; $internet = ''; $internetdirectory = ''; $referral = ''; $yellowpages = ''; $tradeshow = ''; $other = ''; $notes = ''; $action = ''; $status = 0; //default value $id = @$_POST['id']; $name = @$_POST['name']; $company = @$_POST['company']; $address = @$_POST['address']; $city = @$_POST['city']; $zip = @$_POST['zip']; $email = @$_POST['email']; $phone = @$_POST['phone']; $fax = @$_POST['fax']; $state = @$_POST['state']; $typeii = @$_POST['typeii']; $type3 = @$_POST['type3']; $burnish = @$_POST['burnish']; $chromate = @$_POST['chromate']; $hex = @$_POST['hex']; $impregnation = @$_POST['impregnation']; $strip = @$_POST['strip']; $partnumber = @$_POST['partnumber']; $partdescription = @$_POST['partdescription']; $alloy = @$_POST['alloy']; $quantity = @$_POST['quantity']; $specifications = @$_POST['specifications']; $color = @$_POST['color']; $repeat = @$_POST['repeat']; $internet = @$_POST['internet']; $internetdirectory = @$_POST['internetdirectory']; $referral = @$_POST['referral']; $yellowpages = @$_POST['yellowpages']; $tradeshow = @$_POST['tradeshow']; $other = @$_POST['other']; $notes = @$_POST['notes']; $action = @$_GET['action']; $status = @$_POST['status']; //if no status is set, defaults to 0 (allow contact) if ($status == ''){$status = 0; } if (($name=='')||($company=='')||($address=='')||($city=='')||($zip=='')) { $msg = "Some data from the form was forgotten. Please fill in the entire form."; confirm($msg); $data = "$id|$name|$company|$address|$city|$zip|$email|$phone|$fax|$state|$typeii|$type3|$burnish|$chromate|$hex|$impregnation|$strip|$partnumber|$partdescription|$alloy|$quantity|$specifications|$color|$repeat|$internet|$internetdirectory|$referral|$yellowpages|$tradeshow|$other|$notes"; show_form('',$data); die(); }//end if //You could add some validation of the data ( I recommend it and its a great way to get your feet wet with php ) if ($action == "add") { $sql = "insert into rfq (name, company, address, city, zip, email, phone, fax, state, typeii, type3, burnish, chromate, hex, impregnation, strip, partnumber, partdescription, alloy, quantity, specifications, color, repeat, internet, internetdirectory, referral, yellowpages, tradeshow, other, notes) values('{$name}','{$company}','{$address}','{$city}','{$zip}','{$email}','{$phone}','{$fax}','{$state}','{$typeii}','{$type3}','{$burnish}','{$chromate}','{$hex}','{$impregnation}','{$strip}','{$partnumber}','{$partdescription}','{$alloy}','{$quantity}','{$specifications}','{$color}','{$repeat}','{$internet}','{$internetdirectory}','{$referral}','{$yellowpages}','{$tradeshow}','{$other}','{$notes}');"; $msg = "Record successfully added"; }elseif($action=="edit"){ $sql = "update rfq set name = '{$name}', company = '{$company}', address = '{$address}', city = '{$city}', zip = '{$zip}', email = '{$email}', phone = '{$phone}', fax = '{$fax}', state = '{$state}', typeii = '{$typeii}', type3 = '{$type3}', burnish = '{$burnish}', chromate = '{$chromate}', hex = '{$hex}', impregnation = '{$impregnation}', strip = '{$strip}', partnumber = '{$partnumber}', partdescription = '{$partdescription}', alloy = '{$alloy}', quantity = '{$quantity}', specifications = '{$specifications}', color = '{$color}', repeat = '{$repeat}', internet = '{$internet}', internetdirectory = '{$internetdirectory}', referral = '{$referral}', yellowpages = '{$yellowpages}', tradeshow = '{$tradeshow}', other = '{$other}', notes = '{$notes}' where id = {$id};"; $msg = "Record successfully updated"; } $result = conn($sql); if (mysql_errno()==0) { confirm($msg); list_users(); }else{ $msg = "There was a problem adding the user to the database. Error is:".mysql_error(); confirm($mag); }//end if } /************************************************************************* db connection function *************************************************************************/ function conn($sql) { //connection string was here but i moved it //echo "commnecing connection to local db<br>"; if (!($conn=mysql_connect($host, $user, $pass))) { printf("error connecting to DB by user = $user and pwd=$pass"); exit; } $db3=mysql_select_db($db,$conn) or die("Unable to connect to local database"); $result = mysql_query($sql) or die ("Can't run query because ". mysql_error()); return $result; }//end function /************************************************************************* alert box popup confimation message function *************************************************************************/ function confirm($msg) { echo "<script langauge=\"javascript\">alert(\"".$msg."\");</script>"; }//end function ?> [/code]
  6. ERROR: Can't run query because You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'repeat, internet, internetdirectory, referral, yellowpages, tradeshow, other, no' at line 1 I get this and i've even went to standards of SQL syntax and mine runs hand in hand. This exact code works on another server but when i uploaded to a different server/hosting company it tells me im not following it by the "book". This is the INSERT sql i have; I am very greatful of anyones advice or help. Thanks $sql = "insert into rfq (name, company, address, city, zip, email, phone, fax, state, typeii, type3, burnish, chromate, hex, impregnation, strip, partnumber, partdescription, alloy, quantity, specifications, color, repeat, internet, internetdirectory, referral, yellowpages, tradeshow, other, notes) values('{$name}','{$company}','{$address}','{$city}','{$zip}','{$email}','{$phone}','{$fax}','{$state}','{$typeii}','{$type3}','{$burnish}','{$chromate}','{$hex}','{$impregnation}','{$strip}','{$partnumber}','{$partdescription}','{$alloy}','{$quantity}','{$specifications}','{$color}','{$repeat}','{$internet}','{$internetdirectory}','{$referral}','{$yellowpages}','{$tradeshow}','{$other}','{$notes}');"; this is w3schools (just a random example) $sql="INSERT INTO person (FirstName, LastName, Age) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";
  7. if ($typeii != NULL) { $typeii = "YES"; } else { $typeii = "NO"; }?> and then i made input box <input type="checkbox" name="typeii" value="<?php echo $typeii ?>"> and it works, i guess i just needed to go at it harder. Thought i would at least give the community a solved so someone can benefit besides me.
  8. So i have created a form that easily adds/edits/deletes to a database except for the fact i cant update any of my checkboxes to the databases, only my input fields get updated. I just want the selected input to just update in the database under its field name/value to either be yes or no is sufficient enough. I'll give you my code and then a few of what i was thinking might be the problem, really interested in understanding this // this input addresses updates to database but the typeii checkbox does not updated and leaves the db blank <tr valign="baseline"> <td align="right" nowrap><div align="left">Address:</div></td> <td><input type="text" name="address" value="<?php echo $address ?>" size="32"></td> <td> </td> <td align="right" nowrap><div align="left">City:</div></td> <td><input type="text" name="city" value="<?php echo $city ?>" size="32"></td> </tr> <td colspan="2" align="right" nowrap> <div align="left"> <input <?php if (!(strcmp("yes","no"))) {echo "checked=\"checked\"";} ?> type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox2"> Type II (Conventional Anodize)</div></td> Should i be more concerned with how each checkbox has its own id of checkbox(1,2,4,5,etc...) ex) id="checkbox2" ? and do a php echo of the vlue of checkbox2 and not my own determined name for it as typeii? <input type="checkbox" name="typeii" value="<?php echo $typeii ?>" id="checkbox2">
  9. Okay, so im having some problems doing pagination. I have attempted many times and luckily i am not receiving errors....but the script is not working as it should..... Here is my SQL result code followed by the pagination code.. Any advice would be great because pagination has always been a downfall of mine and never have gotten it to work. RIGHT NOW it displays this on the bottom of the page for pagination FIRST PREV (Page 1 of 0) NEXT LAST ..... I set it to only display 3 results so i can test it and rigth now my sql is pulling all my results (9 in total). Scroll half way down the code to see BEGIN PAGINATION CODE CODE: function list_users() { $y = 0; //counter $sql = "select * from contract_status order by station_id;"; $result = conn($sql); include "smsinclude.php"; echo "<table width=\"700\" cellpadding=\"0\" cellspacing=\"0\"> <tr><td colspan=\"2\" style=\"font-size:18px; font-weight:bold;\">Manage Contract Status</td></tr> <tr> <td valign=\"top\"><br><a href='".$_SERVER['PHP_SELF']."?action=add'>Add info to Contract Status</a></td> <td valign=\"top\"><br>$navigation</td> </tr> </table> <table width=\"760\" cellpadding=\"5\" cellspacing=\"0\"> <tr> <td width=\"80\"><b><u>Station</u></b></td> <td width=\"300\"><b><u>Status</u></b></td> <td width=\"300\"><b><u>Notes</u></b></td> <td width=\"80\"><b><u>Delete</u></b></td></tr>"; if (mysql_num_rows($result)){ //show a list of kids with name as a link to the prepopulated form with their data in it while($rows = mysql_fetch_array($result)){ //change row background color (($y % 2) == 0) ? $bgcolor = "#F8F7F2" : $bgcolor=" #FFFFFF"; //build strings to make life easier $station_id = $rows['station_id']; $status = $rows['status']; $notes = $rows['notes']; $id = $rows['id']; //pass the url to delete the correct table $field_data = "contract_status"; //echo out the row echo "<tr style='background-color:$bgcolor;'> <td width=\"80\" valign=\"top\"><a href='".$_SERVER['PHP_SELF']."?id=$id'>$station_id</a></td> <td valign=\"top\" height=\"30\" valign=\"middle\">$status</td> <td valign=\"top\" height=\"30\" valign=\"middle\">$notes</td> <td width=\"80\" valign=\"top\" height=\"30\" valign=\"middle\"><a href='delete_record.php?id=$id&field_data=$field_data'>Delete</a></td> <tr>"; $y++; //increment the counter }//end while echo "</table><br>$navigation2 <br><br>If you wish to print this page you must use Landscape Printing for best results"; }else{ //handle no results echo "<tr><td colspan='3' align='center'><b>No data found.</b></td></tr>"; }//endif echo "<br>"; // BEGIN CODE FOR PAGINATION if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if /* 2. Identify how many database rows are available This code will count how many rows will satisfy the current query. */ $query = "SELECT count(*) FROM contract_status"; $query_data = mysql_fetch_row($result); $numrows = $query_data[0]; /* 3. Calculate number of $lastpage This code uses the values in $rows_per_page and $numrows in order to identify the number of the last page.*/ $rows_per_page = 5; $lastpage = ceil($numrows/$rows_per_page); /*4. Ensure that $pageno is within range This code checks that the value of $pageno is an integer between 1 and $lastpage.*/ $pageno = (int)$pageno; if ($pageno > $lastpage) { $pageno = $lastpage; } // if if ($pageno < 1) { $pageno = 1; } // if /*5. Construct LIMIT clause This code will construct the LIMIT clause for the sql SELECT statement.*/ $limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page; /*6. Issue the database query Now we can issue the database qery and process the result.*/ $query = "SELECT * FROM contract_status $limit"; /*7. Construct pagination hyperlinks Finally we must construct the hyperlinks which will allow the user to select other pages. We will start with the links for any previous pages.*/ if ($pageno == 1) { echo " FIRST PREV "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?pageno=1'>FIRST</a> "; $prevpage = $pageno-1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'>PREV</a> "; } // if /*Next we inform the user of his current position in the sequence of available pages.*/ echo " ( Page $pageno of $lastpage ) "; /*This code will provide the links for any following pages.*/ if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'>NEXT</a> "; echo " <a href='{$_SERVER['PHP_SELF']}?pageno=$lastpage'>LAST</a> "; } // if // end code for pagination } Could the pagination be screwed up by my first SQL call to display all fields, where in the pagination sql it counts the fields? Thanks!
  10. wow sorry to post this and topic solve it so fast but i figured it out, i did not name my form and select box correctly.......sigh....
  11. I am trying to get my select box to work without a submit button. I have already made one that works just fine but when i put in php variables it does not seem to work. here is what i got <form> <table width="780" cellpadding="0" cellspacing="0" border="0" align="center"> <tr> <td width="20" valign="top"> </td> <td width=250 valign="top"> <p class="small"> <SELECT NAME="nav" onChange="document.location.href=document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value"> <OPTION VALUE="#" SELECTED> - Select a DMA to pull a report - </option> <?php while($results = mysql_fetch_array($sql_address)){ $stationID = $results['station_id']; $dmaID = $results['dma_id']; echo"<option value=\"view_records.php?station=$stationID\">$dmaID</option>"; // Increment the row count $row_count++; } // Free the MySQL resource mysql_free_result($sql_address); ?> </select></p></td>...</form> im pretty sure ive messed this line up somehow to make it not work properly echo"<option value=\"view_records.php?station=$stationID\">$dmaID</option>"; By the way i can get it to work with a submit button but do not want that alternative.
  12. I am trying to both successfully add a delete link that will delete with using 1 php page. I can easily make it a second page and work but would like it to work with one. Here is a snippet of the records being echoed out along with the function of deleting the row: RECORDS //echo out the row echo "<tr style='background-color:$bgcolor;'> <td valign=\"top\" width=\"80\" height=\"30\" valign=\"middle\"><a href='".$_SERVER['PHP_SELF']."?id=$id'>$station_id</a></td> <td width=\"230\" valign=\"top\" height=\"30\" valign=\"middle\">$betas_sent</td> <td width=\"230\" valign=\"top\" height=\"30\" valign=\"middle\">$betas_returned</td> <td width=\"340\" valign=\"top\" height=\"30\" valign=\"middle\">$beta_notes</td> <td width=\"80\" valign=\"top\" height=\"30\" valign=\"middle\"><a href='".$_SERVER['PHP_SELF']."?action=delete'>Delete</a></td> <tr>"; $y++; //increment the counter }//end while echo "</table><br>$navigation2 <br><br>If you wish to print this page you must use Landscape Printing for best results"; }else{ //handle no results echo "<tr><td colspan='5' align='center'><b>No data found.</b></td></tr>"; }//endif } DELETE //DELETE RECORD if ($action == "delete") { $sql = "DELETE FROM kv_production WHERE id = '".$codes."'"; $msg = "Record successfully Deleted"; } $result = conn($sql); if (mysql_errno()==0) { confirm($msg); list_users(); }else{ $msg = "There was a problem adding the user to the database. Error is:".mysql_error(); confirm($mag); }//end if My old delete was used in the record displays doing this (and it worked) <td width=\"80\" valign=\"top\" height=\"30\" valign=\"middle\"><a href='delete_record_kv_production.php?id=$id'>Delete</a></td> FOLLOWED BY the page it calls delete_record_kv_production.php (this is the code that made it delete the record but i cant get it to put on one php page only, not having to go to another php page to execute. any ideas? <?php //Get variables from config.php to connect to mysql server require 'config.php'; // connect to the mysql database server. $connect = mysql_connect($dbhost, $dbusername, $dbuserpass) or die("Unable to connect to SQL server..<br />".mysql_error()); $selectDB = mysql_select_db($dbname) or die("Unable to select database.<br />".mysql_error()); //$codes = ((int)($_GET['id'])); $codes = $_GET['id']; $searchcode_query = "SELECT * FROM kv_production WHERE id = '".$codes."'"; $sql_delete_query = "DELETE FROM kv_production WHERE id = '".$codes."'"; $result = mysql_query($searchcode_query) or die("Error executing MySQL SELECT query<br />".mysql_error()); if( mysql_affected_rows() != 1 ) { print "<center>No such Station exists anymore<br><br>Please go back to <a href=\"add_record_kv_production.php\">add a record</a> | <a href=\"view_records_kv_production.php\">view a record</a></center>"; } else { mysql_free_result($result); $result = mysql_query($sql_delete_query) or die("Error executing MySQL DELETE query<br />".mysql_error()); echo "<center>Deleted record id = $codes<br><br>"; echo "Please go back to <a href=\"add_record_kv_production.php\">add a record</a> | <a href=\"view_records_kv_production.php\">view a record</a></center>"; } /** HTML Can go here too **/ ?>
  13. Thank you for cleaning it up jonsjava, i am now going to use the "proper" format of SQL you suggested and after 2 hours of looking through my code you are right as well for the most part. I was using the wrong SQL table on my inserts station_list when it should have been contact_log as stated everywhere above in the code!!!! I hate simple errors, it's why i needed an extra eye. Thanks again JON!
  14. Can't run query because Unknown column 'contact_date' in 'field_list' I know that the main cause of this is because of quotations single or double quotes but apparently process of elimination has not worked out so well. Does it matter that the single quotes are within doubles? An extra eye would be very helpful, i will post all the sql statements first and then the majority of the code below it with the same SQL statements. Thanks so much everyone! All SQL statements on php page: $sql = "select * from contact_log where id = $id order by station_id"; $sql = "select * from contact_log order by station_id"; $sql = "insert into station_list (station_id, contact_date, contact_person, contact_kv, contact_notes) values('$station_id','$contact_date','$contact_person','$contact_kv','$contact_notes')"; $msg = "Record successfully added"; }elseif($action=="edit"){ $sql = "update station_list set station_id = '$station_id', contact_date = '$contact_date', contact_person = '$contact_person', contact_kv = '$contact_kv', contact_notes = '$contact_notes' where id = $id"; $msg = "Record successfully updated"; The rest of the code in the order it is shown ( i left out db connection and another part /************************************************************************* show the input / edit form *************************************************************************/ function show_form($handle='',$data='') { //$handle is the link to the resultset, the ='' means that the handle can be empty / null so if nothing is picked it won't blow up //set default values $station_id = ''; $contact_date = ''; $contact_person = ''; $contact_kv = ''; $contact_notes = ''; $id = ''; $value = 'Add'; //submit button value $action = 'add'; //default form action is to add a new dma/station to db //set the action based on what the user wants to do if ($handle) { //set form values for button and action $action = "edit"; $value = "Update"; //get the values from the db resultset $row = mysql_fetch_array($handle); $station_id = $row['station_id']; $contact_date = $row['contact_date']; $contact_person = $row['contact_person']; $contact_kv = $row['contact_kv']; $contact_notes = $row['contact_notes']; $id = $row['id']; }//end if //error handling from the processing form function if($data != '') { $elements = explode("|",$data); $station_id = $elements[0]; $contact_date = $elements[1]; $contact_person = $elements[2]; $contact_kv = $elements[3]; $contact_notes = $elements[4]; $id = $elements[5]; } ?> <body> <form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action?>"> <table width="700" bgcolor="ffffff" cellpadding="0" cellpsacing="0" border="1" bordercolor="#000000"> <tr> <td><input type="hidden" value="<?php echo $id?>" name="id"> <table width="700" cellpadding="0" cellpsacing="0" border="0" bordercolor="#000000"> <tr> <td align="left" width="180">Station ID</td> <td width="320" align="left"><input type="text" name="station_id" size="15" value="<?php echo $station_id?>"></td> <td align="left" width="200">All Upper Case ex) KCNC</td> </tr> <tr> <td align="left" width="180">Date of Contact</td> <td width="320" align="left"><input type="text" name="contact_date" size="15" value="<?php echo $contact_date?>"></td> <td align="left" width="200">ex) 05-21-2008 </td> </tr> <tr> <td align="left" width="180">Person Contacted</td> <td width="320" align="left"><input type="text" name="contact_person" size="40" value="<?php echo $contact_person?>"></td> <td align="left" width="200">ex) Joe Smith </td> </tr> <tr> <td align="left" width="180">KinderVision Contact</td> <td width="320" align="left"><input type="text" name="contact_kv" size="40" value="<?php echo $contact_kv?>"></td> <td align="left" width="200">ex) Doug Sebastian </td> </tr> <tr> <td align="left" width="180" valign="top">Contact Notes</td> <td width="320" align="left"><textarea name="contact_notes" cols="40" rows="6"><?php echo $contact_notes?></textarea></td> <td align="left" width="200"></td> </tr> <tr> <td colspan="3"> <p align="center"><input name="submit" type="submit" value="<?php echo $value?>"> <input name="reset" type="reset" value="Clear Form"></p> </td> </tr> </table> </td> </tr> </table> <? }//end function /************************************************************************* list all the DMA/Stations in the db *************************************************************************/ function list_users() { $y = 0; //counter $sql = "select * from contact_log order by station_id"; //may want to add the option where clause to only take kids with an active status $result = conn($sql); echo "<table width='700' align='center' cellpadding='0' cellspacing='0'> <tr><td colspan='5' align='center' style='font-size:18px; font-weight:bold;'>Manage Contact Log</td></tr> <tr><td colspan='5'> </td></tr> <tr><td colspan='5'><a href='".$_SERVER['PHP_SELF']."?action=add'>Add a new Contact Log</a></td></tr> <tr><td colspan='5'> </td></tr>"; if (mysql_num_rows($result)){ //show a list of kids with name as a link to the prepopulated form with their data in it while($rows = mysql_fetch_array($result)){ //change row background color (($y % 2) == 0) ? $bgcolor = "#F8F7F2" : $bgcolor=" #FFFFFF"; //build strings to make life easier $station_id = $rows['station_id']; $contact_date = $rows['contact_date']; $contact_person = $rows['contact_person']; $contact_kv = $rows['contact_kv']; $contact_notes = $rows['contact_notes']; $id = $rows['id']; //convert status to readable string from 1 or 0 ($status == 0) ? $status = "Available to contact" : $status = "Do not contact at present."; //echo out the row echo "<tr style='background-color:$bgcolor;'><td><a href='".$_SERVER['PHP_SELF']."?id=$id'>$station_id</a></td> <td>$contact_date</td> <td>$contact_person</td> <td>$contact_kv</td> <td>$contact_notes</td> <tr>"; $y++; //increment the counter }//end while echo "</table>"; }else{ //handle no results echo "<tr><td colspan='5' align='center'><b>No data found.</b></td></tr>"; }//endif } /************************************************************************* add / update the contact's data *************************************************************************/ function process_form() { $station_id = ''; $contact_date = ''; $contact_person = ''; $contact_kv = ''; $contact_notes = ''; $id = ''; $action = ''; $status = 0; //default value $station_id = @$_POST['station_id']; $contact_date = @$_POST['contact_date']; $contact_person = @$_POST['contact_person']; $contact_kv = @$_POST['contact_kv']; $contact_notes = @$_POST['contact_notes']; $id = @$_POST['id']; $action = @$_GET['action']; $status = @$_POST['status']; //if no status is set, defaults to 0 (allow contact) if ($status == ''){$status = 0; } if (($station_id=='')||($contact_date=='')||($contact_person=='')||($contact_kv=='')||($contact_notes=='')) { $msg = "Some data from the form was forgotten. Please fill in the entire form."; confirm($msg); $data = "$station_id|$contact_date|$contact_person|$contact_kv|$contact_notes|$id"; show_form('',$data); die(); }//end if //You could add some validation of the data ( I recommend it and its a great way to get your feet wet with php ) if ($action == "add") { $sql = "insert into station_list (station_id, contact_date, contact_person, contact_kv, contact_notes) values('$station_id','$contact_date','$contact_person','$contact_kv','$contact_notes')"; $msg = "Record successfully added"; }elseif($action=="edit"){ $sql = "update station_list set station_id = '$station_id', contact_date = '$contact_date', contact_person = '$contact_person', contact_kv = '$contact_kv', contact_notes = '$contact_notes' where id = $id"; $msg = "Record successfully updated"; } $result = conn($sql); if (mysql_errno()==0) { confirm($msg); list_users(); }else{ $msg = "There was a problem adding the user to the database. Error is:".mysql_error(); confirm($mag); }//end if }
  15. Thanks ginger, you would think i would actually just copy your code and instead i just replaced what i thought you meant in the function, it works heh. I wish i knew why it works, but thank you for your "KEEN" eye. Randy
  16. *bump I am really avoiding going the database route, i found this http://www.plus2net.com/php_tutorial/dd3.php but it uses a database. Should i stick with my original code? I just don't understand why the 3rd select will not work. Ive tried the following: ADDED the SEL part for the 3rd select: function makeSelect3($opts, $opt1, $opt2) { echo "<SELECT name='option3' onchange='this.form.submit()'>"; echo "<option value=''>- select 3rd choice -</option>"; if ($opt1 && $opt2) { unset($opts[$opt1]); //remove 1st choice unset($opts[$opt2]); //remove 2nd choice foreach ($opts as $v => $t) { // which option is selected? $sel = $v==$currVal ? 'selected' : ''; echo "<option value='$v' $sel>$t</option>"; } } echo '</SELECT>'; Ive tried rearranging function makeSelect3($opts, $opt1, $opt2) { to function makeSelect3($opts, $opt1, $currVal) { etc... ive also tried adding <?php $option1 = $_GET['option1']; $option2 = $_GET['option2']; $option3 = $_GET['option3']; ?> into the required file. Thanks again
  17. Ya i thought the same thing but when i did that i received this error PHP Notice: Undefined variable: currVal in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 102 PHP Notice: Undefined variable: currVal in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 102 PHP Notice: Undefined variable: currVal in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 102 PHP Notice: Undefined variable: currVal in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 102 PHP Notice: Undefined variable: currVal in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 102 which just points to that line. It's accepting the first two options, but something is definitely iffy on the 3rd.
  18. Hey guys, i have came to the conclusion that this used to work on PHP 4 and when i upgraded to PHP 5 it said something along the lines that "you should have learned to code right noob". Ha, not really, here is the error i get: PHP Notice: Undefined variable: sel in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 101 PHP Notice: Undefined variable: sel in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 101 PHP Notice: Undefined variable: sel in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 101 PHP Notice: Undefined variable: sel in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 101 PHP Notice: Undefined variable: sel in E:\Domains\livingwellsanctuary.com\wwwroot\sproductline\singingbowls\crownchakra.php on line 101 URL, http://www.livingwellsanctuary.com/sproductline/singingbowls/crownchakra.php you can choose 2 options but the 3rd one errors, see for yourself! That is pointing at this line echo "<option value='$v' $sel>$t</option>"; Anyways i will provide the necessary code. My first impression was to add this to the top of the page to declare the variables, but i just got so "MANY" errors. $t= $_GET['t']; $v= $_GET['v']; // ETC..... just declaring some of the variables used in this but not really sure if i need to do this or which ones to declare It would be very helpful if i could get some insight to what direction i need to go. Thank you. PHP PAGE <?php $allOpts = array( '8B' => '8" B Chakra Bowl', '10B' => '10" B Chakra Bowl', '12B' => '12" B Chakra Bowl', '13B' => '13" B Chakra Bowl', '14B' => '14" B Chakra Bowl', '15B' => '15" B Chakra Bowl', '16B' => '16" B Chakra Bowl' ); function makeSelect1($opts, $currVal) { echo "<SELECT name='option1' onchange='this.form.submit()'>"; echo "<option value=''>- select 1st choice -</option>"; foreach ($opts as $v => $t) { // which option is selected? $sel = $v==$currVal ? 'selected' : ''; echo "<option value='$v' $sel>$t</option>"; } echo '</SELECT><br><br>'; } function makeSelect2($opts, $currVal, $opt1) { echo "<SELECT name='option2' onchange='this.form.submit()'>"; echo "<option value=''>- select 2nd choice -</option>"; if ($opt1) { unset($opts[$opt1]); //remove 1st choice foreach ($opts as $v => $t) { // which option is selected? $sel = $v==$currVal ? 'selected' : ''; echo "<option value='$v' $sel>$t</option>"; } } echo '</SELECT><br><br>'; } function makeSelect3($opts, $opt1, $opt2) { echo "<SELECT name='option3' onchange='this.form.submit()'>"; echo "<option value=''>- select 3rd choice -</option>"; if ($opt1 && $opt2) { unset($opts[$opt1]); //remove 1st choice unset($opts[$opt2]); //remove 2nd choice foreach ($opts as $v => $t) { echo "<option value='$v' $sel>$t</option>"; } } echo '</SELECT>'; } ?> <?php $option1 = isset($_GET['option1']) ? $_GET['option1'] : ''; $option2 = isset($_GET['option2']) ? $_GET['option2'] : ''; $option3 = isset($_GET['option3']) ? $_GET['option3'] : ''; if ($option1 && $option2 && $option3) { echo "1st choice : $option1<br>"; echo "2nd choice : $option2<br>"; echo "3rd choice : $option3<br>"; echo "<br>"; require("resultscrown.php"); } else { echo "<FORM name='form1' method='GET'>"; makeSelect1($allOpts, $option1); makeSelect2($allOpts, $option2, $option1); makeSelect3($allOpts, $option1, $option2); echo '</FORM>'; } ?><a href="<?php echo "{$_SERVER['PHP_SELF']}"?>?option1=&option2=">Reset Selections</a> This is above in the code, but its showing that if the above shows a value for all 3 options then it requires the information on resultscrown.php which is all good. Or just use this url which is testing the query string to make sure it can pull from file http://www.livingwellsanctuary.com/sproductline/singingbowls/crownchakra.php?option1=8B&option2=10B&option3=12B if ($option1 && $option2 && $option3) { echo "1st choice : $option1<br>"; echo "2nd choice : $option2<br>"; echo "3rd choice : $option3<br>"; echo "<br>"; require("resultscrown.php");
  19. Ok so yes this does work but i forgot to add a question in because apparently this script works on my dedicated server but the clients web hosting company is yahoo and im guessing that they don't allow this type of mailing in their php.ini (noticed alot of people talking about this). Do you know if this can still be done or where i should first check on the cpanel or .htaccess to see if i can change the settings to allow this script to work as it is intended? Thanks! EDIT: Restrictions Yahoo! places 2 restictions on the ability to send mail: A limited number of recipients may be sent mail each day You must specify a return address that is in your own domain They do this so we can't SPAM the world (at least not on the same day) and all the mail we send is traceable back to us. They don't count mail sent to addresses in our own domain so you can send copies to yourself without reducing the number of people to whom you can send mail each day. I guess this could be a problem, so i'm assuming that php/sending mail on yahoo web hosting is pretty much not worth it....
  20. hehe i thought you said you tasted the code silly man! Thanks a bunch it works perfectly !
  21. Hello, i read http://www.phpfreaks.com/forums/index.php/topic,99582.0.html thread that was closes to my problem but having some minor issues that I am sure will make my hand go up to the forehead followed by a 'duh'. This is a php page that just has the form, on submit it goes to the next page and correctly posts the data on the next page but it will not email it for what ever reason. <form name="galatickets" method="GET" action="confirmation_2008.php" onSubmit="return checkgalatickets()"> <p class="bodyfont"> Name of Student #1: <input name="studentname1" size="45"></span></font> <br><br> Student's Class Name: <select size="1" name="classname1"> <option>Please Select a Class</option> <option value="class1">Mermaid 10:00 am Monday (Show 2)</option> <option value="class2">Cinderella 10:45 am Monday (Show 1)</option> <option value="class3">Sweet Peas 11:30 am Monday (Show1)</option> <option value="class4">Sprites 1:00 pm Monday (Show 1)</option> <option value="class5">Esmerelda 1:45 pm Monday (Show 2)</option> </select></span></font> <br><br> Which Show: <select size="1" name="show1"> <option>Please Select which Show</option> <option value="show1">Show 1 at 10:00 AM</option> <option value="show2">Show 2 at 2:00 PM</option> <option value="show3"> Show 3 at 7:00 PM</option> </select> <br><br> Studio Location: <select size="1" name="location1"> <option>Please Select a Studio Location</option> <option value="act1">Act I (Harbourtown Center)</option> <option value="act2">Act II (Hamilton County Sports Complex)</option> </select> this is how i mailed it. It's very important that the $message will email the variables from the form, any suggestions would be greatly appreciated! <?php $to = x@gmail.com'; $subject = 'Wakeup bob!'; $message = 'yo, whassup? $studentname1 and ticket total $tickets_total'; $headers = "From: x@gmail.com\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // Send $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?>
  22. some code would be very helpful if you could provide some
  23. I also tried this approach with no avail, this approach did not return anything and returned php syntax errors. I think this approach may be better than the last but things are starting to mesh so much together that im actually confusing myself. Any clarity would be nice 3rd attempt: <table> <tr> <td width=250 valign=top> <p class="small"> <form><select name="dmalist"> <option value=''>- Select -</option> <?php while($results = mysql_fetch_array($sql_address)){ <option value=view_records.php?station=' .$results[`station_id`] . '>dma: ' .$results['dma_id'] . ' station: ' .$results['station_id'] . '</option> // Increment the row count $row_count++; } // Free the MySQL resource mysql_free_result($sql_address); ?> </select> </form></p> </td> </tr> </table>
  24. Okay my attempt at this did not return an error but it did however return absolutely nothing but a select box that was listed as Select but no database results were listed, i guarantee my problem is this line of code <option value="view_records.php?station=' .$results['station_id'] . '> formSelected( $HTTP_POST_VARS[ "dma_id" ], [ "station_id" ] ); </option> but i could be wrong, take a look at my code that i did below. Thanks in advance! <?php //Setup connection to the database $connect = mysql_pconnect("localhost", "x", "x") or die(mysql_error()); //Connect to the database mysql_select_db("x", $connect) or die(mysql_error()); // Perform an SQL query on the Address table $sql_address = mysql_query("SELECT dma_id, station_id from station_list order by dma_id") or die (mysql_error()); ?> <table> <tr bgcolor="' . $row_color . '"> <td width=250 valign=top> <p class="small\"> <form><select name="dmalist"> <option value=''>- Select -</option> <?php while($results = mysql_fetch_array($sql_address)){ ?> <option value="view_records.php?station=' .$results['station_id'] . '> formSelected( $HTTP_POST_VARS[ "dma_id" ], [ "station_id" ] ); </option> <?php // Increment the row count $row_count++; } // Free the MySQL resource mysql_free_result($sql_address); ?> </select></form> </p> </td> </tr></table>
×
×
  • 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.