- This topic is empty.
-
AuthorPosts
-
August 9, 2014 at 10:52 am #178397
Anonymous
InactiveGreetings traq,
As we discussed previously I believed all were to be
<p class="">
due to ease of styling. You have<p class="cform-success">Your message was sent successfully. Thank you!</p>
in the tutorial, so I am confused as to what it’s to be as I believed the v<
div> was dismissed. I prefer having control of styling in the CSS as opposed to it being in the HTML itself as we covered earlier. There is no < div> in my coding.
Best Regards.
August 9, 2014 at 11:21 am #178399__
ParticipantLook at the class properties where we define the messages:
protected $_notice_failure = <<< HTML <p class="cform-failure">Sorry; there was a problem. Please try again.</p> HTML; protected $_notice_success = <<< HTML <p class="cform-success">Your message was sent successfully. Thank you!</p> HTML;
This is where the HTML, that we see displayed as text, is coming from. If you don’t want it, you need to change these values so they include only text.
If you do this, then you will only have the
cform-notice
class available as a styling hook (i.e., there will be nosuccess
orfailure
classes, nor any other markup). It is your decision, but in all honesty I would recommend allowing the html and just removing thehtmlspecialchars
call.August 9, 2014 at 11:41 am #178407Anonymous
InactiveThis is where the HTML, that we see displayed as text, is coming from. If you don’t want it, you need to change these values so they include only text.
You’re waaaaaaay over my head on this at 9:40 pm my time. Let me revisit this again tomorrow with a refreshed mind.
I do want the styling controlled in the CSS however, if that makes sense.
Many Thanks!
August 9, 2014 at 2:00 pm #178418__
ParticipantLet me revisit this again tomorrow with a refreshed mind.
No problem. You’re very welcome.
I do want the styling controlled in the CSS however, if that makes sense.
Styling will always be controlled via CSS. I am not suggesting any sort of inline styling.
Right now, we’re talking about why we see some html markup in the notice as regular text. It appears as regular text because the
htmlMarkup_userNotice
method uses thehtmlspecialchars
function. My best recommendation is to just change the code so it doesn’t usehtmlspecialchars
(as demonstrated previously).Once that is done, the markup will be treated as html and won’t appear as text. Plus, you can still remove it from the user notice if you wish.
August 9, 2014 at 10:00 pm #178438Anonymous
InactiveGreetings traq,
I made the change like so
<p class="cform-notice">'.$this->_notice.'</p>
But now the challenge questions will not allow the variable answers, i.e. “1”, “One”, “one”
Also, the alignment of the text is not working correctly.
August 9, 2014 at 10:58 pm #178439__
ParticipantBut now the challenge questions will not allow the variable answers
We’re making the comparison “case-insensitive” by converting the user’s answer to lowercase. For example, if the user submits “ONE” or “One” or “oNe” (etc.), it will be converted to “one” before being compared to the acceptable answers.
So, the quick fix is to define all of your “correct” answers in lower case. For example, the correct answer should be “one”, not “One”. We can rewrite the code for a more “complete” fix if you wish; I’ll address that tomorrow.
the alignment of the text is not working correctly.
the
cform-notice
wrapper should be a div, not a paragraph (paragraphs can’t wrap other paragraphs: that’s what is happening, you have two paragraphs (each 394px wide and display:table-cell; one is empty) side-by-side).August 9, 2014 at 11:24 pm #178441Anonymous
InactiveGreetings traq,
Ok, it’s working now and the challenge question didn’t work because one of the variables I typed in didn’t exist in the array.
I want to test it some more, but thus far it seems to be perfect.
I do have a question. How/Why did the case-insensitive option cause the spam trap to trigger and cause the Recipient to not validate before that change was made?
Many thanks!
August 9, 2014 at 11:36 pm #178442__
ParticipantHow/Why did the case-insensitive option cause the spam trap to trigger and cause the Recipient to not validate before that change was made?
Basically the same reason: the Recipient is validated by looking up an email address that matches the label the user selects. Converting (for example) “General Inquiry” to lowercase results in “general inquiry”, and there is no such label in the array.
August 9, 2014 at 11:48 pm #178444Anonymous
InactiveBasically the same reason: the Recipient is validated by looking up an email address that matches the label the user selects. Converting (for example) “General Inquiry” to lowercase results in “general inquiry”, and there is no such label in the array.
Ah! So simple! I literally couldn’t see the forest for the tress on that one.
The form is working to perfection! Is there anything else you can think of the needs to be done, or might be worth doing?
I’ve learned much from this and am still Googling things. I’m honored that you took the time to do this and allow me to learn something I wouldn’t have had the privilege to learn otherwise.
I think we also set a record for the longest thread! LOL
Best Regards.
August 10, 2014 at 9:39 am #178466__
ParticipantIs there anything else you can think of the needs to be done, or might be worth doing?
For your usage, I don’t think so. If I were to release this as a general-purpose script, I’d probably add “setter” methods to change options, add/remove recipients, etc..
I’ve learned much from this …
Great! Glad I could be a part of that!
August 10, 2014 at 11:29 pm #178483Anonymous
InactiveGreetings traq,
There is another question that I want to ask that relates to this in a way. On the contact page itself you used
session_start(); include_once "{$_SERVER['DOCUMENT_ROOT']}/””/””/class/cform.php"; $contactForm = new cform( $_POST );
And I see this potentially being helpful with other things one might want to include into a page that requires frequent changes such as the menu bar on the page. If this “include” is used for common elements on site pages and a change is made to those elements, then the change will automatically apply to all, correct? Is this the best way to achieve this? If so, would you please tell me how the statement for such should be written. Should it be include or include_once? I’ve read about this but am still unclear about it all.
Best Regards.
August 11, 2014 at 1:54 pm #178581__
ParticipantThe difference between
include_once
andinclude
is thatinclude_once
will only load the script if it has never been loaded before, whileinclude
will load it regardless.For the class definition, we only want it included once, since trying to define a class twice results in a fatal error. For templates, you want the file included every time you ask for it.
…I see this potentially being helpful with other things one might want to include into a page that requires frequent changes such as the menu bar on the page.
Yes, that’s a very common use case. And yes, you’ll see changes immediately: the
include
happens at run time, so you really are seeing the current version of the file. You don’t need to wait for anything to be “applied.”Is this the best way to achieve this?
It depends on the situation, but yes, in general it’s a fine approach.
<!doctype html> <html> <head> <!-- . . . --> </head> <body> <?php include "{$_SERVER['DOCUMENT_ROOT']/templates/your-top-menu.html}"; ?> <!-- . . . --> </body> </html>
August 12, 2014 at 11:37 pm #178839Anonymous
InactiveGreetings traq,
Something doesn’t seem quite right here. Shouldn’t there be additional coding in the head of this or before that as with the contact form for this to work? Also, I sem to recall someone saying html will not work within a php like
<?php include "{$_SERVER['DOCUMENT_ROOT']/templates/your-top-menu.html}"; ?>
I tried this and it didn’t work.
Beest Regards.
August 13, 2014 at 11:45 am #178920__
ParticipantShouldn’t there be additional coding in the head of this or before that as with the contact form for this to work?
It depends on the situation. For example, if you need to do something that involves setting headers (starting a session, setting a cookie, http redirects, …), then yes, that needs to come before any HTML or text output.
If you are only including a file, then no, no other code is needed.
Also, I sem to recall someone saying html will not work within a php like
<?php include "{$_SERVER['DOCUMENT_ROOT']/templates/your-top-menu.html}"; ?>
Meaning, you cannot
include
an html file? You can.This is what happens when you
include
a file:- the PHP engine “drops out” of PHP mode and into output mode.
- if the included file starts with
<?php
(or another recognized start tag), the PHP engine goes back to PHP mode. - from there, the PHP engine reads and executes the included file normally.
- when done, the PHP engine goes back to PHP mode (if it is not already).
So, if your included file has only HTML, it will simply be output. If your file has a
<?php
tag, it will be parsed as a PHP script.Effectively, you can re-create exactly what
include
does like so*:eval( '?>'.file_get_contents( 'your/file.txt' ) );
* of course, you should not do this.
Note that the file extension doesn’t matter. You can label your includes
.txt
or.php
or.inc
or.html
or.template
or.sweetsweetcandy
.** How PHP treats them depends entirely on their contents.** keep in mind that, for security reasons, all of your include files should not be accessible from the web (e.g., in a non-accessible directory or in a directory above the web root).
I tried this and it didn’t work.
How so? Are you sure the filesystem path is correct?
August 13, 2014 at 11:25 pm #178999Anonymous
Inactive** keep in mind that, for security reasons, all of your include files should not be accessible from the web (e.g., in a non-accessible directory or in a directory above the web root).
I’m confused. How do you make a file non-accessible? If it isn’t accessible how would a file be retrieved for use in a web page?
Isn’t the file in the example you gave in the web root? i.e.
<?php include "{$_SERVER['DOCUMENT_ROOT']/templates/your-top-menu.html}"; ?>
I also recall the file for the contact form was in the web root as well.
What’s the potential risk if an include is something as simple as a navigation bar or some such?
Do I place the <?php include within the
<nav></nav>
or do I place the <?php include where the<nav> …….</nav>
and the markup for the navigation bar was at?I am certain the file path is correct. I typed the url direct and the nav bar shows up.
Would you please check the contact form and its file accessibility for any security issues?
Many thanks!
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.