Welcome Guest, Not a member yet? Register   Sign In
puzzling error msg in form validation controller
#11

[eluser]TheFuzzy0ne[/eluser]
I don't understand what you're trying to do, but to concatenate strings you need to use the . operator.

Code:
$some_var  . "some string" . "another string" . $another_var . ' ' . $another_var2;
#12

[eluser]Dam1an[/eluser]
Or if you don't want to do concatenation, you can use double quotes, in which case variables will be replaced with their values

And Fuzz, it was 15 minutes between my post stating the problem and n0xies stating it, followed by you 3 inutes later Tongue
#13

[eluser]TheFuzzy0ne[/eluser]
One suggestion might be for you to use a view for your Email. Pass some variables into it, get the resulting page, and then stick it in your Email.
#14

[eluser]oldnews[/eluser]
To clarify, my email submit form in views follows the CI User Guide's suggested layout. I don't believe that is the problem, particularly since I have triple checked to be sure the assigned field names match the designated variables in the form validation routine. My issues continue to revolve around the email library load. My latest revised code, taking last night's advisories, is now yielding: Call to undefined method CI_Email::email_from() for line 35, though I think am observing the suggested construction under the Email Function Reference heading on the CI User Guide Email Class page:

Code:
<?php

class Form extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        
        $this->load->library('form_validation');
                
        $this->form_validation->set_rules('who', 'your name', 'required');
        $this->form_validation->set_rules('mainphone', 'primary phone', 'required');
        $this->form_validation->set_rules('email', 'email address', 'required|valid_email');
        $this->form_validation->set_rules('extraphone', 'additional phone');
        $this->form_validation->set_rules('address', 'mailing address', 'required');
        $this->form_validation->set_rules('altphone', 'alternative phone');
        $this->form_validation->set_rules('city', 'municipality', 'required');
        $this->form_validation->set_rules('zip', 'zip code', 'required');
        $this->form_validation->set_rules('description', 'describe photo', 'required');
        $this->form_validation->set_rules('location', 'photo location', 'required');
        $this->form_validation->set_rules('ageutresidency', 'certification checkbox', 'required');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('header2');
            $this->load->view('myform');
            $this->load->view('footer2');
        }
        else
        {

            $this->load->library('email');

            $this->email->subject("Best Summer Vacation Picture contest entry");
            $this->email->email_from($email, $who);
            $this->email->reply_to($email, $who);
            $this->email->to("[email protected]");
            $this->email->message($address . ", " . $city . ", UT " . $zip . ", photo description: " . $description . ", location: " . $location . ", primary phone: " . $mainphone . ", optional secondary phone: " . $extraphone . ", optional tertiary phone: " . $altphone . ", certification of minimum age of 18 and UT residency: " . $ageutresidency);

//            $this->email->attach("/uploads/"$photofile);

            $this->email->send();

            echo $this->email->print_debugger();

            if ( ! $this->email->send())
            {
                // Generate error
            }
            else
            {
                $this->load->view('closer');
            }
        }
    }
}

// End of file: form.php
// Location: ./system/application/controllers/form.php

This is all very confusing. I suppose the undefined method referred to by the error message is distinct from the email function, but where must I direct my attention in the User Guide to grasp this nuance and do the correct coding that will generate what is billed as a simple email send process?
#15

[eluser]n0xie[/eluser]
[quote author="oldnews" date="1245536075"]
Call to undefined method CI_Email::email_from() for line 35, though I think am observing the suggested construction under the Email Function Reference heading on the CI User Guide Email Class

Code:
$this->load->library('email');

            $this->email->subject("Best Summer Vacation Picture contest entry");
            $this->email->email_from($email, $who);
            $this->email->reply_to($email, $who);
            $this->email->to("[email protected]");
This is all very confusing. I suppose the undefined method referred to by the error message is distinct from the email function, but where must I direct my attention in the User Guide to grasp this nuance and do the correct coding that will generate what is billed as a simple email send process?[/quote]

See http://ellislab.com/codeigniter/user-gui...email.html

