SteVis Posted March 15, 2008 Share Posted March 15, 2008 I've put together a simple contact form and i'm trying to e-mail the data collected. Code: <?php // include the required PEAR class require_once 'HTML/QuickForm.php'; $form = new HTML_Quickform('contact'); //add the elements $form->addElement('header', 'contact_header', 'Request a Quote or Information'); $form->addElement('text', 'fname', 'First Name:', 'size="30" maxlength="128"'); $form->addElement('text', 'lname', 'Last Name:', 'size="30" maxlength="128"'); $form->addElement('text', 'email', 'E-Mail:', 'size="30" maxlength="128"'); $form->addElement('text', 'company', 'Company:', 'size="30" maxlength="128"'); $form->addElement('textarea', 'detail', 'Quick description:', 'setrows="15"'); $form->addElement('submit', 'send', 'Submit'); //group the elements to ease the e-mail process //add some rules $form->addRule('fname','Please enter your first name','required'); $form->addRule('lname','Please enter your lirst name','required'); $form->addRule('email', 'Please enter a e-mail address', 'required'); $form->addRule('email', 'Please enter a valid E-Mail address', 'email'); //e-mail the form and display a confirmination message if ($form->validate()) { $form->process('send_message'); } else { $form->display(); } function send_message($data) { mail(me@uber.com','Request information/quote',$data['detail'], $data['email']); echo "Thank you"; } ?> This code works, and it sends the e-mail but I can only get it to send the data from two fields because the mail() only allows 5 parameters or something along those lines. I'm assuming I need to put the form values in an array or something like that but I'm lost on exactly what to do. Quote Link to comment Share on other sites More sharing options...
SteVis Posted March 18, 2008 Author Share Posted March 18, 2008 I realize that this probably wasn't the best board for a PEAR problem but for anyone who may have come across this, my solution is here. if ($form->validate()) { $form->freeze(); $form->process('send_message'); } else { $form->display(); } function send_message($data) { $message = array($data['fname'], $data['lname'], $data['email'], $data['message']); $str = implode(",", $message); mail('shamilt01@gmail.com','Request information/quote',$str); echo "Thank you, we will get back to you as soon as possible"; } I bassically just made an array of the fields (which I should have automated) and imploded the array into a string so I could use the mail() function. Anyway, peace out. 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.