Jump to content

goltoof

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by goltoof

  1. Trying to get a contact form which came with a TF template (the author is not responding). Sort of need it fixed asap. The documentation simply states change the email to the send email but the page throws and error and no message is sent. Is there any obvious reason why this form wouldn't work out of the box? I tried a couple other contact forms and they work just fine on the server. code for displaying the form <form id="contactForm" action="contact.php" method="post"> <div class="inner"> <i class="icon-useralt"></i> <input name="senderName" id="senderName" required="required" type="text" placeholder="Name" /> </div> <div class="inner"> <i class="icon-envelope"></i> <input type="email" name="senderEmail" id="senderEmail" placeholder="Email address" required="required" /> </div> <div class="inner"> <i class="icon-pencil"></i> <textarea name="message" id="message" placeholder="Message" rows="5"></textarea> </div> <input type="submit" id="sendMessage" name="sendMessage" value="Submit message" /> </form> contact.php <?php if(!$_POST) exit; $email = $_POST['email']; //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS'; if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){ $error.="Invalid email address entered"; $errors=1; } if($errors==1) echo $error; else{ $values = array ('name','email','message'); $required = array('name','email','message'); $your_email = "mail@example.com"; $email_subject = $_POST['subject']."\n";; $email_content = "new message:\n"; foreach($values as $key => $value){ if(in_array($value,$required)){ if ($key != 'subject') { if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; } } $email_content .= $value.': '.$_POST[$value]."\n"; } } if(@mail($your_email,$email_subject,$email_content)) { echo 'Message sent!'; } else { echo 'ERROR!';
  2. I want a unit converter tool, metric to american, temperature, time, physics, etc. There's plenty of sites out there that do that. I just want one on our own server, but I can't find the source code out there for them.
  3. I'll look into it. An example as it pertains to the situation would be extremely helpful. I'd like to see if it's at least more practical than inidividual echos.
  4. I don't think a loop applies here since I'm not displaying every field for each option. Each option contains up to 50 fields that differ from other options. option1 (field1, field2, field3, field4, field27, field28, field29, field56, field88, field89, etc) option2 (field1, field2, field9, field10, field11, field23, field34, etc) option3 (field1, field2 field3, field36, field37, field52, field56, etc)
  5. The actual script I'm working on involves 50 or so values to display for each option, with 10 options, and each option has different values. There are 200 values in total between the 10 options. I think it's just a little daunting having to echo each array individually 50 times for each option, that's a lot of echos and makes for a very ugly script...
  6. I can but I was wondering if there was another way to do it without having to echo each value individually. No way to just echo once and just list every value i want in one line?
  7. For option1 I need to echo not just field1, but field2, field4, etc.. What's the proper way to do this? <?php $field_array = array( 'field1' => '<tr><td>Field 1:</td><td><input type="text" name="field1" /></td></tr>', 'field2' => '<tr><td>Field 2:</td><td><input type="text" name="field2" /></td></tr>', 'field3' => '<tr><td>Field 3:</td><td><input type="text" name="field3" /></td></tr>', 'field4' => '<tr><td>Field 4:</td><td><input type="text" name="field4" /></td></tr>', 'field5' => '<tr><td>Field 5:</td><td><input type="text" name="field5" /></td></tr>', ); ?> <?php if(isset($_GET["q"])){ ?> <form method="post" action="update.php"> <table> <? switch ($_GET["q"]) { case "option1" : echo $field_array['field1']; break; case "option2" : echo $field_array['field1']; break; } ?> </table> <input type="submit"> </form> <?php } ?>
  8. Good catch, but still doesn't work.
  9. If you look back "test.php" and "display.php" are both set inside of the "getDisplay" div. So the entire form is intact inside the same div. There are two forms here, one is the select form which triggers the AJAX to display the form that is created by display.php and test.php. The AJAX (select) form works fine, and the form inside of the getDisplay div appears fine, but it won't submit.
  10. Source looks like this... When "test" is selected, display.php populates it along with test.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Update</title> <link rel="stylesheet" href="style.css" type="text/css"> <script type="text/javascript"> function getDisplay(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("getDisplay").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","display.php?q="+str,true); xmlhttp.send(); } </script> <script language="javascript"> function update() { alert("Database updated."); window.location.reload(true); } </script> </head> <body> <div id="header"> <div id="form"> <form> <select onchange="getDisplay(this.value)"> <option value="">Select product category</option> <option value="select-test">Test</option> </select> </form> </div> </div> <br /> <div id="getDisplay"> <div id="info">Product info listed here.</div> </div> </body> </html>
  11. Just in case, here's index.php, containing the ajax that populates the "getDisplay" div with display.php and test.php: <script type="text/javascript"> function getDisplay(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("getDisplay").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","display.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <div id="header"> <div id="form"> <form> <select onchange="getDisplay(this.value)"> <option value="">Select product category</option> <option value="test">Test</option> <option value="test2">Test 2</option> </select> </form> </div> </div> <div id="getDisplay"> <div id="info"><!-- display.php & test.php appear here --!></div> </div>
  12. It's just a simple alert and page refresh function update() { alert("Database updated."); window.location.reload(true); } I don't think that's the problem here though because the html (echoed in php) works fine in it's own page but it doesn't work when created with display.php and test.php
  13. Why won't this form submit? When I hit submit the page just stays and doesn't submit anything to the db. It uses ajax to display the form (test.php) but the problem isn't the ajax just the way the php generates the form, i think. display.php <?php $q=$_GET["q"]; if ($q == true) echo '<table><form method="post" action="update.php" onsubmit="return udpate()">'; if ($q == "test") include 'test.php'; if ($q == "test2") include 'test2.php'; if ($q == true) echo '</table><input type="submit" value="Add Product" /></form>'; if ($q == false) echo ''; ?> test.php <?php echo '<tr><td>Product Category:</td><td><input type="text" name="prod_cat" size="" /></td></tr>'; echo '<tr><td>Model# </td><td><input type="text" name="model" size="" /></td></tr>'; echo '<tr><td>List Price </td><td><input type="text" name="price_list" size="" /></td></tr>'; ?> update.php <?php include ('link.php'); $id = $_POST['']; $prod_cat = $_POST['prod_cat']; $model = $_POST['model']; $price_list = $_POST['price_list']; $query= "INSERT INTO product_specs (ID, prod_cat, model, price_list ) VALUES ('NULL', '".$prod_cat."', '".$model."', '".$price_list."') "; mysql_query($query) or die ('Error updating database: ' . mysql_error()); ?>
  14. Need to exclude whitespaces from mysql input. When user inserts space accidentally, php needs to eliminate it, whether searching or updating the field. <tr><td>Model# </td><td><input type="text" name="model" size="" /></td></tr> <?php $id = $_POST['']; $model = $_POST['model']; $query= "INSERT INTO product_specs (ID, model) VALUES ('NULL', '".$model."')"; ?> Also need to exclude whitespaces from mysql query. <?php $model=$_GET["model"]; $result = mysql_query("select * from product_specs where model ='$model'"); if ($row = mysql_fetch_object($result)) { echo 'Model# '. $row->model . '<br />'; } ?> I'm familiar with trim(), preg_replace() just unclear how to include in the script.
  15. I'm making a simple db driven catalog. It's not a shopping cart, just a ton of products each with tons of technical specs that need to be displayed on their own product page . I already setup the mysql database, have a column for every spec (dimensions, voltages, etc, etc) as well as model#, product category, price, etc. I want to display the specs of a specified product in a styled table, based on the model# (not addressing navigation/menus yet, for now I'll just show the specs by changing a variable ie $model_no, or putting the model# in a box on the page). So my db looks like this id | model | prod_cat | price | gain | amp | height | weight | 1 | 23456 | prodcat1 | 1000 | 20db | NULL | 2x3x4 | 5lbs | 2 | 56789 | prodcat2 | 2000 | NULL | 20w | 5x6x7 | 2lbs | There are about 50 columns of specs and as you can see the specs are different for every product category, So any NULL field needs to not echo in the table row of specs that gets generated. The html table (for now) will look something like this: Model#: 23456 Specs Gain | 20db Height | 2x3x4 Weight | 5lbs So I also need the best way to not only make it show specs (NULL fields excluded) in a table, but how to go about labeling each field in the table (Height, Weight, etc) I'll add more features down the line like navigation, etc, this is a good enough start for now. I've played around with fetch_object, fetch_row, fetch_field, fetch_array, I just don't know the best way to start. Hope someone can at least point me in the right direction.
  16. Anyone? Does this question not make sense?
  17. My catalog uses a template file to list product details. One part of it is responsible for putting these details into nifty little tabs: <?php $template = '{magictabs style=black_rounded, tabwidth=110px}'; $template .= 'Technical Specifications'; $template .= '::'; $template .= '<table colspan="3"><tr><td>'; $template .= $details; $template .= '</td></tr></table>'; $template .= '||||'; ?> I don't want it to output $details, I want it to output a separate script instead. How do I include this separate file as a variable? I want this: <?php include('specs.php'); ?> to replace the $details variable.
  18. Which is what I've been doing, and has led me on a wild goose chase. I was looking more for something like "these are the abc's to get the mail to send based on your configuration", I'm a little sick of all this reverse engineering for something so blatantly simple.
  19. I've been tearing my hair out for 3 days now over something that some 12 year old could probably do in 10 minutes in his sleep. My Joomla site sends mail just fine, but I can't even get the simplest php script to send mail. By simplest I mean <?php $txt = "Some text"; mail ("my@email.com","Test subject",$txt); ?> I'm using Ubuntu server, sendmail is all configured. Joomla sends just fine, I'm trying to send from a simple form on a webpage outside of Joomla which brings me to believe that there's something I'm not including in the script that it needs to work. Can you break down each thing that I should check on the server and each thing I should include in the script to just make it work? Please help.
  20. got it working with this: <?php $no_of_columns = 3; $row_begin = "<tr class=\"setrtoc\">\n"; $row_end = "</tr>"; for ($i=0, $n=count( $this->categories ); $i < $n; $i++) { if(($i % $no_of_columns) == 0) echo($row_begin); echo "<td class=\"setdtoc\">\n"; echo $this->_getHtmlTocEntry($i); echo "</td>\n"; if(($i % $no_of_columns) == ($no_of_columns - 1)) echo($row_end); } ?> Thanks again for your help!
  21. Does this make sense to anyone? It seems like it should be quite simple the script already works just needs a small fix to break it off into new columns.
  22. One thing I forgot to include is that it's all in a list, as you can see in the original code I posted. So the output should be more like this: <tr> <td> <td> <td> <td> <ul> <ul> <ul> <ul> Category 1 Category 6 Category 11 Category 16 Category 2 Category 7 Category 12 Category 17 Category 3 Category 8 Category 13 Category 18 Category 4 Category 9 Category 14 Category 19 Category 5 Category 10 Category 15 Category 20 </ul> </ul> </ul> </ul> </td> </td> </td> </td> </tr> <br><br> <tr> <td> </ul> Category 21 Category 22 etc.... </ul> </td> </tr> the <table> tags aren't needed because they're already generated elsewhere.
×
×
  • 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.