php forum
php mysql forum
php mysql smarty
 
Topic Options
#278510 - 08/25/04 06:57 PM Php and Forms
pootlecat Offline
Power User

Registered: 07/24/02
Posts: 83
Loc: Canada
Hi,<br />I am hoping you guys can point me in the right direction <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" /><br />I've created a page that contains a form and when you submit the form the page calls itself. The problem is that when you hit enter it completely ignores everything you have filled in in the form.<br /><br />Here is the code (the page is called images.php):<br />
Code:
 <br />&lt;form method="post" action="/images.php"&gt;<br />&lt;select name="ImgType"&gt;<br />	&lt;option value="Photo Object" <br />	&lt;?php if ($ImgType == 'Photo Object') {echo('SELECTED') ;} ?&gt;<br />	&gt;Photo Objects&lt;/option&gt;<br />	&lt;option value="Stock Photo" <br />	&lt;?php if ($ImgType == 'Stock Photo') {echo('SELECTED') ;} ?&gt;<br />	&gt;Photos&lt;/option&gt;<br />	&lt;option value="Vector" <br />	&lt;?php if ($ImgType == 'Vector') {echo('SELECTED') ;} ?&gt;<br />	&gt;Vector Clipart&lt;/option&gt;<br />&lt;/select&gt;<br />&lt;span class="regular"&gt;Search by Keyword:&lt;/span&gt;&lt;br&gt;<br />&lt;input type="text" name="keyss" value="&lt;?php if ($submit) {echo $keyss ;} ?&gt;"&gt;<br />&lt;input type="submit" name="submit" value="Go!"&gt;<br />&lt;/form&gt;<br /><br />&lt;?php<br />if (!$submit) {<br />Do Something<br />}<br />else {<br />Do Something Else<br />};<br /> 
<br /><br />Any ideas?
_________________________
Never heard of Neopets.com?
If so then you won't like my site ;P

Top
#278511 - 08/27/04 03:19 AM Re: Php and Forms [Re: casper_dup1]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Hmm, try this... <br /> <br />
Code:
&lt;form method="post" action="&lt;?php echo($PHP_SELF); ?&gt;"&gt; <br />&lt;select name="ImgType"&gt; <br />	&lt;option value="Photo Object" <br /> 	&lt;?php if ($ImgType == 'Photo Object') {echo('SELECTED') ;} ?&gt; <br />	&gt;Photo Objects&lt;/option&gt; <br />	&lt;option value="Stock Photo" 	&lt;?php if ($ImgType == 'Stock Photo') {echo('SELECTED') ;} ?&gt; <br />	&gt;Photos&lt;/option&gt; <br />	&lt;option value="Vector" 	&lt;?php if ($ImgType == 'Vector') {echo('SELECTED') ;} ?&gt; <br />	&gt;Vector Clipart&lt;/option&gt; <br />&lt;/select&gt; <br />&lt;span class="regular"&gt;Search by Keyword:&lt;/span&gt;&lt;br&gt; <br />&lt;input type="text" name="keyss" value="&lt;?php if (isset($submit)) {echo $keyss ;} ?&gt;"&gt; <br />&lt;input type="submit" name="submit" value="Go!"&gt; <br />&lt;/form&gt; <br />&lt;?php <br />else (!isset($submit)) { <br />Do Something <br />} <br />else { <br />Do Something Else <br />} <br />?&gt;  
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#278512 - 08/27/04 07:00 PM Re: Php and Forms [Re: smoknz28]
Ron M Offline
Admin Emeritus

Registered: 11/29/01
Posts: 789
Loc: Des Moines, IA
Wouldn't he need to reference $_POST['ImgType'] instead of $ImgType in order to get the image type posted?
_________________________
http://thegeeksinc.com
[img]http://www.ubbdev.com/ud/?u=Sub_Zero&s=1[/img] points generated

Top
#278513 - 08/27/04 10:13 PM Re: Php and Forms [Re: domino]
scroungr Offline
Old Hand

Registered: 10/17/03
Posts: 2409
Loc: Richmond, VA
if globals are off yes
_________________________
Couchtomatoe - www.couch-tomatoe.cc
My abilities are for hire for installs, upgrades, custom themes and custom modifications.

Top
#278514 - 08/30/04 06:04 PM Re: Php and Forms [Re: 234234]
pootlecat Offline
Power User

Registered: 07/24/02
Posts: 83
Loc: Canada
Thanks to both of you but unfortunately it still doesn't work if you just hit 'Enter'.<br />You can try it yourself here: http://www.topfreeimages.com/images.php<br />Globals are on btw. I checked <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" /><br />Any other ideas or suggestions would be greatly appreciated!<br />Thanks,<br />Alison
_________________________
Never heard of Neopets.com?
If so then you won't like my site ;P

Top
#278515 - 08/31/04 12:12 AM Re: Php and Forms [Re: casper_dup1]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Ok after some testing I have discovered that this is an issue specific to Internet Explorer only. IE doesn't set the value of the submit button when the enter key is pressed, but Mozilla/Firefox does for example. The easiest way to get around it in your situation (with only one submit button on the page) is by making the following changes...<br /><br /><br />1-A) CHANGE THIS:<br /><br />
Code:
&lt;input type="text" name="keyss" value="&lt;?php if (isset($submit)) {echo $keyss ;} ?&gt;"&gt;<br />
<br /><br />TO THIS:<br /><br />
Code:
&lt;input type="text" name="keyss" value="&lt;?php if (!empty($_POST)) {echo $keyss ;} ?&gt;"&gt;<br />
<br /><br /><br />1-B) CHANGE THIS:<br /><br />
Code:
else (!isset($submit)) {
<br /><br />TO THIS:<br /><br />
Code:
else (empty($_POST)) {
<br /><br /><br />If you were using multiple submit buttons (each with different functions), then hidden input fields would need to be used and checked for in PHP. This method can also be used for you, but it's messier and not necessary.<br /><br />Ahh, if only all browsers behaved the same way...life would be so simple []http://www.mameworld.info/loonybar/images/graemlins/wink2.gif[/]
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#278516 - 09/01/04 06:54 AM Re: Php and Forms [Re: smoknz28]
pootlecat Offline
Power User

Registered: 07/24/02
Posts: 83
Loc: Canada
Thanks so much Twisty - you are a star! <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" /><br />Works like a charm!
_________________________
Never heard of Neopets.com?
If so then you won't like my site ;P

Top



Latest Posts
[7.2.1] - Naked shoutbox
by bellaonline
05/05/12 05:00 PM
[7.x] Stop Forum Spam Integration v0.4
by bellaonline
05/05/12 03:53 PM
Shout Box

(Views)Popular Topics
Known public proxy servers 1689885
Integrated Index Page (IIP) 5.3.1 555705
Finished-[6.5.2] Games Arcade Deluxe v1.9 501236
Integrated Index Page (IIP) 5.1.1 415112
TLD Bv2.1 Released - Threads Links Directory 396822
[6.0x] Who's Online 4.0.0 [Finished] 389412
Finished-[6.5.1] Integrated Index Page (IIP) 6.5 330423
Q & A 298663
Slash UBB 266936
[6.3.x] [beta] Hit Hack 2.0 227970
Forum Stats
13621 Members
59 Forums
37191 Topics
295716 Posts

Max Online: 686 @ 06/28/07 07:04 AM

 

 

 
fusionbb message board php hacks