473,408 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Require user to type an specific word in form in order to get form submitted?

matheussousuke
249 100+
To prevent spam, I need the user text to have the <html> tag in the beginning, because the site is about blogger/myspace templates, so the system gotta recognize that there is a <html> tag somewhere in the text.

I think it can be easily done with condition function, but I don't know how where from start.
Feb 11 '12 #1
15 10459
i dont realy understand your question can you expanciate on what you want...are you trying to search for the occurence of <html> in the submitted string?
Feb 11 '12 #2
matheussousuke
249 100+
It's like:

1 - User is typing, then he submits the form.
2 - On submission, user get a message saying: The content you typed is not a myspace/blogger template, please use a template.
3 - To know if he's using a template or not, the system will see if in the submitted text there was a <html> tag, but the user doesn't know about.

I think that's a little like that "Required field" function, but here there is no if (empty) function.
Feb 12 '12 #3
i hope this should help you

if not let me know

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $word_a = "<html>";
  4. $word_b = "</html>";
  5. $main = $_POST['variable_name'];
  6.  
  7. #the main varible will be submitted by your form. Change the variable_name for the real name of your variable on the form
  8.  
  9. $errors = array();
  10. #this will hold any error messages if found
  11.  
  12. if (strpos($main, $word_a) === false) 
  13. {
  14. $errors[] = "Our Systems Detected that this is not a valid blogger/myspace template - Missing <html> tag";
  15. }
  16.  
  17. if (strpos($main, $word_a) !== false)
  18. {
  19. echo "Your success messages or you could leave it blank";
  20. }
  21.  
  22. if (strpos($main, $word_b) === false)
  23. {
  24. $errors[] = "Our Systems Detected that this is not a valid blogger/myspace template - Missing </html> tag";
  25. }
  26.  
  27. if (strpos($main, $word_b) !== false)
  28. {
  29. echo "Your success messages or you could leave it blank";
  30. }
  31.  ?>
  32.  
i hope this helps...let me know if not
Feb 12 '12 #4
i hope this should help you

if not let me know

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $word_a = "<html>";
  4. $word_b = "</html>";
  5. $main = $_POST['variable_name'];
  6.  
  7. #the main varible will be submitted by your form. Change the variable_name for the real name of your variable on the form
  8.  
  9. $errors = array();
  10. #this will hold any error messages if found
  11.  
  12. if (strpos($main, $word_a) === false) 
  13. {
  14. $errors[] = "Our Systems Detected that this is not a valid blogger/myspace template - Missing <html> tag";
  15. }
  16.  
  17. if (strpos($main, $word_a) !== false)
  18. {
  19. echo "Your success messages or you could leave it blank";
  20. }
  21.  
  22. if (strpos($main, $word_b) === false)
  23. {
  24. $errors[] = "Our Systems Detected that this is not a valid blogger/myspace template - Missing </html> tag";
  25. }
  26.  
  27. if (strpos($main, $word_b) !== false)
  28. {
  29. echo "Your success messages or you could leave it blank";
  30. }
  31.  ?>
  32.  
i hope this helps...let me know if not
Feb 12 '12 #5
matheussousuke
249 100+
Woa, that's awesome, I have to finish a few coding here, after it, I'll use ur script and let u know. Thx a lot :D
Feb 12 '12 #6
matheussousuke
249 100+
Bebore using it, have to insert a scroll bar, but is it possible to do that as php?
Feb 12 '12 #7
to insert a scroll bar using php?...if yes i don't think that's necessary insert your scroll bar using html and css. is the code working fine?
Feb 12 '12 #8
matheussousuke
249 100+
I still haven't tested it. I'm having an issue with the submitted content, it has to be inside a scroll bar after submitted, because it takes too much space.
Feb 12 '12 #9
may be this may work for you

the html
Expand|Select|Wrap|Line Numbers
  1. <div class=sub_content"><?php echo $submitted_content; ?></div
the css
Expand|Select|Wrap|Line Numbers
  1. .sub_content
  2. {
  3. overflow: scroll;
  4. max-width: specify the width you want here eg 500px;
  5. max-height: specify the height you want here eg 350px;
  6. }
  7.  
that should fix it for you.
Feb 12 '12 #10
matheussousuke
249 100+
Where u from, Joseph?
Feb 12 '12 #11
am from nigeria...where are you?
Feb 12 '12 #12
matheussousuke
249 100+
Currently Brazil.

