By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,747 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,747 IT Pros & Developers. It's quick & easy.

redirecting to the same page

P: 3
Hi,

I've got a subscription form and I want to make it so once someone hits submit, they are redirected to the same page. I thought maybe there was some code that could grab the URL of the current page and insert it into the redirect value. Here is the code (i believe it's the fifth line):

Expand|Select|Wrap|Line Numbers
  1. <center><form method="post" action="" target="_new"> 
  2. <input type="hidden" name="meta_web_form_id" value=""> 
  3. <input type="hidden" name="meta_split_id" value=""> 
  4. <input type="hidden" name="unit" value=""> 
  5. <input type="hidden" name="redirect" value=""> 
  6. <input type="hidden" name="meta_redirect_onlist" value=""> 
  7. <input type="hidden" name="meta_adtracking" value=""> 
  8. <input type="hidden" name="meta_message" value="1"> 
  9. <input type="hidden" name="meta_required" value="from"> 
  10. <input type="hidden" name="meta_forward_vars" value="0"> 
  11. <table> <tr><td colspan=2><center></center></td></tr> <tr><td>Email:</td><td><input type="text" name="from" value="" size="20"></td></tr> <tr><td>Name:</td><td><input type="text" name="name" value="" size="20"></td></tr>     <tr><td colspan=2><center></center></td></tr> <tr><td align="center" colspan="2"><input type="submit" name="submit" value="Submit"></td></tr> </table> </form>  </center>
How would you go about doing this? Any help would be greatly appreciated.

Thanks!
Oct 20 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
This won't be possible with HTML. You can either use a server-side language to set the redirect field value during page load or JavaScript to set it when the submit button is clicked.
Oct 21 '08 #2

P: 3
Alrite, I tried it in php. I'm really not too familiar with php and html, so based on some research I did, this is what I have so far:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. $url = $_SERVER['SERVER_NAME'];
  3. $page = $_SERVER['php_SELF'];
  4. ?> 
  5.  
  6. <center><form method="post" action="" target="_new">
  7. <input type="hidden" name="meta_web_form_id" value="">
  8. <input type="hidden" name="meta_split_id" value="">
  9. <input type="hidden" name="unit" value="">
  10. <input type="hidden" name="redirect" value= <?php echo "http://".$url.$page; ?>>
  11. <input type="hidden" name="meta_redirect_onlist" value="">
  12. <input type="hidden" name="meta_adtracking" value="">
  13. <input type="hidden" name="meta_message" value="1">
  14. <input type="hidden" name="meta_required" value="from">
  15. <input type="hidden" name="meta_forward_vars" value="0">
  16.  
It's not working, but am I onto something? Again, thanks for any help.
Oct 22 '08 #3

eWish
Expert 100+
P: 971
emumcard,

When posting code sample here at Bytes you are expected to use the tags. Please be sure to use them in the future. For more information on the use of code tags please read the Posting Guidelines "How to ask a question".

Since what you are wishing to do can not be achieved by HTML/CSS and you are trying with PHP I am moving this thread to the PHP Forum for further assistance.

--Kevin
Oct 22 '08 #4

Markus
Expert 5K+
P: 6,050
I believe
Expand|Select|Wrap|Line Numbers
  1. echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  2.  
will do what you want.
Oct 22 '08 #5

P: 3
I believe
Expand|Select|Wrap|Line Numbers
  1. echo "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
  2.  
will do what you want.
Thanks Markus, how do I format it though? Because when I include the php tags, it doesn't work.
Oct 23 '08 #6

Post your reply

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