Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9

Thread: Form Question

  1. #1
    New Coder
    Join Date
    Aug 2004
    Location
    Uppsala, Sweden
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form Question

    How can I make this page just to send it to gb.php and not be redirected after the posting.

    Code:
    <TABLE HEIGHT="100%" WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
    	<TR>
    		<TD ALIGN="left" VALIGN="top" COLSPAN="2">
    			<IFRAME SRC="gb.php" WIDTH="300" HEIGHT="320" FRAMEBORDER="0" SCROLLING="yes" STYLE="border-top:1px solid #999999;border-bottom:1px solid #999999;" allowTransparency="true">
    			</IFRAME>
    		</TD>
    	</TR>
    	<TR>
    		<TD ALIGN="left" VALIGN="top">
    			<FORM ACTION="gb.php" METHOD="post" NAME="gb">
    				<TABLE BORDER="0" CELLSPACING="3" CELLPADDING="3">
    					<TR>
    						<TD ALIGN="left" VALIGN="top">
    							<INPUT TYPE="text" NAME="uname"	SIZE="20" MAXLENGTH="30" VALUE="&nbsp;Name" CLASS="formstyle" OnFocus="javascript:this.select()"><BR>
    							<INPUT TYPE="text" NAME="email"	SIZE="20" MAXLENGTH="70" VALUE="&nbsp;E-mail" CLASS="formstyle" OnFocus="javascript:this.select()"><BR>
    							<SPAN CLASS="formtext">
    								<INPUT TYPE="submit" NAME="submit" VALUE="&nbsp;Send&nbsp;" CLASS="submitstyle">
    								<INPUT TYPE="reset" NAME="reset" VALUE="&nbsp;Reset&nbsp;" CLASS="submitstyle">
    							</SPAN>
    						</TD>
    						<TD ALIGN="left" VALIGN="top">
    							<TEXTAREA NAME="entry" ROWS="4" COLS="19" MAXLENGTH="80" CLASS="formstyle" OnFocus="javascript:this.select()">&nbsp;Message</TEXTAREA><BR>
    						</TD>
    					</TR>
    				</TABLE>
    			</FORM>
    		</TD>
    	</TR>
    </TABLE>
    If I post now, after I've hit Send I'm redirected to gb.php, but I just want it to reload the gb.php in the iframe.

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    to do what you want to do (assuming I understand your problem correctly), I think you're going to need a MySQL database....here's my idea:

    You would set up a "container" file (let's call it "container.php") that included 2 iframes, one for your form, and the other for your form's target page....subsequently, each iframe would have it's own unique source file (let's call one "form.php" for the form iframe, and call the other one "form_target_page.php" for the form's target iframe)...

    "form.php" would obviously contain the code for your form....In "form.php", you would also include some PHP before your form that sends your form values, if they are set, to your database.....you would then make the form action in "form.php" call itself, so "form.php" would reload "form.php" in the form iframe after you hit the form's submit button...soooo, then when you hit submit, "form.php" reloads in the form iframe, your PHP querying your database would kick in, and and then your form would appear again ready for its next use....

    In the meantime, "form_target_page.php" in the form's target iframe would be running a meta-refresh every 5 seconds to constantly reload itself in that iframe...every time this page refreshes, you would include some PHP in the file that queries the database looking for the form values that would have been uploaded there if someone had completed the form in the other iframe....if "form_target_page.php" 's database query found the form values, then you could make "form_target_page.php" redirect (with the header() function) to another page that would do whatever you want....and remember, header() would redirect the page inside that SAME iframe....

    So in this way you never leave "container.php"; only the embedded iframes reload and change....i think the only drawback to this is that if you want to resubmit your form more than once, you're screwed because "form_target_page.php" would have already detected your previous form submission's content and would have since redirected to another page...so "form_target_page.php" would no longer be constantly refreshing with the meta-refresh and consequently, your form's submission in the other iframe would never be recognized....

    UNLESS, you have a button/link on whatever page that "form_target_page.php" redirects to that would again redirect back to "form_target_page.php" when the user pressed it....that would work, and would allow for multiple uses of your form.....

    This might be confusing, so please ask me questions if you dont understand....

    Edit: I'm curious, what is this script for that you are writing?
    Last edited by chump2877; 03-22-2005 at 12:47 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The only way I can think of doing that is to put the form tag inside the iframe.

    you could optionally have another form in your main page that copies itself to the iframe form and submits it...

    possibly look at the "target" attribute, though I think that only works for links.

  • #4
    New Coder
    Join Date
    Aug 2004
    Location
    Uppsala, Sweden
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm... Now you got me thinking (which I guess was the point of it all )
    The form now resides in guestbook.php, the container.php (gb.php) is in an iframe in guestbook.php.

    If the form then submits the data to itself (guestbook.php) it would reload to itself again. But I guess this still would require the use of the refresh in gb.php

    Any way around that?
    Or wouldn't the gb.php be reloaded at the same time as guestbook.php is reloaded?

  • #5
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    Actually, "container.php" and "gb.php" are not the same thing....In your case, and what I was suggesting, is that "container.php" would be a new file that you would create to hold 2 iframes: an iframe with a source called "gb.php" and an iframe with a source called "guestbook.php"....

    >> Any way around that?

    "gb.php" would have to refresh fairly often to detect if "guestbook.php" had uploaded form information to your database (with my solution)....But the refresh would be very smooth, and only detectable if you looked in your browser's status bar....however, there are drawbacks to meta-refresh (taken from that article I linked to):

    * If the redirect happens quickly (less than 2-3 seconds), your readers can't hit the "Back" button. This annoys many people.
    * Refreshing the current page can confuse people. If they didn't request the reload, some people can get concerned about security.

    You need to decide if these will be issues for the people who are going to be using your page....sometimes these things can be issues, but if you cite clear instructions on your page as to how to use your application, you should probably be fine.....

    >>Or wouldn't the gb.php be reloaded at the same time as guestbook.php is reloaded?

    Almost simulatneously, and only with the meta-refresh (again, with my solution)....at the most there would be a 5 second delay between reloads in "guestbook.php" and "gb.php"....You could cut the potential gap to 2 or 3 seconds, or even 0 seconds, by adjusting the auto-refresh time attribute in your meta-refresh....but, when you start to lower the intervals to lower than 5 seconds, then your status bar will constantly be showing your page in a state of refreshing itself....my personal preference is to keep it 5 seconds or above....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #6
    New Coder
    Join Date
    Aug 2004
    Location
    Uppsala, Sweden
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by chump2877
    Almost simulatneously, and only with the meta-refresh (again, with my solution)....at the most there would be a 5 second delay between reloads in "guestbook.php" and "gb.php"....You could cut the potential gap to 2 or 3 seconds, or even 0 seconds, by adjusting the auto-refresh time attribute in your meta-refresh....but, when you start to lower the intervals to lower than 5 seconds, then your status bar will constantly be showing your page in a state of refreshing itself....my personal preference is to keep it 5 seconds or above....
    well then, why not just have guestbook.php submit the form to itself, it would then reload itself and thus also reload gb.php which prints out the data?

    this is starting to borderline towards the PHP forum now. heh.

  • #7
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    >>well then, why not just have guestbook.php submit the form to itself, it would then reload itself and thus also reload gb.php which prints out the data?

    Yes, you could do that, but I thought you wanted "gb.php" to reload in your iframe....

    If you did it that way, you could program the results to load with CSS formatting (that looks like an iframe) or you could load your form results into some <textarea> tags.....I don;t really know what this is for (you never told me!), so do whatever fits your situation....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  • #8
    New Coder
    Join Date
    Aug 2004
    Location
    Uppsala, Sweden
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I worked it out, it acts as I want now. it redirects to itself

  • #9
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,830
    Thanks
    21
    Thanked 157 Times in 148 Posts
    Good deal....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •