Jump to content

bramwolf

Members
  • Posts

    137
  • Joined

  • Last visited

Everything posted by bramwolf

  1. Hey Guys! I was developing a contact based on Ryan's basic contact form. At first I had some problems getting all the data I wanted into the mail being sent, but I got that fixed. At some random point in developing it stopped sending the emails, which earlier it did very fast without any problems. I went back to how the code was when it was sending but since than couldn't get it to work again. I've looked over it a hundred times by now and can't find anything that would cause it to not send the e-mail. It even validates and gives the validation message, which it could only do after it sent the e-mail? Does anyone know what could be going on? You can find the form at: www.partyverhuursiroo.nl/bestellijst/ and here is the code I'm using ( I'm a php n0ob, plz be gentle ) Thanks in advance for your help! Bram Wolf <?php // set this to the email address you want to send to (or pull from a PW field) $emailTo = 'info@bramwolf.nl'; // or if not set, we'll just email the default superuser if(empty($emailTo)) $emailTo = $users->get($config->superUserPageID)->email; // set and sanitize our form field values $form = array(); $product = array(); $form["naam"] = $input->post->naam; $form["straatnaam"] = $input->post->straatnaam; $form["postcode"] = $input->post->postcode; $form["woonplaats"] = $input->post->woonplaats; $form["telefoon"] = $input->post->telefoon; $form["email"] = $input->post->email; $form["verhuurdatum"] = $input->post->verhuurdatum; $form["retourdatum"] = $input->post->retourdatum; $form["comments"] = $input->post->comments; $j = 0; foreach ($_COOKIE as $key => $val){ $cookies[] = array($key); $values[] = array($val); foreach ($pages->get('/assortiment')->children as $subpage ) { foreach ($subpage->artikelen as $artikel ) { if ($key == $artikel->id) { $j++; $product["artikel_aantal" . $j] = $_COOKIE[$key]; $product["artikel_naam" . $j] = $artikel->product_title; $totaal = $_COOKIE[$key] * $artikel->product_price; $product["artikel_prijs" . $j] = $totaal; } } } } // foreach ($product as $one => $two) { // echo " $one = $two <br>"; // } // initialize runtime vars $sent = false; $error = ''; // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($form as $key => $value) { if(empty($value)) $error = "<h3 class='error'>Controleer of alle velden zijn ingevuld</h3>"; } // if no errors, email the form results if(!$error) { $subject = "Bestelling van $form[naam]"; $message = ''; foreach($form as $key => $value) { $message .= "$key: $value\n"; } $message .= "\n \n"; $j++; $postcount = 1; while ($postcount < $j) { foreach($product as $key => $value) { if ($key == 'artikel_aantal' . $postcount ) { $message .= "$value x"; // echo $value . " x "; } if ($key == 'artikel_naam' . $postcount ) { $message .= "$value ="; // echo $value; } if ($key == 'artikel_prijs' . $postcount ) { $message .= "€ $value \n"; // echo " = € " . $value . "<br>"; } } $postcount++; } mail($emailTo, $subject, $message, "From: $form[email]"); $sent = true; } } if($sent) { echo "<h3>Hartelijk bedankt voor uw bestelling. Wij nemen zo spoedig mogelijk contact met u op!</h3>"; // or pull from a PW field } else { // encode values for placement in markup foreach($form as $key => $value) { $form[$key] = htmlentities($value, ENT_QUOTES, "UTF-8"); } // output the form echo <<< _OUT $error <form action="./" method="post"> <p class="form_p"> <label for="naam">Uw Naam</label><br /> <input type="text" id="naam" name="naam" size="60" value="$form[naam]" /> </p> <p class="form_p"> <label for="straatnaam">Straatnaam en huisnummer</label><br /> <input type="text" name="straatnaam" id="straatnaam" size="60" value="$form[straatnaam]" /> </p> <p class="form_p"> <label for="telefoon">Uw telefoon nummer</label><br /> <input type="text" name="telefoon" id="telefoon" size="60" value="$form[telefoon]" /> </p> <p class="form_p"> <label for="postcode">Uw postcode</label><br /> <input type="text" name="postcode" id="postcode" size="60" value="$form[postcode]" /> </p> <p class="form_p"> <label for="email">Uw Email adres</label><br /> <input type="email" name="email" id="email" size="60" value="$form[email]" /> </p> <p class="form_p"> <label for="woonplaats">Uw woonplaats</label><br /> <input type="text" name="woonplaats" id="woonplaats" size="60" value="$form[woonplaats]" /> </p> <p class="form_p"> <label for="verhuurdatum">Verhuur datum: </label><br /> <input type="text" id="verhuurdatum" name="verhuurdatum" value="$form[verhuurdatum]" /> </p> <p class="form_p"> <label for="retourdatum">Retour datum: </label><br /> <input type="text" id="retourdatum" name="retourdatum" value="$form[retourdatum]" /> </p> <p class="form_p"> <label for="comments">Comments</label><br /> <textarea id="comments" name="comments" rows="5" cols="60">$form[comments]</textarea> </p> <p class="form_p"><input type="submit" name="submit" value="Submit" /></p> </form> _OUT; } ?>
  2. YES! I fixed it On the course-page, where I set the cookie, and the session variable in the first case, I linked to the subscription page where in turn I wanted to call the cookie. I figured out that on pretty much all the pages within the site Chrome kept the cookie alive, except for the subscription page. I saw al links inside my site ended with a slash, checked the code and saw that the link I made didn't end with the slash. Also, very weird but I didn't add a domain to the cookie creation, and the course page created a www.domain.com instance while the subscribe page seemed to be looking for a .domain.com instance, adding a domain to the cookie fixed this as well. I added it and now chrome keeps the cookie alive Pretty weird that this make so much difference, and that Firefox and Safari don't take the trailing slash into account
  3. Hey Guys, Thanks for the replies! I tried your different syntaxes however with those Firefox, Safari and Chrome failed to display the variable. I'm not sure how I would define a session variable, other than I did? Further I did some testing and read somewhere cookies solved the problem, and cookies also work fine on Firefox and Safari. But Chrome still doesn't, It sets them properly and gives them the session expiration date but when I go to a different page, in this case the subscription page, it gets removed from the cookie list. A think Chrome might be doing the same to Processwire's session variable? I don't know where those are stored but they don't show up in the cookie list. Has anybody heard of this problem? I set cookies like this: document.cookie = "cursus=<?PHP echo $page->title ?>; path=/"; and this to retrieve it: <script type="text/javascript"> function getCookie(name) { var re = new RegExp(name + "=([^;]+)"); var value = re.exec(document.cookie); return (value != null) ? unescape(value[1]) : null; } </script> <script type="text/javascript"> document.write(getCookie("cursus")); </script></div> Oh btw, When searching Google I keep on finding issues where Chrome doesn't clear the session cookies.. :S Well at least I fixed that for everyone, my Chrome super-clears cookies Thanx in advance
  4. Yeah I did, Copied it from the cheatsheet? http://cheatsheet.processwire.com/session/properties-and-methods/session-set-name-value/ I do have the feeling it works? on some browsers? I have no idea what, and why it isn't working properly
  5. Hey Guys, I've ran into some really weird behavior with session variables. What I've been trying to do is this: I have 10 separate pages that share the same template, named cursus.php. These are pages with course info and have different title's. these page all do the following: $session->remove($cursus); $session->set($cursus, $page->title); They all have a link to one page where you can subscribe for the course on that page I call out the session variable and want to recall there from what page they entered the subscription page by doing the following: <div>Subscribe for the course: <?PHP echo $session->get($cursus); ?></div> and that, on it's turn, gets mailed to my client. Now Firefox and Safari seem to be displaying the variable perfectly fine but Chrome is not. I've tried it on my mobile and and desktop and even in incognito mode, which should clear any cache problems, but it still doesn't work. Am i going about this completely the wrong way or does anyone have a suggestion of what the problem could be? As you can image it's very important to my client and thus to me, that I get this working as soon as possible! Any help will be greatly appreciated. Bram Wolf
  6. Hey Guys, I was wondering if anyone came across this before or, if I'm just crazy On different pages I use a simply Body field which is a instance of TinyMCE. If I call it directly as a standalone field ( $page->body ) it outputs line breaks ( <br /> ) in the paragraph where the empty lines in the text are. But, when I use the same field inside a repeater and output it using foreach ($page->slideshow as $slide ) $slide->body, it end the paragraph at each line break in the text. I find this super weird and kinda annoying since you have to use different stylings the create the same effect. Does anyone know why this is and how you could fix it? I would prefer it would always output <BR />'s instead of paragraph ends. thanx Bram
  7. Ah yes! I see what you mean! Quite severe indeed But i actually decided to use this one, since it only lists the other available languages, much better than hardcoding links to all languages i think! <ul id='languageSelection'> <?php foreach($languages as $language) { if(!$page->viewable($language)) continue; // check if page not published for this language $class = "$language" == "$user->language" ? "active" : ""; $url = $page->localUrl($language); $lang = $language->name; if(strcmp($lang,'default') == 0) { $lang = 'nl'; } // default language fix echo "<li class='$class'><a title='$language->title' href='$url'>$lang</a></li>"; } ?> </ul> If this wouldn't give me a internal server error that is
  8. Hey Pete, thanks for your contribution but I decided to trash my own script and go for overoon's version since it makes much more sense any ideas on why that gives me an internal server error? bram
  9. Hey Overoon, Thank you so much for your reply! Your script indeed sounds alot better than mine So I decided to put it to the test but when I implement it in my HTML the site gives me a internal error. I've checked the script and the php lines are flawless, no broken lines or whatever. Any ideas on what could be the problem? I'll try to find the server log and see if it gives any usefull info. thanks Bram
  10. Hey Guys, I'm still wrestling the same problem without any succes. Does anyone have an idea as to what I'm doing wrong? Any help would be greatly appreciated! Grts, Bram
  11. Ah!! Great tips! Thanks for taking the time to elaborate on some stuff I did! I'll keep your comments in mind next time I'll try to write php ( tomorrow I figure ) But for now I'm inclined to go with Martijn's code as it already got me halfway there, and mine didn't Nontheless, thanks man!
  12. Hi there, So, I've tried to code above and it does output the links to the page's content in the available different languages, however when I click the links I keep ending up on the page in the same language I was already in. Any ideas on what I am doing wrong? As apparent, I'm not quite familiar with php or getting it to do with processwire what I want, but it seems to me, from other examples I saw, there should be a ->get($language) statement in the links somewhere? Or is there something else I'm messing up? My languages are setup as following: Default -> Dutch de -> German en -> English thanks in advance
  13. Yeah! I'm gonna try and get this to work, thanks for helping me out man I've been looking everywhere for this code but couldn't find it anywhere! Sorry for being such a n0ob i guess Bram
  14. Hey Guys! I already posted this in Multi-Language but maybe it sits better here, Sorry! I must admit I'm fairly new to all this so I might be overlooking something completely or just not getting it But here's what I want to do! I'm building a website which I want to present in 3 languages. The user should be able to choose his or her language via the use of a button. I created 3 image buttons that send a value to a php script at the bottom of my page, but the page keeps rendering in the default language. Any ideas on what I am doing wrong, or how you would go about achieving this? I would like the user(language) to stay the same as the chosen though the buttons until it is changed again. This is what I have so far : <form action="" method="post"> <input type="text" name="taal" value="nl" style="display:none;"> <input type="image" src="../site/templates/img/vlag_nl.png" name="submit" /> </form> <form action="" method="post"> <input type="text" name="taal" value="de" style="display:none;"> <input type="image" src="../site/templates/img/vlag_de.png" name="submit" /> </form> <form action="" method="post"> <input type="text" name="taal" value="en" style="display:none;"> <input type="image" src="../site/templates/img/vlag_en.png" name="submit" /> </form> <?PHP if(isset($_POST["submit"])) { $taal = $_REQUEST['taal']; $user->language = $languages->get($taal); echo $pages->LocalUrl($taal)->render(); }; ?> Any help would be much appreciated! I've been spending waaay too much time on this piece of hocus pocus already Gr, Bram
  15. Hey Guys! I must admit I'm fairly new to all this so I might be overlooking something completely or just not getting it But here's what I want to do! I'm building a website which I want to present in 3 languages. The user should be able to choose his or her language via the use of a button. I created 3 image buttons that send a value to a php script at the bottom of my page, but the page keeps rendering in the default language. Any ideas on what I am doing wrong, or how you would go about achieving this? I would like the user(language) to stay the same as the chosen though the buttons until it is changed again. This is what I have so far : <form action="" method="post"> <input type="text" name="taal" value="nl" style="display:none;"> <input type="image" src="../site/templates/img/vlag_nl.png" name="submit" /> </form> <form action="" method="post"> <input type="text" name="taal" value="de" style="display:none;"> <input type="image" src="../site/templates/img/vlag_de.png" name="submit" /> </form> <form action="" method="post"> <input type="text" name="taal" value="en" style="display:none;"> <input type="image" src="../site/templates/img/vlag_en.png" name="submit" /> </form> <?PHP if(isset($_POST["submit"])) { $taal = $_REQUEST['taal']; $user->language = $languages->get($taal); echo $pages->LocalUrl($taal)->render(); }; ?> Any help would be much appreciated! I've been spending waaay too much time on this piece of hocus pocus already Gr, Bram
×
×
  • Create New...