Jump to content

goltoof

Members
  • Posts

    27
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

goltoof's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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
×
×
  • 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.