I still haven't used your script because I haven't fixed the form issue, thought it was just the scroll bar, inserted it, but there is another bug now, can I pm you?
Feb 13 '12 #13
matheussousuke
249 100+
Sorry, it's been 1 week since my last reply, I'm not being able to use ur script, it wont show the error messages.
Feb 23 '12 #14
give me your full source code and how you implemented the script let me find out why there is no error message
Feb 23 '12 #15
matheussousuke
249 100+
The text comes from a textarea tag

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  
  4.  
  5. /**
  6.  
  7.  
  8.  
  9.  * Elgg bloggertemplates Plugin
  10.  
  11.  
  12.  
  13.  * @package bloggertemplates
  14.  
  15.  
  16.  
  17.  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
  18.  
  19.  
  20.  
  21.  * @author slyhne
  22.  
  23.  
  24.  
  25.  * @copyright slyhne 2010-2011
  26.  
  27.  
  28.  
  29.  * @link www.zurf.dk/elgg
  30.  
  31.  
  32.  
  33.  * @version 1.8
  34.  
  35.  
  36.  
  37.  */
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. // Get plugin settings
  46.  
  47.  
  48.  
  49. $allowhtml = elgg_get_plugin_setting('bloggertemplates_allowhtml', 'bloggertemplates');
  50.  
  51.  
  52.  
  53. $currency = elgg_get_plugin_setting('bloggertemplates_currency', 'bloggertemplates');
  54.  
  55.  
  56.  
  57. $numchars = elgg_get_plugin_setting('bloggertemplates_numchars', 'bloggertemplates');
  58.  
  59.  
  60.  
  61. if($numchars == ''){
  62.  
  63.  
  64.  
  65.     $numchars = '250';
  66.  
  67.  
  68.  
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. // Set title, form destination
  78.  
  79.  
  80.  
  81. $title = elgg_echo("bloggertemplates:addpost");
  82.  
  83.  
  84.  
  85. $tags = "";
  86.  
  87.  
  88.  
  89. $title = "";
  90.  
  91.  
  92.  
  93. $price = "";
  94.  
  95.  
  96.  
  97. $custom = "";
  98.  
  99.  
  100.  
  101. $description = "";
  102.  
  103.  
  104.  
  105. if (defined('ACCESS_DEFAULT')) {
  106.  
  107.  
  108.  
  109.     $access_id = ACCESS_DEFAULT;
  110.  
  111.  
  112.  
  113. } else {
  114.  
  115.  
  116.  
  117.     $access_id = 0;
  118.  
  119.  
  120.  
  121. }
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. // Just in case we have some cached details
  130.  
  131.  
  132.  
  133. if (isset($vars['bloggertemplatestitle'])) {
  134.  
  135.  
  136.  
  137.     $title = $vars['bloggertemplatestitle'];
  138.  
  139.  
  140.  
  141.     $body = $vars['bloggertemplatesbody'];
  142.  
  143.  
  144.  
  145.     $price = $vars['bloggertemplatesprice'];
  146.  
  147.  
  148.  
  149.     $custom = $vars['bloggertemplatescustom'];
  150.  
  151.  
  152.  
  153.     $tags = $vars['bloggertemplatestags'];
  154.  
  155.  
  156.  
  157. }
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169. ?>
  170.  
  171.  
  172.  
  173. <script type="text/javascript">
  174.  
  175.  
  176.  
  177. function textCounter(field,cntfield,maxlimit) {
  178.  
  179.  
  180.  
  181.     // if too long...trim it!
  182.  
  183.  
  184.  
  185.     if (field.value.length > maxlimit) {
  186.  
  187.  
  188.  
  189.         field.value = field.value.substring(0, maxlimit);
  190.  
  191.  
  192.  
  193.     } else {
  194.  
  195.  
  196.  
  197.         // otherwise, update 'characters left' counter
  198.  
  199.  
  200.  
  201.         cntfield.value = maxlimit - field.value.length;
  202.  
  203.  
  204.  
  205.     }
  206.  
  207.  
  208.  
  209. }
  210.  
  211.  
  212.  
  213. function acceptTerms() {
  214.  
  215.  
  216.  
  217.     error = 0;
  218.  
  219.  
  220.  
  221.     if(!(document.bloggertemplatesForm.accept_terms.checked) && (error==0)) {        
  222.  
  223.  
  224.  
  225.         alert('<?php echo elgg_echo('bloggertemplates:accept:terms:error'); ?>');
  226.  
  227.  
  228.  
  229.         document.bloggertemplatesForm.accept_terms.focus();
  230.  
  231.  
  232.  
  233.         error = 1;        
  234.  
  235.  
  236.  
  237.     }
  238.  
  239.  
  240.  
  241.     if(error == 0) {
  242.  
  243.  
  244.  
  245.         document.bloggertemplatesForm.submit();    
  246.  
  247.  
  248.  
  249.     }
  250.  
  251.  
  252.  
  253. }
  254.  
  255.  
  256.  
  257. </script>
  258.  
  259.  
  260.  
  261. <?php
  262.  
  263.  
  264.  
  265. echo "<label>";
  266.  
  267.  
  268.  
  269. echo elgg_echo("title");
  270.  
  271.  
  272.  
  273. echo "&nbsp;<small><small>" . elgg_echo("bloggertemplates:title:help") . "</small></small><br />";
  274.  
  275.  
  276.  
  277. echo elgg_view("input/text", array(
  278.  
  279.  
  280.  
  281.                 "name" => "bloggertemplatestitle",
  282.  
  283.  
  284.  
  285.                 "value" => $title,
  286.  
  287.  
  288.  
  289.                 ));
  290.  
  291.  
  292.  
  293. echo "</label></p>";
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301. $bloggertemplatescategories = elgg_view('bloggertemplates/bloggertemplatescategories',$vars);
  302.  
  303.  
  304.  
  305. if (!empty($bloggertemplatescategories)) {
  306.  
  307.  
  308.  
  309.     echo "<p>{$bloggertemplatescategories}</p>";
  310.  
  311.  
  312.  
  313. }
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321. if(elgg_get_plugin_setting('bloggertemplates_custom', 'bloggertemplates') == 'yes'){
  322.  
  323.  
  324.  
  325.     $bloggertemplatescustom = elgg_view('bloggertemplates/custom',$vars);
  326.  
  327.  
  328.  
  329.     if (!empty($bloggertemplatescustom)) {
  330.  
  331.  
  332.  
  333.         echo "<p>{$bloggertemplatescustom}</p>";
  334.  
  335.  
  336.  
  337.     }
  338.  
  339.  
  340.  
  341. }
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. echo "<p><label>" . elgg_echo("bloggertemplates:text") . "<br>";
  350.  
  351.  
  352.  
  353. if ($allowhtml != 'yes') {
  354.  
  355.  
  356.  
  357.     echo "<small><small>" . sprintf(elgg_echo("bloggertemplates:text:help"), $numchars) . "</small></small><br />";
  358.  
  359.  
  360.  
  361.     echo "<textarea name='bloggertemplatesbody' class='mceNoEditor' rows='8' cols='40' onKeyDown='textCounter(document.bloggertemplatesForm.bloggertemplatesbody,document.bloggertemplatesForm.remLen1,{$numchars}' onKeyUp='textCounter(document.bloggertemplatesForm.bloggertemplatesbody,document.bloggertemplatesForm.remLen1,{$numchars})'>{$body}</textarea><br />";
  362.  
  363.  
  364.  
  365.     echo "<div class='bloggertemplates_characters_remaining'><input readonly type='text' name='remLen1' size='3' maxlength='3' value='{$numchars}' class='bloggertemplates_charleft'>" . elgg_echo("bloggertemplates:charleft") . "</div>";
  366.  
  367.  
  368.  
  369. } else { 
  370.  
  371.  
  372.  
  373.     echo elgg_view("input/text", array("name" => "bloggertemplatesbody", "value" => $body));
  374.  
  375.  
  376.  
  377. }
  378.  
  379.  
  380.  
  381. echo "</label></p>";
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388. /*
  389. echo "<p><label>" . elgg_echo("bloggertemplates:price") . "&nbsp;<small><small>" . elgg_echo("bloggertemplates:price:help", array($currency)) . "</small></small><br />";
  390.  
  391.  
  392.  
  393. echo elgg_view("input/text", array(
  394.  
  395.  
  396.  
  397.                 "name" => "bloggertemplatesprice",
  398.  
  399.  
  400.  
  401.                 "value" => $price,
  402.  
  403.  
  404.  
  405.                 ));
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413. echo "</label></p>";
  414. */
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421. echo "<p><label>" . elgg_echo("bloggertemplates:tags") . "&nbsp;<small><small>" . elgg_echo("bloggertemplates:tags:help") . "</small></small><br />";
  422.  
  423.  
  424.  
  425. echo elgg_view("input/tags", array(
  426.  
  427.  
  428.  
  429.                 "name" => "bloggertemplatestags",
  430.  
  431.  
  432.  
  433.                 "value" => $tags,
  434.  
  435.  
  436.  
  437.                 ));
  438.  
  439.  
  440.  
  441. echo "</label></p>";
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449. echo "<p><label>" . elgg_echo("bloggertemplates:uploadimages") . "<br /><small><small>" . elgg_echo("bloggertemplates:imagelimitation") . "</small></small><br />";
  450.  
  451.  
  452.  
  453. echo elgg_view("input/file",array('name' => 'upload'));
  454.  
  455.  
  456.  
  457. echo "</label></p>";
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465. echo "<p><label>" . elgg_echo('access') . "&nbsp;<small><small>" . elgg_echo("bloggertemplates:access:help") . "</small></small><br />";
  466.  
  467.  
  468.  
  469. echo elgg_view('input/access', array('name' => 'access_id','value' => $access_id));
  470.  
  471.  
  472.  
  473. echo "</label></p>";
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481. echo "<p>";
  482.  
  483.  
  484.  
  485. // Terms checkbox and link
  486.  
  487.  
  488.  
  489. $termslink = elgg_view('output/url', array(
  490.  
  491.  
  492.  
  493.             'href' => "mod/bloggertemplates/terms.php",
  494.  
  495.  
  496.  
  497.             'text' => elgg_echo('bloggertemplates:terms:title'),
  498.  
  499.  
  500.  
  501.             'class' => "elgg-lightbox",
  502.  
  503.  
  504.  
  505.             ));
  506.  
  507.  
  508.  
  509. $termsaccept = sprintf(elgg_echo("bloggertemplates:accept:terms"),$termslink);
  510.  
  511.  
  512.  
  513. echo "</p>";
  514.  
  515.  
  516.  
  517. echo "<input type='checkbox' name='accept_terms'><label>{$termsaccept}</label></p>";
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525. echo elgg_view('input/submit', array('name' => 'submit', 'text' => elgg_echo('save')));
  526.  
  527.  
Feb 23 '12 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Daniel Ruscoe | last post by:
Hi chaps, I'm relatively new to the language, but I want to create a simple order form using PHP and cookies. Please let me know if there's a better way in this situation, database isn't...
5
by: Batezz | last post by:
I have created a form (below) How do I stop it redirecting to another page (productsearchresults.php) when form is submitted if both the fields are blank? Any help appreciated. Batezz
4
by: Eric | last post by:
Hey Everyone.. I have a form that has approximately 7 text fields and 1 checkbox. Generally when this form is submitted(to itself BTW) it works fine, however, when the checkbox is only field...
4
by: jwa6 | last post by:
I have a user/pc specific problem in access. This doesn't occur on any other ( windows xp pc) that I have used the ..mbd on. This involves a query that's using a range of dates as a parm. This...
23
by: karen987 | last post by:
I have a form on a html page which one fills in and submits using email. The form has been opened in a pop up page, Once the form has been submitted, (emailed) I need to add some javasript...
3
by: mckbill | last post by:
Is there a way I can direct the cursor to a specific field (variable) in a form by typing the field name while in form view? I have a form with many fields, and it would be nice if there were...
0
by: Francesco Pietra | last post by:
I forgot to add that the lines to strip are in present case of the type of the following block HETATM 7007 O WAT 446 27.622 34.356 55.205 1.00 0.00 O HETATM 7008 H1 WAT...
1
by: Deccypher | last post by:
Hi I am trying to give my customers an option to save favorite products for easy storage and reorderig. it works great and on the single item add to cart i have no problem, how ever i would also...
6
by: Palehorse | last post by:
I'd like to apologize upfront for me saying "I'm not a programer", I'm sure you all hear this a hundred times a day. Unfortunately, in this case, it's true. I've been working on trying to figure out...
3
by: Ron Mowry | last post by:
I am wanting to create a macro that will fill a specific field on a form and then go to the next record set. I have a blank field in the table that the form is pulling from. I want the user to be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.