This is a discussion on isset($_POST['submit']) not true within the alt.comp.lang.php forums, part of the PHP Programming Forums category; In a form I have replaced the submit button with the second line of code, as follows (I wont go ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
In a form I have replaced the submit button with the second line of code, as
follows (I wont go into the reasons here, to keep my question straightforward) echo "<form name=\"$this->formName\" id=\"$this->formName\" action=\"" . $_SERVER['PHP_SELF'] . $theGETString . "\" method=\"POST\" >\n"; echo "<a href=\"javascript:document.forms['$this->formName'].submit();\" class=\"button\" >Submit Form</a>\n"; echo "</form>\n"; The form APPEARS to get POSTed, however, in the form it is posting to, where I have: if (isset($_POST['submit'])) { //this never gets executed! } My question is why not? Previously, if I created my submit button the standard way: echo "<input type=\"submit\" name=\"submit\" value=\"Submit Form\" class=\"button\"> In my POSTed to form, it would get executed where if (isset($_POST['submit'])) . Does anyone idea why I am unable to replace my submit button here, or a workaround? |
|
|||
|
You took out the variable named 'submit' hence it is no longer set.
John "Ike" <rxv@hotmail.com> wrote in message news:RCL0e.3296$gI5.2898@newsread1.news.pas.earthl ink.net... > In a form I have replaced the submit button with the second line of code, as > follows (I wont go into the reasons here, to keep my question > straightforward) > > echo "<form name=\"$this->formName\" id=\"$this->formName\" action=\"" . > $_SERVER['PHP_SELF'] . $theGETString . "\" method=\"POST\" >\n"; > echo "<a href=\"javascript:document.forms['$this->formName'].submit();\" > class=\"button\" >Submit Form</a>\n"; > echo "</form>\n"; > > The form APPEARS to get POSTed, however, in the form it is posting to, where > I have: > > if (isset($_POST['submit'])) { > //this never gets executed! > } > > My question is why not? Previously, if I created my submit button the > standard way: > echo "<input type=\"submit\" name=\"submit\" value=\"Submit Form\" > class=\"button\"> > > In my POSTed to form, it would get executed where if > (isset($_POST['submit'])) . Does anyone idea why I am unable to replace my > submit button here, or a workaround? > > |
|
|||
|
"Ike" <rxv@hotmail.com> kirjoitti
viestissä:RCL0e.3296$gI5.2898@newsread1.news.pas.e arthlink.net... > In a form I have replaced the submit button with the second line of code, > as > follows (I wont go into the reasons here, to keep my question > straightforward) > > echo "<form name=\"$this->formName\" id=\"$this->formName\" action=\"" . > $_SERVER['PHP_SELF'] . $theGETString . "\" method=\"POST\" >\n"; > echo "<a href=\"javascript:document.forms['$this->formName'].submit();\" > class=\"button\" >Submit Form</a>\n"; > echo "</form>\n"; > > The form APPEARS to get POSTed, however, in the form it is posting to, > where > I have: > > if (isset($_POST['submit'])) { > //this never gets executed! > } > > My question is why not? Previously, if I created my submit button the > standard way: > echo "<input type=\"submit\" name=\"submit\" value=\"Submit Form\" > class=\"button\"> > > In my POSTed to form, it would get executed where if > (isset($_POST['submit'])) . Does anyone idea why I am unable to replace my > submit button here, or a workaround? The work-around: put this on your form echo '<input type="hidden" name="submit" value="true">'; It places a form element called "submit" on your form, which you then later check in the code to see if it was sent. Without the submit button it never will be sent to server unless you have something to replace it with. One thing I'd like to say that it's not generally a good idea to replace the submit button with a javascript/link. Some people don't use javascript and therefor they're unable to access your page if it relys on javascript. I simply can't believe your situation really requires replacing the button with a link until you explain why. I mean with css you can modify the appearance of a button to look anything you like, even a link. Still not satisfied? It can be an image as well... So why not? What's with the link? |
|
|||
|
"Tex John" <john@logontexas.com> wrote in message news:XcM0e.18580$ot.16538@tornado.texas.rr.com... > You took out the variable named 'submit' hence it is no longer set. How do I put it back in there without using the submit button itself? |
|
|||
|
See Kimmo's answer...<input type='hidden' name='submit' value='TRUE'>
"Ike" <rxv@hotmail.com> wrote in message news:SMM0e.3978$H06.2945@newsread3.news.pas.earthl ink.net... > > "Tex John" <john@logontexas.com> wrote in message > news:XcM0e.18580$ot.16538@tornado.texas.rr.com... > > You took out the variable named 'submit' hence it is no longer set. > > How do I put it back in there without using the submit button itself? > > |
|
|||
|
Ike wrote:
> In a form I have replaced the submit button with the second line of > code, as follows (I wont go into the reasons here, to keep my question > straightforward) > > echo "<form name=\"$this->formName\" id=\"$this->formName\" action=\"" > . $_SERVER['PHP_SELF'] . $theGETString . "\" method=\"POST\" >\n"; > echo "<a > href=\"javascript:document.forms['$this->formName'].submit();\" > class=\"button\" >Submit Form</a>\n"; > echo "</form>\n"; > > The form APPEARS to get POSTed, however, in the form it is posting to, > where I have: > > if (isset($_POST['submit'])) { > //this never gets executed! > } > > My question is why not? Previously, if I created my submit button the > standard way: > echo "<input type=\"submit\" name=\"submit\" value=\"Submit Form\" > class=\"button\"> > > In my POSTed to form, it would get executed where if > (isset($_POST['submit'])) . Does anyone idea why I am unable to > replace my submit button here, or a workaround? You no longer have a button named submit posting to the other page, so there is no longer a variable initialised in the $_POST array called "submit". A way you can check if a form has been posted (assuming there are any form values in the form) is to do the following check: if(sizeof($_POST)) { // do something } or to put a hidden field in the form (called eg "submit") and test for that. Ideally you should not use Javascript to submit a form at all as people may have it disabled and then the form won't work at all. There are obvious exceptions to this such as when creating an app for your own purpose or for an Intranet where you can control what's going on in the browsers. -- Chris Hope | www.electrictoolbox.com | www.linuxcdmall.com |
|
|||
|
"Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com> wrote in message news:d204kq$iou$1@phys-news1.kolumbus.fi... > It places a form element called "submit" on your form, which you then later > check in the code to see if it was sent. Without the submit button it never > will be sent to server unless you have something to replace it with. > > One thing I'd like to say that it's not generally a good idea to replace the > submit button with a javascript/link. Some people don't use javascript and > therefor they're unable to access your page if it relys on javascript. I > simply can't believe your situation really requires replacing the button > with a link until you explain why. I mean with css you can modify the > appearance of a button to look anything you like, even a link. Still not > satisfied? It can be an image as well... So why not? What's with the link? > > I need to make the page appear exactly the same as a java applet which resides in it. Therefore, I took out the botton images from the look and feel package so that the page appears exactly like the applet. Enclosed below is the page as rendered ( I assume this is what you are asking, yes?) and the css file that it requires to render the buttons: <html> <head> <title>GGForm Demo</title> <LINK rel="stylesheet" type="text/css" href="lstyle.css"> <STYLE type="text/css"> a:hover{ color:#555555; } </STYLE> </head> <body link="#777777" alink="#555555" vlink="#777777"> <table align="center" cellpadding=5 style="border:1px solid #CCCCCC;"> <tr><td> <label class="label" for="">Grip UPs System</label><br><br> <br><br><br> <form name="leads" id="leads" action="/leads.php" method="POST" style="margin:0"> <input type="hidden" name="uniqueId" id="uniqueId" class="text"> <input type="hidden" name="upcardkey" id="upcardkey" class="text"> <label class="selectlabel" for="associatekey">Associate serving this customer</label><br> <select name="associatekey" id="associatekey" size="1" class="select"> <option value="6">chip</option> <option value="4">chris55</option> <option value="7">dave</option> <option value="3">daw91</option> <option value="1">jol36</option> <option value="5">rjl10</option> <option value="2">rvince</option> <option value="8">tom</option> </select><br><br> <input type="hidden" name="date" id="date" class="text"> <input type="hidden" name="time" id="time" class="text"> <label class="textlabel" for="sensor" onClick="forms['leads'].sensor.select();">Sensor</label><br> <input type="text" name="sensor" ..id="sensor" size="3" MAXLENGTH="3" class="text"><br><br> <label class="textlabel" for="heads" onClick="forms['leads'].heads.select();">Number of persons in this party</label><br> <input type="text" name="heads" ..id="heads" size="3" MAXLENGTH="3" class="text"><br><br> <input type="hidden" name="upskey" id="upskey" class="text"> <label class="selectlabel" for="howdidyouhear">How did you hear about our company?</label><br> <select name="howdidyouhear" id="howdidyouhear" size="1" class="select"> <option value="12"> hf membership list 2004</option> <option value="3">cold call</option> <option value="11">distributor</option> <option value="6">home builders</option> <option value="10">justin</option> <option value="1">market-high point</option> <option value="8">mortgage companies</option> <option value="9">other</option> <option value="5">phone up</option> <option value="2">pre-market-high point</option> <option value="7">real estate</option> <option value="4">referral</option> </select><br><br> <div class="hbuttons"> <a href="javascript:document.forms['leads'].reset();" value="Reset Form" class="button" >Reset Form</a> <a href="javascript:document.forms['leads'].submit();" class="button" >Submit Form</a> </form> </div> <div style="clear: left;"></div> </td></tr></table> </body></html> //lsytle.css: ..hbuttons a{ display: block; text-decoration: none; font: 11px Arial; color: black; width: 140px; height: 25px; float: left; display: inline; margin-right: 8px; background-image:url(backgroundbutton.gif); background-repeat: no-repeat; padding-top: 4px; text-align:center; border:none } ..hbuttons a:hover{ background-image:url(foregroundbutton.gif); } ..hbuttons a#current { background-image:url(foregroundbutton.gif); } |
|
|||
|
"Ike" <rxv@hotmail.com> kirjoitti
viestissä:JTM0e.3986$H06.2508@newsread3.news.pas.e arthlink.net... > Oh, Sorry Kimmo -- I completely missed your first paragraph of your > response. But won't that make submit==true even if the reset button is > then > hit? -Ike > No, because only hitting submit submit's the form. Hitting reset does not send form data, it just rests the values. |
|
|||
|
"Ike" <rxv@hotmail.com> kirjoitti
viestissä:jRM0e.3984$H06.2786@newsread3.news.pas.e arthlink.net... > > "Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com> wrote in message > news:d204kq$iou$1@phys-news1.kolumbus.fi... >> It places a form element called "submit" on your form, which you then > later >> check in the code to see if it was sent. Without the submit button it > never >> will be sent to server unless you have something to replace it with. >> >> One thing I'd like to say that it's not generally a good idea to replace > the >> submit button with a javascript/link. Some people don't use javascript >> and >> therefor they're unable to access your page if it relys on javascript. I >> simply can't believe your situation really requires replacing the button >> with a link until you explain why. I mean with css you can modify the >> appearance of a button to look anything you like, even a link. Still not >> satisfied? It can be an image as well... So why not? What's with the >> link? >> >> > > I need to make the page appear exactly the same as a java applet which > resides in it. Therefore, I took out the botton images from the look and > feel package so that the page appears exactly like the applet. Enclosed > below is the page as rendered ( I assume this is what you are asking, > yes?) > and the css file that it requires to render the buttons: > > <html> > <head> > <title>GGForm Demo</title> > > <LINK rel="stylesheet" type="text/css" href="lstyle.css"> > <STYLE type="text/css"> > a:hover{ color:#555555; } > </STYLE> > </head> > > <body link="#777777" alink="#555555" vlink="#777777"> > > <table align="center" cellpadding=5 style="border:1px solid #CCCCCC;"> > <tr><td> > > <label class="label" for="">Grip UPs System</label><br><br> > <br><br><br> > <form name="leads" id="leads" action="/leads.php" method="POST" > style="margin:0"> > <input type="hidden" name="uniqueId" id="uniqueId" class="text"> > <input type="hidden" name="upcardkey" id="upcardkey" class="text"> > <label class="selectlabel" for="associatekey">Associate serving this > customer</label><br> > <select name="associatekey" id="associatekey" size="1" class="select"> > <option value="6">chip</option> > <option value="4">chris55</option> > <option value="7">dave</option> > <option value="3">daw91</option> > <option value="1">jol36</option> > <option value="5">rjl10</option> > <option value="2">rvince</option> > <option value="8">tom</option> > </select><br><br> > > <input type="hidden" name="date" id="date" class="text"> > <input type="hidden" name="time" id="time" class="text"> > <label class="textlabel" for="sensor" > onClick="forms['leads'].sensor.select();">Sensor</label><br> > <input type="text" name="sensor" ..id="sensor" size="3" MAXLENGTH="3" > class="text"><br><br> > > <label class="textlabel" for="heads" > onClick="forms['leads'].heads.select();">Number of persons in this > party</label><br> > <input type="text" name="heads" ..id="heads" size="3" MAXLENGTH="3" > class="text"><br><br> > > <input type="hidden" name="upskey" id="upskey" class="text"> > <label class="selectlabel" for="howdidyouhear">How did you hear about our > company?</label><br> > <select name="howdidyouhear" id="howdidyouhear" size="1" class="select"> > <option value="12"> hf membership list 2004</option> > <option value="3">cold call</option> > <option value="11">distributor</option> > <option value="6">home builders</option> > <option value="10">justin</option> > <option value="1">market-high point</option> > <option value="8">mortgage companies</option> > <option value="9">other</option> > <option value="5">phone up</option> > <option value="2">pre-market-high point</option> > <option value="7">real estate</option> > <option value="4">referral</option> > </select><br><br> > > <div class="hbuttons"> > <a href="javascript:document.forms['leads'].reset();" value="Reset Form" > class="button" >Reset Form</a> > <a href="javascript:document.forms['leads'].submit();" class="button" >>Submit Form</a> > </form> > </div> > <div style="clear: left;"></div> > > </td></tr></table> > </body></html> > > //lsytle.css: > > .hbuttons a{ > display: block; > text-decoration: none; > font: 11px Arial; > color: black; > width: 140px; > height: 25px; > float: left; > display: inline; > margin-right: 8px; > background-image:url(backgroundbutton.gif); > background-repeat: no-repeat; > padding-top: 4px; > text-align:center; > border:none > } > > .hbuttons a:hover{ > background-image:url(foregroundbutton.gif); > } > > .hbuttons a#current { > background-image:url(foregroundbutton.gif); > } Hmm.. okay, but why not <div class="hbuttons"> <input type="reset" value="Reset Form" class="button" value="Reset Form" onMouseOver="this.className='button_hover';" onMouseOut="this.className='button';"> <input type="submit" name="submit" class="button" value="Submit Form" onMouseOver="this.className='button_hover';" onMouseOut="this.className='button';"> </div> and .hbuttons a, .hbuttons button{ display: block; text-decoration: none; font: 11px Arial; color: black; width: 140px; height: 25px; float: left; display: inline; margin-right: 8px; background-image:url(backgroundbutton.gif); background-repeat: no-repeat; padding-top: 4px; text-align:center; border:none } ..hbuttons a:hover, .hbuttons a#current, .hbuttons button_hover { background-image:url(foregroundbutton.gif); } The only two changes would be that user with no javascript would 1) not get the hover-effect 2) still be able to submit the form. The benefit of 2 exceeds the disadvantage of 1, so it would make sense to use it. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|