Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Can someone recommend a customizable contact form, please?

  • This topic is empty.
Viewing 15 posts - 151 through 165 (of 225 total)
  • Author
    Posts
  • #175783
    __
    Participant

    Is there coding that’s supposed to be in the success page too?

    Yes. That’s the code we were talking about above.

    Because you are now submitting the form to a different page, you must process the form on that page (or it won’t be processed at all).

    #175784
    Anonymous
    Inactive

    Well, I am totally confused at this point. I thought we were only dealing with the page that has the CSS and coding for the form and the contact page the form is embedded in.

    I have no idea where I am at or what I’ve added to what that shouldn’t have been added, or changed what shouldn’t have been changed.

    #175837
    __
    Participant

    I thought we were only dealing with the page that has the CSS and coding for the form and the contact page the form is embedded in.

    Well, we were; but you wanted the form to submit to a different page. If it submits to another page, then you have to process the submission on that new page.

    Strictly speaking, there is no need to submit to a different page. Honestly, I think your needs would be better served keeping the form + submission all on the same page, and just add the ability to customize the “success” message. It would certainly be less confusing.

    #175874
    Anonymous
    Inactive

    Greetings Traq,

    On the contact page that the form is embedded in I have this:

      <div>
     <?= $contactForm->htmlMarkup("/new/test/success.php"); ?>
      </div>
    

    On the cform php that contains the CSS and other coding which styles the form and gives it its functions I have

    return str_replace( $placeholders,$replacements,$this-&gt;_htmlMarkup );
    
    <form class=cform action="http://www.wslmf.org/new/test/success.php" method=POST>
    

    and

    public function htmlMarkup_userNotice(){
    return ($this->_notice)?
    "<p>".htmlspecialchars( $this->_notice )."</p>":
    false;
    

    I believe these are the only changes I have made. I haven’t added anything to the success page. What do I need to add to it and what do I need to remove/change on the contact and php pages?

    Many Thanks.

    #175954
    __
    Participant

    Sorry. I have this bookmarked and I’ll get back to you with more help, but I’m probably going to be less-than-available for a few days here.

    In the meantime, consider whether you would be satisfied with staying on the same page and simply displaying the “success” message in place of the form on a successful submission. It is up to you, of course, but this would be a cleaner and less complicated solution in terms of coding. I (personally) think it is a better user experience, as well, but again, the choice is up to you: we can do it either way.

    #175961
    Anonymous
    Inactive

    Greetings Traq,

    Sorry. I have this bookmarked and I’ll get back to you with more help, but I’m probably going to be less-than-available for a few days here.

    Not a problem. I too have had other irons in the fire these past weeks which hasn’t been conducive to my keeping this matter clear in my mind.

    In the meantime, consider whether you would be satisfied with staying on the same page and simply displaying the “success” message in place of the form on a successful submission.

    Yes, that would be Ok, even better when considered as it keeps the site them constant instead of being directed to an out-of-place plain white page.

    What would be the best way to clear the information entered in the form after it is submitted? I see that the info previously entered is still cached after using the back button. I really want potential trolls, etc to be as discouraged as possible from abuse, and if they have to repeatedly re-enter info I don’t think they would stick around and do that. I know there are ways to do this, or does the token do this? It doesn’t appear to function properly if so.

    Best Regards.

    #176118
    __
    Participant

    I see that the info previously entered is still cached after using the back button. I really want potential trolls, etc to be as discouraged as possible from abuse, and if they have to repeatedly re-enter info I don’t think they would stick around and do that

    While the info is still in the history (and this is a browser behavior; we’re not doing it intentionally), the token will prevent the same form from being processed if it is submitted again (i.e., it causes multiple submissions to be ignored).

    The only way to prevent this completely would be to submit the form via ajax, so there is no page load (and thus no entry in the browser history).

    #176123
    Anonymous
    Inactive

    Greetings Traq,

    I have been reading about the various PHP functions in the form and trying to understand what does what, how and why. I thought the token prevented the form from being submitted again, but until all the rough edges I’ve created are smoothed out it isn’t testable.

    Many thanks for enlightening me on this.

    #176611
    Anonymous
    Inactive

    @traq

    Just curious when we might begin on this again.

    Best Regards.

    #176717
    __
    Participant

    maybe a day or two more… sorry, but I’ll definitely make time for it this week.

    #176732
    Anonymous
    Inactive

    Greetings Traq,

    No apology necessary, I just wanted to give you a reminder in case you had forgotten. I know it’s easy for things to slip ones mind when many things are going on.

    I sent you a message through what I thought was your business site, but I guess I had the wrong person. I was hoping to discuss your business.

    Best Regards.

    #176819
    __
    Participant

    I sent you a message through what I thought was your business site…

    If you’re talking about “custom-anything,” the site (and email) is long dead. It’s on its way to expiration… I should really take the whole thing down. Sorry about that. I’m working on a new site.

    #176820
    Anonymous
    Inactive

    If you’re talking about “custom-anything,” the site (and email) is long dead.

    Yep, that’s the one. I’ll fire of an e-mail to you tomorrow at the new address, which I’ve copied so you can remove it if desired.

    I’m scheduled to be away again for a few days beginning tomorrow evening, so there will be no need to begin on anything after that if you’ve other projects in the works. I am needing someone to hire to take care of some rough edges and keep things in check so to speak. I just bought a tablet (out of need) and had a look at a test page for the update site and I was satisfied with the look other than the drop-down menu width doesn’t respond properly to a tablet view. Anyway, I’ll address more tomorrow and we will see where things go from there.

    I am interested in finishing this tutorial and seeing how this ends and a bunch of Q&A afterwards, but again no immediate need given the planned away time.

    Many Thanks!

    #177064
    __
    Participant

    Alright, some minor changes, mostly in how the success/failure message is assigned:

    protected $_notice_failure = "Sorry; there was a problem.  Please try again.";
    protected $_notice_success = "Your message was sent successfully.  Thank you!";
    
    //  …
    
        protected function _sendEmail(){
    
            // …
    
            if( $sent ){
                $this->_notice = $this->_notice_success;
                // unset values now that they've been sent
                foreach( $this->_values as $k=>$v ){
                    $this->_values[$k] = "";
                }
            }
            else{ $this->_notice = $this->_notice_failure; }
        }
    

    You can add/change these messages to whatever text you prefer.

    Next, we change the code that displays the form to display the message when needed, and the form otherwise. Everything else stays the same.

    <!--  …  -->
    
      <div id="form">
        <?= $contactForm->htmlMarkup_userNotice()?:
            $contactForm->htmlMarkup() ?>
      </div>
    

    Now, at the moment, this will put out a rather plain “success” or “failure” message, and as I said, you can change it as desired. There’s two ways we might do this:

    1. add a template for the message (much like we have a template for the form itself), which the text of the message will be inserted into.
    2. allow the message to include its own HTML, and skip the template. This might be a good way to go, since we only have two possible messages. It would also be a bit easier to make a fancier message.

    I have made a new gist with these changes. I have tried to incorporate your current CSS rules and contact form page. You should double-check these, to make sure I got everything right, before copying them for your own use.

    #177074
    Anonymous
    Inactive

    Greetings Traq,

    I’m getting the following:

    Fatal error: Cannot redeclare cform::_sendEmail() in /””/””/””/””/test/class/cform.php on line 444

    I think I’ve left something in from before. I’m not sure though. I’ve compared your latest Gist to my working php and they appear to be the same. I’m trying to not simply copy and paste as I’m trying to understand the placements and other “whys”

    Best Regards.

Viewing 15 posts - 151 through 165 (of 225 total)
  • The forum ‘Other’ is closed to new topics and replies.