Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP Search only works when clicking "submit"When you press the "Enter" key it runs the reset button

Posted on 2011-04-28
19
Medium Priority
?
594 Views
Last Modified: 2012-05-11
PHP Search only works when clicking "submit" When you press the "Enter" key it runs the reset button and not the submit button. I really need for it to submit when enter key is pressed.

Thanks,


www.ccttero.com is the website and here is the contents of the code for the search window.

<tr align="center">

                  <td><font size="-1" color="#002b40" face="Arial, Helvetica, sans-serif"><strong>Search </strong></font>

                  <input type="text" name="searchTerm" value="<?php echo $searchTerm; ?>" size="50"/>

                  <input type="submit" name="submit" value="Submit" hidefocus="true" onKeyPress="return processKey(this,event)" />

                  <input type="submit" name="reset" value="Reset" />                  </td>

      </tr>
0
Comment
Question by:TitoCebolla
  • 9
  • 6
  • 4
19 Comments
 
LVL 19

Accepted Solution

by:
Greg Alexander earned 2000 total points
ID: 35485773
Make tehe type on the reset, actually reset and I think you are good

<tr align="center">

                  <td><font size="-1" color="#002b40" face="Arial, Helvetica, sans-serif"><strong>Search </strong></font> 

                  <input type="text" name="searchTerm" value="<?php echo $searchTerm; ?>" size="50"/>

                  <input type="submit" name="submit" value="Submit" hidefocus="true" onKeyPress="return processKey(this,event)" />

                  <input type="reset" name="reset" value="Reset" />                  </td>

      </tr>

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35485937
Throw away the RESET button entirely.  You never see that on a search form any more!
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35485950
One other thing to look out for.  Your code looks like it might depend on "register_globals" and you probably want to get past that issue as soon as possible.
http://php.net/manual/en/security.globals.php

Best regards, ~Ray
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:TitoCebolla
ID: 35485986
If I delete the reset button will it use the "submit" button when you press the enter Key? Thats what I need but also I would like to keep the reset button if possible.

Thanks,
0
 
LVL 19

Expert Comment

by:Greg Alexander
ID: 35485993
Did you try my solution?
0
 

Author Comment

by:TitoCebolla
ID: 35486018
I aplogize "g" but I did not understand your submission but if I can I am definitaly willing to try.

thanks,
0
 
LVL 19

Expert Comment

by:Greg Alexander
ID: 35486065
 <input type="reset" name="reset" value="Reset" />        

instead of

  <input type="submit" name="reset" value="Reset" />        
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35486086
If I delete the reset button will it use the "submit" button when you press the enter Key? - Yes, unless you have JavaScript that intervenes.
Thats what I need but also I would like to keep the reset button if possible. - Then keep the reset button, but before you decide you need a reset button, have a look at the search boxes on a handful of the popular web sites like Google, Yahoo, Facebook, etc.  No reset buttons.  Maybe there is a reason why they do that, and in my opinion they do that because the reset button has never made any sense at all.  It's an unnecessary part.
0
 

Author Comment

by:TitoCebolla
ID: 35486162
Didn't work Ray. Thanks tho....
0
 

Author Comment

by:TitoCebolla
ID: 35486182
No go "g" thanks tho.
      <tr align="center">

                  <td><font size="-1" color="#002b40" face="Arial, Helvetica, sans-serif"><strong>Search </strong></font>

                  <input type="text" name="searchTerm" value="<?php echo $searchTerm; ?>" size="50"/>

                  <input type="submit" name="submit" value="Submit" hidefocus="true" onKeyPress="return processKey(this,event)" />

                  <input type="reset" name="reset" value="Reset" />                  </td>

      </tr>
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35486201
What does "didn't work" mean?  Parse error?  Message?  Halt and catch fire?

Please install this script and see if it works.  If not, tell us a little more about your browser and testing methods:
http://www.laprbass.com/RAY_form_thankyou_page.php
<?php // RAY_form_thankyou_page.php
error_reporting(E_ALL);
echo "<pre>\n";

// SHOW HOW TO DO FORM INPUT, VALIDATION, AND THANK YOU PAGE

