Tylor Eddy Posted August 27, 2011 Report Share Posted August 27, 2011 G'day Guys, I am attempting to create 2 duplicates of the Contact form, and its php file, to create a training request form, and also a management positions application. I am able to create the forms, they are the easy bit. What i'm stuck on is editing the contact.php (now training.php for the new module) to show the different fields in the form, and also display it differently in the email sent out after the form is completed. This is what i have so far, to help explain what i wish to change. <?php /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * * @author Nabeel Shahzad * @copyright Copyright (c) 2008, Nabeel Shahzad * @link http://www.phpvms.net * @license http://creativecommons.org/licenses/by-nc-sa/3.0/ */ class Training extends CodonModule { public function index() { require_once CORE_LIB_PATH.'/recaptcha/recaptchalib.php'; if($this->post->submit) { if(Auth::LoggedIn() == false) { # Make sure they entered an email address if(trim($this->post->name) == '' || trim($this->post->email) == '') { $this->set('message', 'You must enter a name and email!'); $this->render('core_error.tpl'); return; } } $resp = recaptcha_check_answer (Config::Get('RECAPTCHA_PRIVATE_KEY'), $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); // Check the captcha thingy if(!$resp->is_valid) { $this->set('captcha_error', $resp->error); $this->set('message', 'You failed the captcha test!'); $this->render('training_form.tpl'); return; } if($this->post->subject == '' || trim($this->post->message) == '') { $this->set('message', 'You must enter a subject and message!'); $this->render('core_error.tpl'); return; } $subject = 'New message from '.$this->post->name.' - "'.$this->post->subject.'"'; $message = DB::escape($this->post->message) . PHP_EOL . PHP_EOL; unset($_POST['recaptcha_challenge_field']); unset($_POST['recaptcha_response_field']); foreach($_POST as $field=>$value) { $message.="-$field = $value".PHP_EOL; } $message = nl2br($message); $message = utf8_encode($message); Util::SendEmail($this->post->recipient, $subject, $message); $this->render('training_sent.tpl'); return; } # Just a simple addition $rand1 = rand(1, 10); $rand2 = rand(1, 10); $this->set('rand1', $rand1); $this->set('rand2', $rand2); $tot = $rand1 + $rand2; //echo "total: $tot <br />"; SessionManager::Set('captcha_sum', $tot); //echo 'output of $_SESSION: <br />'; //print_r($_SESSION); $this->render('training_form.tpl'); } } Near the center it says to display -$fields I would like to change these fields so it displays different names for what is being presented, instead of subject & message in the email sent out. As it will confuse the staff member who gets the email Also how can i call an extra field ? Hopefully i've made sense here with what i've said haha Cheers Tylor Currently the email looks like this: 12:30 -name = Tylor Eddy -email = email here -recipient = recipient email -subject = 28.7.11 -message = 12:30 -loggedin = true -submit = Send Message i would like to change the fields to say 12:30 -name = Tylor Eddy -email = email here -recipient = recipient email -Date = 28.7.11 -Time = 12:30 -loggedin = true -submit = Send Message and also get rid of the 12:30 displaying above the email Quote Link to comment Share on other sites More sharing options...
dimitris Posted August 28, 2011 Report Share Posted August 28, 2011 Why you are not using one contact form but with a dropdown from which the sender have to choose the subject of his mail ? and also according to the subject you can use if...else statements to send the email to different receivers 1 Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 29, 2011 Author Report Share Posted August 29, 2011 Why you are not using one contact form but with a dropdown from which the sender have to choose the subject of his mail ? and also according to the subject you can use if...else statements to send the email to different receivers I want to be able to use seperate forms for different area's within my site, that relay different information to various people in my management team, that's why i would like to have these two different forms. Quote Link to comment Share on other sites More sharing options...
MBrown Posted August 29, 2011 Report Share Posted August 29, 2011 If all fails, it may actually be easier to just create two separate contact forms using a free service on the internet. Saves a hell of a lot of work with coding and you can optimize it to your liking (i.e. drop downs etc.). Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 29, 2011 Author Report Share Posted August 29, 2011 If all fails, it may actually be easier to just create two separate contact forms using a free service on the internet. Saves a hell of a lot of work with coding and you can optimize it to your liking (i.e. drop downs etc.). I looked into using one off the internet, I ran into trouble when it came to integrating it as a module. I've already created the forms, customised from the contact.tpl form, all that i need now is to customise the .php backend to send out the email with the new fields Quote Link to comment Share on other sites More sharing options...
MBrown Posted August 29, 2011 Report Share Posted August 29, 2011 I looked into using one off the internet, I ran into trouble when it came to integrating it as a module. I've already created the forms, customised from the contact.tpl form, all that i need now is to customise the .php backend to send out the email with the new fields Hmm I see, what I did was just get a nice looking script from the internet and instead of creating it as a module I created a page called "Contact Us" and pasted the script into that and voila Sorry I can't really help the way you are doing it, but if you want to mak it slightly easier and try my way just let me know and I will be glad to help out. Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 29, 2011 Author Report Share Posted August 29, 2011 Hmm I see, what I did was just get a nice looking script from the internet and instead of creating it as a module I created a page called "Contact Us" and pasted the script into that and voila Sorry I can't really help the way you are doing it, but if you want to mak it slightly easier and try my way just let me know and I will be glad to help out. How did you call the fields, that's where i'm having the trouble. I'd be happy to see how you've done it, especially if its easier haha Quote Link to comment Share on other sites More sharing options...
mattia Posted August 29, 2011 Report Share Posted August 29, 2011 Try this: This is an example for the proposed schedule <body> <form action="mailto:YOUR EMAIL@.COM?subject=YOUR SUBJECT" method="post" id="miomodulo" enctype="text/plain"> <label for="nome"><font color=yellow><b>DEPP ICAO</b></font></label><br /> <input type="text" id="DEPP ICAO" name="DEPP ICAO" size="20" /> <br /> <br /> <label for="cognome"><font color=yellow><b>ARR ICAO</b></font></label><br /> <input type="text" id="ARR ICAO" name=ARR ICAO" size="20" /> <br /> <br /> <label for="parere"><font color=yellow><b>DEP TIME</b></font></label><br /> <input type="text" id="DEP TIME" name="DEP TIME" size="20" /> <br /> <br /> <label for="parere"><font color=yellow><b>ARR TIME</b></font></label><br /> <input type="text" id="ARR TIME" name="ARR TIME" size="20" /> <br /> <br /> <label for="parere"><font color=yellow><b>Flight Time:</b></font></label> <br /> <input type="text" id="Flight Time:" name="Flight Time:" size="20" /> <br /> <br /> <font color=yellow><b>Days of Week:</b></font> <br /> <label for="parere"><font color=yellow>sunday:</label> <input type="Checkbox" id="sunday" name="sunday" size="20" /> <label for="parere">monday:</label> <input type="Checkbox" id="monday" name="monday" size="20" /> <label for="parere">tuesday:</label> <input type="Checkbox" id="tuesday" name="tuesday" size="20" /> <label for="parere">Wednesday:</label> <input type="Checkbox" id="Wednesday" name="Wednesday" size="20" /> <label for="parere">Thursday :</label> <input type="Checkbox" id="Thursday " name="Thursday " size="20" /> <label for="parere">Friday :</label> <input type="Checkbox" id="Friday " name="Friday " size="20" /> <label for="parere">Saturday :</font></label> <input type="Checkbox" id="Saturday " name="Saturday " size="10" /> <br /> <br /> <font color=yellow><b>Equipment: :</b></font><br /> <SELECT size=1 cols=4 NAME="Equipment"> <OPTION value=YOUR AIRCRAFT CODE > YOUR AIRCRAFT CODE </select> <br /> <br /> <label for="parere"><font color=yellow><b>FLIGHT LEVEL:</b></font></label><br /> <input type="text" id="FLIGHT LEVEL" name="FLIGHT LEVEL" size="20" /> <br /> <br /> <font color=yellow><b>Flight Type:</b></font><br /> <SELECT size=1 cols=4 NAME="Flight Type"> <OPTION value=Passenger> Passenger <OPTION value=Cargo> Cargo </select> <br /> <br /> <label for="parere"><font color=yellow><b>price:</b></font></label><br /> <input type="text" id="Price" name="price" size="20" /> <br /> <br /> <font color=yellow><b>Route</b></font> <br /> <textarea cols="50" rows="4" WRAP="physical" name="Routes "></textarea> <br /> <br /> <font color=yellow><b>Notes</b></font><br /> <textarea cols="50" rows="4" WRAP="physical" name="Notes "></textarea> <br /> <br /> <input type="submit" value="send" /> <input type="reset" value="delete" /> </form> </body> Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 29, 2011 Author Report Share Posted August 29, 2011 G'day Mattia, Not sure how you are calling this on your website, is it a module ? Quote Link to comment Share on other sites More sharing options...
MBrown Posted August 29, 2011 Report Share Posted August 29, 2011 Feel free to see a live demo, is this along your lines? http://www.palmairva.com/index.php/pages/contactus Quote Link to comment Share on other sites More sharing options...
mattia Posted August 29, 2011 Report Share Posted August 29, 2011 G'day Mattia, Not sure how you are calling this on your website, is it a module ? I add new page and in page i have added this code Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 29, 2011 Author Report Share Posted August 29, 2011 I add new page and in page i have added this code aha, i get you now, ill let you know how i go, when i have a go later this afternoon. Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 30, 2011 Author Report Share Posted August 30, 2011 aha, i get you now, ill let you know how i go, when i have a go later this afternoon. G'day Mattia, Just tried you code, it's using a mail application to send the form, and that's not what i want it to do, i'd prefer it to just send it out after its filled out with the information Quote Link to comment Share on other sites More sharing options...
mattia Posted August 30, 2011 Report Share Posted August 30, 2011 G'day Mattia, Just tried you code, it's using a mail application to send the form, and that's not what i want it to do, i'd prefer it to just send it out after its filled out with the information I also want it so Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 30, 2011 Author Report Share Posted August 30, 2011 I also want it so I've made a break through with the code, if all goes to plan, i'll share what i did sometime tomorrow i have a fully functional form, but i cannot for the life of me get the captcha to work, you dont even have to fill it in and the form will still send :S Quote Link to comment Share on other sites More sharing options...
mattia Posted August 30, 2011 Report Share Posted August 30, 2011 ok I look forward Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted August 31, 2011 Author Report Share Posted August 31, 2011 G'day Guys, A quick question, how can i set up these forms so they can only be used by members ? That will save using a captcha. Quote Link to comment Share on other sites More sharing options...
Jeff Posted September 1, 2011 Report Share Posted September 1, 2011 Try this at the very top of your .tpl file <?php if(Auth::LoggedIn() == false) { echo 'You must be logged in to view this page!'; return; } ?> Quote Link to comment Share on other sites More sharing options...
Tylor Eddy Posted September 1, 2011 Author Report Share Posted September 1, 2011 Try this at the very top of your .tpl file <?php if(Auth::LoggedIn() == false) { echo 'You must be logged in to view this page!'; return; } ?> Cheers, works great Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.