Quote:Email Function Reference
Code:
$this->email->from()
Sets the email address and name of the person sending the email:
Code:
$this->email->from('[email protected]', 'Your Name');
#16

[eluser]oldnews[/eluser]
Precisely! Then what coding mistake is causing the error, when, in the companion views/myform.php, these variables are set within the first 3 data fields?

Code:
<html>
<head>
<title>Entry Form</title>
<LINK REL=StyleSheet href="./style.css" type="text/css" media=screen>
</head>
<body>

<table cellpadding="0" cellspacing="0" border="0" width="800">
<tr>
<td class="red">Now, fill out our entry form completely...<br />
&nbsp;<br />

&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('form'); ?&gt;

<center>
<table  border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="right">your name:</td>
<td>&lt;input type="text" name="who" value="&lt;?php echo set_value('who'); ?&gt;" size="42" /&gt;&lt;/td>
<td align="right" colspan="2">primary phone:</td>
<td>&lt;input type="text" name="mainphone" value="&lt;?php echo set_value('mainphone'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
<tr>
<td align="right">email address:</td>
<td>&lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="42" /&gt;&lt;/td>
<td align="right" colspan="2"><i>option add phone</i>:</td>
<td>&lt;input type="text" name="extraphone" value="&lt;?php echo set_value('extraphone'); ?&gt;" size="20" /&gt;&lt;/td>
</tr>
et cetera...

method == function or method != function?
#17

[eluser]oldnews[/eluser]
Quote:One suggestion might be for you to use a view for your Email. Pass some variables into it, get the resulting page, and then stick it in your Email.
advised theFuzzyOne

Actually, I was thinking about a plain, non-CI-framework HTML email form with a standard, stand-alone PHP background companion, to process entry submissions. Is this what you meant, Fuzz? Or could you elaborate/clarify what it is you are suggesting?
#18

[eluser]TheFuzzy0ne[/eluser]
Well my Emails are sent as HTML, so I'd have a view like this:
Code:
<p>
    Hi, &lt;?php echo $username; ?&gt;
</p>
<p>
    You are recieving this message because &lt;?php echo $last_post_user_name; ?&gt; has replied to a topic you have subscribed to.
</p>
<p>
    Please click <a href="&lt;?php echo site_url('forums/view_post/'.$post['id']); ?&gt;" title="View Topic &apos;&lt;?php echo $topic['title']; ?&gt;&apos;">here to view the topic.
</p>

Then from my controller, I should be able to grab the body of the email like this:
Code:
$email_body = $this->load->view('email', $data, TRUE);

Then I can use that as the Email body, and configure the Email library accordingly.

Hope this helps.
#19

[eluser]oldnews[/eluser]
Thanks for clarifying, Fuzz. I see what you're doing. What I'm doing is somewhat different: strangers submitting contest entries which include an uploaded picture for a sponsor who requires data harvesting of several key fields. Late last night, I set up a work-around html email form with a background, non-CI, PHP companion handler that has worked fine on less complex contest sites. I wish you would try uploading a sample jpg on the CI-managed landing page. Then attempt to fill in that CI-managed form (controller code shown in my last publication several replies back on the first page), and when it fails, go to my work-around non-CI PHP email form that DOES execute. You may get a better sense for what needs to be accomplished WITH CI form validation. The site is not actually live, yet: we're still testing to try to get the handlers to do everything seemlessly. And, BTW, I know I can pass the variable (that's displayed in a text field) as hidden, but for testing purposes, I'm putting it out there in plain view for now. Thanks. All advice is welcome and appreciated.

UploadPixMaverik.com
#20

[eluser]n0xie[/eluser]
[quote author="oldnews" date="1245545099"]Precisely! Then what coding mistake is causing the error
[/quote]

Code:
// your code
$this->email->email_from($email, $who);

// the userguide
$this->email->from($email, $who);

Quote:method == function or method != function?
http://nl3.php.net/manual/en/language.oop5.basic.php




Theme © iAndrew 2016 - Forum software by © MyBB