// IF THERE IS SOMETHING THAT HAS BEEN POSTED
if (!empty($_POST))
{

    // THIS IS THE VALIDATION PROCESS - ONLY TWO RESULTS
    // EITHER A FAILURE PAGE OR A THANK YOU PAGE
    // CHECK TO SEE IF IT IS WHAT WE EXPECT
    if ($_POST["xyz"] != 'XYZ')
    {
        // CREATE ERROR PAGE IF DATA FAILED VALIDATION
        echo "\nSORRY YOU DID NOT ENTER XYZ";
    }
    else
    {
        // CREATE THANK YOU PAGE IF DATA PASSED VALIDATION
        echo "\nTHANK YOU, ";
        die("ALL DONE NOW");
    }

}// END OF PHP - PUT UP THE FORM
?>
<form method="post">
ENTER 'XYZ' IN UPPER CASE LETTERS HERE:
<input name="xyz" />
<input type="submit" />
</form>

Open in new window

0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35486205
Maybe you have omitted the <form> and </form> tags?
0
 

Author Comment

by:TitoCebolla
ID: 35486593
Didn't work means I deleted the reset button like you suggested, tested it by entering a search term and it still reset the page instead of submitting it.
0
 
LVL 19

Expert Comment

by:Greg Alexander
ID: 35486626
Whats the entire form look like?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35486965
Yes, let's see if there are <form> and </form> tags.  Those are not present in what you posted here.  Also you might try leaving out the JavaScript onKeyPress event for now.  Let's just get the form working first, then deal with the add-ons.
0
 

Author Comment

by:TitoCebolla
ID: 35487400
I do not see the <form> tag but I do see the </form> at almost the very end of all of the code.
I aplogize but I am just learning some of this. Here is the whole table code.


<table border="0" width="100%">

            <tr align="center">
            
             <p align="center"><font color="#000000" size="3">The order of preference shall be given in all RFP’s, IFB’s, and other contract solicitations in the following order: (1)100% Colville Business Enterprise (2)Colville Family Business Enterprise (3)Colville Business Enterprise (4)Indian Business Enterprise</font></p><br />
              <p align="center"><strong><font size="4" face="Times New Roman, Times, serif">Colville Confederated Tribes</font></strong></p><strong></em></font></strong><br />
          <font size="6"><p align="center">T</font><font size="4">ribal</font> <font size="6">E</font><font size="4">mployment</font>          <font size="6">R</font><font size="4">ights</font> <font size="6">O</font><font size="4">ffice</p></font> <font colo"#CC3333"           size="4" face="Times New Roman, Times, serif"><em><br />
          </em>
          <p align="center"><em><font color="#CC0000"><strong>Vendor Database Search</strong></font></em></p>
    </font></strong></font></h1></font><br /><p align="center"><font color="#000000" size="3">SEARCH TERM EXAMPLES:</font><font color="#8E7F73" size="3"> <font color="#000000" face="Times New Roman, Times, serif">Fencing, Paving, Wood Cutter, Carpentry, Demolition, Plumbing, Technology, Equipment Rental, Logging, Dump Truck ect.</font></font></p></em></font></strong></font></h1></font></tr>

            <tr align="center">

                  <td><font size="-1" color="#002b40" face="Arial, Helvetica, sans-serif"><strong>Search </strong></font>

                  <input type="text" name="searchTerm" value="<?php echo $searchTerm; ?>" size="50"/>

                  <input type="submit" name="submit" value="Submit" hidefocus="true" onKeyPress="return processKey(this,event)" />

                  <input type="reset" name="reset" value="Reset" />                  </td>

      </tr>

      </table>
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35488812
I object to deleting this question.  You got many good replies, but you posted only partial pieces of code.  This left us with nothing to go on, and we may have wasted our time (and yours) because you gave us an incomplete picture of what was really happening.  And the notion that you "do not want my code out there" is not really much of an issue - we have all see millions of lines of bad code, so there is nothing important or special about the code that you are having issues with.

Candor, clarity and forthright discussion will be of value to you in your work with EE.  All the best, ~Ray
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35488815
Please tell us how you solved it or tell us how our answers were unresponsive to your question.  We want to do the best we can.  Thanks, ~Ray
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35488861
Thanks for sharing!  Good luck in your work, now and in the future, ~Ray
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question