Jump to content

Search the Community

Showing results for tags 'form'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hello, i am trying to built one job search form but its not working, bellow is my code <form method="get" action="<?=$config->urls->root;?>search/"> <input type="text" placeholder="Keyword Search" name="keyword" id="keyword"> <select name="job_sector" id="job_sector"> <option>All Sectors</option> <option>Human Resources</option> <option>Consulting</option> </select> <select name="job_level" id="job_level"> <option>All Jobs Level</option> <option>Executive</option> <option>Manager</option> </select> <select name="job_location" id="job_location" > <option>All Locations </option> <option>city1</option> <option>city2</option> </select> <input type="submit" class="btn btn-primary btn-medium" value="Search Jobs" > </form> <?php $search_cat=""; // find any matching keyword if($input->get->job_keyword) { $search_cat="job_keyword~=".$input->get->job_keyword; } if($input->get->job_sector) { $search_cat=$search_cat.",job_sector=".$input->get->job_sector; } if($input->get->job_level) { $search_cat=$search_cat.",job_level=".$input->get->job_level; } if($input->get->job_location) { $search_cat=$search_cat.",job_location=".$input->get->job_location; } $jobs=$pages->find("template=job,$search_cat"); foreach($jobs as $job) { ?> but this code is not working. i want to find all pages with template job and any field select on form. Thanks
  2. Hi folks, Okay this is a bit of an odd one to explain so if you need to email please do at rich.g.cook(at)gmail.com and I'll happily pay a fee for any solutions if needed. I'm building a simple cart/checkout setup and on submission at the checkout the form action, on a static test, was submission.php and on this .php file it got the $_POST data from the form, parsed it using twig, and items and pushed it using swift mail to the seller and the buyer. This all works fine statically, but the issue is now it's on a CMS the $_POST data isn't getting saved across so upon submission all the fields (first name, address etc) are just returning blank. If I hard link the form submission to the templates folder to submission.php then it works but in the URL you have the weird .php whereas if I add it as a page and template in the CMS it drops the .php which is nicer but it doesn't seem to save any of the data this way. I know this is a bit confusing, but hopefully I've made some sense and you guys could help. Thanks, R
  3. I am trying to do the following: create a frontend form that generates a new page that has the fields from a template that a specific page uses. I send the page ID to the form and get the correct template and its fields from there. The presentation part of this form works, but as soon as it is trying to save, the $form variable does not contain the fields from the specified template so it saves a new page without any fields. Here's what I've got so far, hopefully anybody can tell me what I'm doing wrong (I've got most of this code from examples found on this forum): $page_id = htmlspecialchars($_POST['select_product']); // page ID $page = $pages->get($page_id); $template = $page->template; // this is the template where we will get the fields from // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; $form->attr("id+name",'subscribe-form'); // add the page's fields to the form $fields = $page->fieldgroup; foreach($fields as $field) { $inputfield = $fields->get("$field->name")->getInputfield($page); $form->append($inputfield); } // add template name field to the form $field = $modules->get("InputfieldHidden"); $field->label = "Template"; $field->attr('id+name','template_name'); $field->required = 1; $field->value = $template; $form->append($field); // append the field // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $submit->name = 'save_new_aanvraag'; $submit->attr("value", "Go"); $form->append($submit); // process the form if it was submitted if($this->input->post->save_new_aanvraag) { // now we assume the form has been submitted. // tell the form to process input from the post vars. $form->processInput($this->input->post); // see if any errors occurred if( count( $form->getErrors() )) { // re-render the form, it will include the error messages echo $form->render(); } else { // successful form submission $p = new Page(); // create new page object $p->template = $input->post->template_name; // set template $p->parent = $pages->get('/aanvraag/'); // set the parent foreach($form as $field) { $p->set($field->name, $field->value); } $p->save(); //create the page echo "<p>Page saved.</p>"; } } else { echo $form->render(); }
  4. I am trying to do frontend page creation via AJAX but when the form is loaded into an element, things like CKeditor and proper image uploading do not work. It seems javascript should be re-initialized on the elements that got added to the DOM after the initial page has loaded, but I don't know how to do this (if that is even what should be done in the first place)? I got it working fine without AJAX, via a regular template. But when I move the code to a file that is called by AJAX, javascript breaks on the form hence things like CKeditor don't work. Here's what's in HEAD of the main template: <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title><?php echo $headline; ?></title> <link rel="stylesheet" href="<?php echo $config->urls->templates;?>css/foundation.css" /> <script src="<?php echo $config->urls->templates;?>js/vendor/modernizr.js"></script> <!-- Somatonic page edit script --> <script> <?php $jsConfig = $config->js(); $jsConfig['urls'] = array( 'root' => $config->urls->root, 'admin' => $config->urls->admin, 'modules' => $config->urls->modules, 'core' => $config->urls->core, 'files' => $config->urls->files, 'templates' => $config->urls->templates, 'adminTemplates' => $config->urls->adminTemplates, 'adminTemplates' => $config->urls->adminTemplates, ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> <?php //$config->styles->prepend($config->urls->adminTemplates . "styles/main.css?v=2"); //$config->styles->append($config->urls->adminTemplates . "styles/inputfields.css"); //$config->styles->append($config->urls->adminTemplates . "styles/ui.css?v=2"); $config->scripts->append($config->urls->JqueryUI . "JqueryUI.js"); $config->scripts->prepend($config->urls->JqueryCore . "JqueryCore.js"); $config->scripts->append($config->urls->adminTemplates . "scripts/inputfields.js"); foreach($config->styles->unique() as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />"; foreach($config->scripts->unique() as $file) echo "\n\t<script type='text/javascript' src='$file'></script>"; ?> </head> It loads all the necessary script for frontend page creation. And here is the template that does the form processing: if ($command == "template_selection") { // Selected template ID $id = htmlspecialchars($_POST['template_id']); $page = $pages->get($id); $template = $page->template; foreach($template->fields as $field){ echo $field->label . ": "; //echo $field->type . "<br/>"; echo $page->get($field->name) . "<br/>"; } // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; // add the page's fields to the form $form->add($page->getInputfields()); // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $submit->name = 'submit'; $form->add($submit); // process the form if it was submitted if($input->post->submit) { $form->processInput($input->post); $page->save(); echo '<p>saved</p>'; } // render the form output echo $form->render(); die; } This template works properly when not called by AJAX, but, again, when I call it with an AJAX request, the javascripts don't work. Is there any way I can make this work?
  5. I am in the process of converting over a one page website to work with PW and am at the stage of hooking up the contact form but it's not working. I'm using the phpMailer script with a bit of jquery to process the form validation. I'm not set on converting over my current form to work with PW as the phpMailer script is a bit out of date now. All I need is something that works, outputs validation without a page refresh and ideally has some anti-spam measures built in. I know Ryan built the Form Template Processor so wasn't sure if this is a better route to go down? Here's the jquery for my current form. $(function() { // These first three lines of code compensate for Javascript being turned on and off. // It simply changes the submit input field from a type of "submit" to a type of "button". var paraTag = $('input#submit').parent('p'); $(paraTag).children('input').remove(); $(paraTag).append('<input type="button" name="submit" id="submit" class="btn pull-right" value="Send" />'); $('#main input#submit').click(function() { $('#main').append('<img src="assets/img/mail-ajax-loader2.gif" class="loaderIcon" alt="Loading..." />'); var name = $('input#form_name').val(); var email = $('input#form_email').val(); var subject = $('input#form_subject').val(); var comments = $('textarea#form_message').val(); $.ajax({ type: 'post', url: 'sendEmail.php', data: 'name=' + name + '&email=' + email + '&subject=' + subject + '&comments=' + comments, success: function(results) { $('#main img.loaderIcon').fadeOut(1000); $('ul#response').html(results); } }); // end ajax }); }); Any advice is greatly appreciated.
  6. Hi guys, I'd like to center the admin login form. Here's how it is now: http://api.drp.io/files/5442717971fe5.png Any suggestions on how to center it? I've tried to do it but it broke all the responsive layout... I guess my css skills are a bit rusty...
  7. Hello, I'm building a form through the API. In that form I am using a repeater field that is setup with 5 Ready-To-Edit New Repeater items. In the repeater is only one text input field named "servername". Now I'm having trouble accessing the repeater field values when I process the form. I read through the docs at https://processwire.com/api/fieldtypes/repeaters/. But when processing form input post values things seem to be different. I add the field to the form with: $registrationField = $fields->get("reg_servers")->getInputfield($pages->get("/registration")); $registrationField->attr("class","form-control"); $registrationForm->append($registrationField); The field is there in the form and working fine. Now when processing the form, I need to access the values of my repeater. Here's the relevant code: if($input->post->submitregistration) { $registrationForm->processInput($input->post); $servers = $registrationForm->get("reg_servers")->value; var_dump(count($servers)); // this gives int 5, which is fine foreach ($servers as $server) { echo "<pre>"; print_r($server->fields->servername); //servername is my text input field in the repeater echo "</pre>"; } exit(); } In the print_r output I can't find the value of my fields. I also tried var_dump($server->servername) and var_dump($server->servername->value) inside the foreach which gives an empty string. var_dump($server->fields->servername->value) gives null. How can I access my field values?
  8. Hello all, I'm back on my PW site and I'm facing an issue for a couple of hours now and it's driving me crazy... I'm sure it's not that much for a bunch of you, but it looks hopeless to me so here's my problem : I'm sending a form to a page and I have many checkboxes sent, so I used an array. My code looks like this : <table class="adminTable"> <tr> <td></td> <th ng-repeat="task in tasks" title="{{task.summary}}"><div class="vertical-text"><div class="vertical-text__inner">{{task.title}}</div></div></th> </tr> <tr> <td></td> <td ng-repeat="task in tasks" title="Tout cocher"><input type="checkbox" /></td> </tr> <tr ng-repeat="player in players"> <th>{{player.title}}</th> <td ng-repeat="task in tasks" title="{{player.name}} - {{task.title}}"> <!-- <input type="hidden" name="player[{{$parent.$index}}]" value="{{player.id}}" /> --> <input type="checkbox" name="player[{{player.id}}][]" value="{{task.id}}" /> </td> </tr> </table> The important line (to me) is the <input type="checkbox" name="player[{{player.id}}][]" value="{{task.id}}" /> in which I'm trying to pass both the id of the player and the task id to record for the player. All this is embedded into an ng-repeat loop since I'm using AngularJs... Anyway, the variables look ok when I'm looking at the generated source and in fact it look fine if I print_r($GLOBALS) when I recieve the POST variables. Here's the print_r($GLOBALS) result : [_POST] => Array ( [adminTableSubmit] => Enregistrer [player] => Array ( [5157] => Array ( [0] => 1580 [1] => 1578 ) [5171] => Array ( [0] => 1580 [1] => 1578 ) ) ) (2 players and 2 tasks for each) BUT : if I write $checked_players = $input->post->player; I get an empty array! Indeed, trying to debug my thing (I guess I can call it a 'thing' at this time), I type : foreach($input->post as $key => $value) echo htmlentities("$key = $value") . "<br />"; $checked_players = $input->post->player; print_r($checked_players); and here's what I get : adminTableSubmit = Enregistrer player = Array Array ( ) Whereas I keep thinking my print_r($checked_players) should return : [5157] => Array ( [0] => 1580 [1] => 1578 ) [5171] => Array ( [0] => 1580 [1] => 1578 ) so that I could then work with that and save data as pages... So please, what I am doing wrong? I'm sure I'm messing things up. I've tried so many possibilities and nothing has worked so far. Hence my message to the community. I really don't get it since it seems like such a basic problem... but the facts are there : I'm stuck Hope to hear from one of you soon. Thanks in advance for your help PS : Sorry for my long post, but I'm trying to be as clear s possible.
  9. Hi all, I am building a page that contains a quite complex request form. To do this, I created a page based on a "contact-form" template, and inside this template I put all the code needed to display the form and manage the results. The form is built using PW API, the code is inspired from some examples I found here on the forum. My problem is that I don't know how to insert a text paragraph between the fields, anyone has idea on how to do this? Here's a very simplified version of my code (only two fields displayed), in this case I would like to append a custom paragraph (simple html) between Company and Name fields. The only solution I found is to use an additional field of Fieldset type, without content, and on the label I set the text I need to output. However in the label field I am not able to insert html tags... Any help is very appreciated... Thank you! // create a text input $field = $modules->get("InputfieldText"); $field->label = "Company"; $field->attr('id+name','company'); $field->required = 1; $form_fields[] = $field; // create a text input $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form_fields[] = $field; // submit button $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Send"); $submit->attr("id+name","submit2"); $submit->skipLabel = '4'; // create the form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'contact-form'); foreach ($form_fields as $field) { $form->append($field); } $form->append($submit); // append the form in $out variable $out .= $form->render();
  10. Hi there I have been using soma's form-process.php to sort out uploading images and form details to create pages and it works great. However, I now want to extend it so that I can allow mixed allowed extensions like txt, csv as well as image files to be uploaded. (to allow designers etc to upload project files) - I don't however need to see the files or images, but just create a link in the created pages to let me download them from the created directory so that I can process/view them. Second part would be to get an email heads up (less of an issue), then do a drag and drop front end. Get there eventually. Any pointers or help that didn't need me to roll back too much would be great.
  11. Hi all I have built my own module for processing forms on my site. The module does check to see of the request was forged or not, but I am unable to inset the token name and value into my template. I use Twig for my templates, and this is what I'm calling: <form data-form-ident="contact-form" data-form-token-name="{{ this.session.CSRF.getTokenName() }}" data-form-token-value="{{ this.session.CSRF.getTokenValue() }}"> The output for that is an empty string. Could it perhaps be because I am using Twig? Side note: disabling Twig is not an option as the templates I'm using are very complex - it would be a darn mission to revert to native PHP. (PW 2.4.0)
  12. I'm hoping that someone can help me out with an ajax problem. I'm trying to build a front-end signup form, using jquery.validate for client-side validation, and then sending the form details via a jquery ajax post. The $.ajax submission reaches the target page OK, but the data that should have been sent with the post seems to get lost along the way. $_POST is always empty. The submitHandler for jquery.validate has the following code; $.ajax({ type: "POST", url: "/processMaths/admin/adduser", data: "name=fred&age=27", // data simplified for testing - I've also used {name:"fred",age:27} success: function(rtndata) { $('#debug').html(rtndata); } }); The page handling the ajax request has the following code added to try to work out what is going wrong. print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />"; $data = file_get_contents('php://input'); print "DATA: <pre>"; var_dump($data); var_dump($_POST); print "</pre>"; echo "here at adding users<br/>"; which updates my #debug div with the following message which suggests that no data reached the page. CONTENT_TYPE: DATA:string(0) "" array(0) { } here at adding users Does anyone have any ideas why the $_POST is empty. The same code outside of PW works OK, and I've previously used ajax inside PW without any problems. I'm stumped on this one - even tried rebooting in desperation, and I've run out of ideas for what else to try. There's obviously something different between my other working ajax calls (including other processwire sites) and this one, but I can't spot the difference. All use apache running on localhost, same version of jquery. The master plan is to set up a mathhelp site using processwire, where teachers can signup (and be assigned a role as "teacher"), and join up their students (role "student" ) - teachers get to set tasks for students to do, and monitor their results, so teachers will have access to more pages than the students (and ideally neither student or teacher will ever need to see the back-end admin pages ). Students, classes and teachers will all be pages. Is there an alternative front-end way of collecting user data that I should know? A more elegant way of using ajax perhaps? I've done so much head scratching my head is getting sore.
  13. Hi, I'm looking for a solution for the following: In a website we are building at the moment some files may only be downloaded after filling in a email address. After posting the form the direct link to the download will be sent to the given email address. In the backend there should be an option to label a downloadable file as 'protected'. What will be best way to achieve this?
  14. How could we add a repeater-field to our module configuration pages? I tried to add it like any other input field, but no success! (Just as a sidenote: Unfortunately my php skills are really restricted) This is my current state, but it just throws an exception: Error: Exception: Unknown column 'field_title.count' in 'field list' (in wire\core\Database.php line 118) public static function getModuleConfigInputfields(array $data) { $data = array_merge(self::getDefaultData(), $data); $inputfields = new InputfieldWrapper(); ... $field = wire("fields")->get("title"); $field->type = $modules->get("FieldtypeRepeater"); $repeater = wire("modules")->get("InputfieldRepeater"); $repeater->name = "somethingUnique"; $repeater->add($field); $repeater->page = wire("page"); $inputfields->add($repeater); ... return $inputfields; } Any idea what I'm doing wrong, or how we could achive this?
  15. Hi guys, I'd like to build a job listing section where anyone can submit jobs (with no user registration required) and job entries/pages would be created only after a payment through Paypal is received. So I was wondering if there's a PW module like Formidable Pro Paypal for WordPress. I know there's Form Builder, but is it suitable in this case? Does it have integration with Paypal?
  16. Was just wondering if anyone had any experience adding repeater items to a new page from a front-end form? The repeater consists of two fields, one a page field and the other a simple text value. I'm unsure how I'd go about adding those values on a new page save()? Thanks, as always.
  17. Hello all, today I've got a problem with a form submission, specifically with images uploads. Before strarting this thread I've read and followed this topics: http://processwire.com/talk/topic/126-anybody-did-user-registrationlogin/ http://processwire.com/talk/topic/3105-adding-file-upload-field-to-form-via-api/ And here is my code: https://gist.github.com/anonymous/5517109 The form subscription worked correctly until I've integrated the WireUpload function, that seems to cause me some problems...infact if i comment out this count() check in the code... if(!count($files)) { $u->error("Sorry, but you need to add a photo!"); return false; } ... the form data get recieved (everything but the images..) and the newpage created. So it seems that the image upload never runs. I also tried to override PHP's upload_temp_dir with $config->uploadTmpDir = dirname(__FILE__) . '/assets/uploads/'; in site/config.php and use that folder as my temporary one, but no luck there too... I want to notice that my console didn't recieve any errors when I submit the form, everything seems to work but it's not I'm on a local server (Wamp on Windows) and in my php.ini file file uploads and temporary directory are set like this: ; Whether to allow HTTP file uploads. ; http://php.net/file-uploads file_uploads = On ; Temporary directory for HTTP uploaded files (will use system default if not ; specified). ; http://php.net/upload-tmp-dir upload_tmp_dir = "c:/wamp/tmp" Any advices from you guys? Thanks.
  18. I just realized that my contact form is not working since updating to the latest version of PW. I gleaned the following code from the PW forums over a year ago. But I am a noob to php and can't seem to find what could be wrong with the code. Does anyone see anything obvious? <?php $sent = false; $error = 'user@example.com'; $emailTo = 'user.bill@example.com'; // or pull from PW page field // sanitize form values or create empty $form = array( 'fullname' => $sanitizer->text($input->post->fullname), 'email' => $sanitizer->email($input->post->email), 'comments' => $sanitizer->textarea($input->post->comments), ); // 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 = "<p class='error'>Please check that you have completed all fields.</p>"; } // if no errors, email the form results if(!$error) { $msg = "Full name: $form[fullname]\n" . "Email: $form[email]\n" . "Comments: $form[comments]"; mail($emailTo, "Website contact form submission", "$form[comments]", "From: $form[email]"); // populate body with success message, or pull it from another PW field $page->body = "<div id='message-success'><p>Thanks, your message has been sent.</p></div>"; $sent = true; } } if(!$sent) { // sanitize values for placement in markup foreach($form as $key => $value) { $form[$key] = htmlentities($value, ENT_QUOTES, "UTF-8"); } // append form to body copy $page->body .= <<< _OUT <form action="./" method="post" id="contact-form"> <fieldset> <legend>Send a note</legend> <ol> <li class="form-row"> <span class="error" style="display: none;" ></span> </li> <li class="form-row"> <label for="fullname">Name</label> <input id="fullname" name="fullname" type="text" size="30" class="name required default" title="Your name" value="$form[fullname]"/> </li> <li class="form-row"> <label for="email">Email</label> <input id="inputemail" name="email" type="text" size="30" class="required email default" title="Your email address" value="$form[email]" /> </li> <li class="form-row"> <label for="comments">Message</label> <textarea name='comments' rows='5' cols='45' id='comments' title="Your message">$form[comments]</textarea> </li> <li class="form-row"> <input type="submit" name="submit" value="Send" class="submit-button"/> </li> </ol> </fieldset> </form> _OUT; } ?><?php /** * Contact form template * */ include("./header.inc"); ?> <div class="main-container"> <div class="main wrapper clearfix"> <article> <section> <?php echo $page->body; ?> </section> </article> </div> <!-- #main --> </div> <!-- #main-container --> <? include("./footer.inc");
  19. Hey, I've a problem,witch i cant solve by myself so I hope you have any ideas what to do: I want to use FormTemplateProcessor here are my settings: A template called contact_form with two fields - contact_mail and contact_text - no template file associated. A template called contact with standard fields - title + body + images and so on - associated to contact.php <?php /** * Kontakt Seite * */ include("./head.inc"); ?> <div class="main wrapper clearfix"> <article class="clearfix"> <h2><?php echo $page->get("headline|title");?></h2> <?php echo $page->body; ?> </article> <?php $form = $modules->get('FormTemplateProcessor'); $form->template = $templates->get('contact_form'); $form->requiredFields = array('contact_email'); $form->email = 'mail@mail.com'; echo $form->render(); ?> </div> <!-- #main --> <?include("./foot.inc"); ?> This looks fine to me and if i try if it works on frontpage, everything seems to work. I got the message, that my submission has been sent. BUT I got no Mail. I've tested it with various e-mail addresses, checked my spambox, but I cant find a mail from my form. I've thought, that maybe there might be something wrong with my Server, but the log-file seems fine to me: 188.111.105.10 - - [21/Jan/2013:10:07:48 +0100] "POST /kontakt-email/ HTTP/1.1" 200 4643 "http://www.mydomain.de/kontakt-email/" "Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0" "www.mydomain.de" I don't know where to search for errors. Perhaps I have to mention that I'm using a various admin path... Would like to hear your advices. Many greets, Jens alias DV-JF
  20. Hi y'all! Im am trying to force a file download after user submits a form. When user hits submit button POST data are send to a template (sort of "thank you for downloading" page). This template on successful submission redirects to another template through this code <?php $downloadurl = $pages->get('/download/')->url; header('refresh: 0; url='.$downloadurl); ?> Redirection then hits this template code (located in download template): <?php // filename & url of the pdf file $filename = $pages->get('/some-page/')->file->name; $fileurl = $pages->get('/some-page/')->file->url; $filesize = $pages->get('/some-page/')->file->filesize; // force download of the file header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename='.$filename); header("Content-Length: ".$filesize); readfile($fileurl); It downloads a file and then redirects back to thank you page. The only problem is that the downloaded file is empty (0KB). When i download a file "the standard way" clicking on a link that directs to $pages->get('/some-page/')->plik->url; everything is ok. Any ideas?
  21. Hi guys, sorry to be bugging you, was just wondering if anyone with more PHP experience may be able to see a line or two in my code which is stopping the form from working. It's essentially a working contact form that Ryan helped me with to which I'm trying to integrate PHPMailer as I was having problems receiving mail natively. Here is my code: <?php include("./header.inc"); $success_message = "<h3 class='success'>Thank you, your message has been sent.</h3>"; $success = false; // we assume it and set to true if mail sent $error = false; // set and sanitize our form field values $form = array( 'name' => $input->post->name, 'email' => $input->post->email, 'phone' => $input->post->phone, 'subject' => $input->post->subject, 'level' => $input->post->level, 'hours' => $input->post->hours, 'message' => $input->post->message ); $required_fields = array( 'name' => $input->post->name, 'email' => $input->post->email, 'subject' => $input->post->subject, 'level' => $input->post->level, ); // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($required_fields as $key => $value) { if( trim($value) == '' ) { $error_message = "<h3 class='error'>Please check that you have completed all the required fields.</h3>"; $error = true; } } // if no errors, email the form results if(!$error) { $to_name = "To name"; $to = "recipient@email.com"; $subject = "Contact Form Request"; $from_name = "From Name"; $from = "sender@email.com"; foreach($form as $key => $value) $message .= "$key: $value\n"; require_once("./scripts/PHPMailer/class.phpmailer.php"); require_once("./scripts/PHPMailer/class.smtp.php"); $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->Username = "username"; // GMAIL username $mail->Password = "password"; // GMAIL password $mail->FromName = $from_name; $mail->From = $from; $mail->AddAddress($to, $to_name); $mail->Subject = $subject; $mail->Body = $message; $mail->Send(); if ($mail->Send()) { $success = true; } } } ?> <?php if(!$success) { ?> <?php if($error) { echo $error_message; // or pull from a PW field } ?> <p id="contact_header">If you'd like to get in touch regarding tuition, please use the form below.</p> <div id="contact_aside"> <h6>Or you can find me, here: </h6> <ul> <li>Skype: <?php echo $page->skype_name; ?></li> <li><a href="<?php echo $page->fb_url; ?>" target="_blank">Facebook</a></li> <?php if ($page->twitter_url) { echo "<li><a href='$page->twitter_url' target='_blank'>Twitter</a></li>"; } ?> </ul> </div><!-- /#contact_aside --> <div class="clear"></div><!-- /.clear --> <form action="./" method="post" id="contact_form"> <fieldset class="first"> <h6>About yourself: </h6> <label for="name">Your name: (required) </label> <input type="text" name="name" autofocus> <label for="email">Your email: (required) </label> <input type="email" name="email"> <label for="phone">Your phone number: </label> <input type="phone" name="phone"> </fieldset> <fieldset> <h6 class="mt60">Your tuition: </h6> <label for="subject">Subject: </label> <select name="subject" id="subject" /> <?php foreach ($page->subject_options as $subject) { echo "<option>$subject->subject_option</option>"; } ?> </select> <label for="level">Level: </label> <select name="level" id="level" /> <?php foreach ($page->level_options as $level) { echo "<option>$level->level_option</option>"; } ?> </select> <label for="hours">Hours per week: </label> <input type="number" min="1" max="40" value="2" name="hours"> </fieldset> <div class="clear"></div><!-- /.clear --> <fieldset class="full"> <label for="message">Additional information: </label> <textarea name="message" cols="30" rows="10"></textarea> <input type="submit" name="submit" value="submit" id="submit"> </fieldset> </form> <div class="clear"></div><!-- /.clear --> <?php } else { echo $success_message; ?> <p>Please click <a href="<?php echo $config->urls->root; ?>">here</a> if you would like to return to the homepage.</p> <?php } ?> <?php include("./footer.inc"); ?> At present when the form is submitted, the page seems to think about something for a while then the page gets reloaded exactly the same as before. Thanks in advance if you have any ideas.
  22. Hi guys, have been trying to figure out how I can get hold of a file's path when it has been uploaded via a form. I don't need to add it to the database, just email it. I am currently using phpmailer to send the email and all I need for it to send the attachment is the path of the uploaded file. I have tried using $input->post then I was thinking it may be something to do with $file or $files?
  23. Am trying to get my own simple contact form up and running and I would prefer to have a very simple one but understand the code that makes it work before trying to do anything complicated. I've created a contact form with contact template and have made action="form.php" method="POST" I've tried setting up a template for form but I keep getting the error that the template does not exist when I submit. On my form.php I want to start really simply just to test that the $input method is working so I just have: <?php $name = $input->post->name; echo $name; ?> Would appreciate any guidance just to get me on my way.
  24. Scratching my head here. I'm trying to find a simple way for the client to be able to add options to a select tag in a form. Do I really have to use pages here? I can use a textarea - convert new lines to <li> tags but that won't cut it for <option> tags. Repeater field? If that is the best option could anyone tell me how I would output the results as <li> tags? Ideally it would be a fieldtype where each drop-down was some sort of item that I could loop in <option> tags. Thanks Edit: I've come up with this code for a repeater file and it seems to be doing the trick. <?php echo "<ul>"; foreach ($page->subject_options as $item) { echo "<li>$item->subject_option</li>"; } echo "</ul>"; ?> I would be interested though if there was a faster or 'cleaner' way of doing this.
×
×
  • Create New...