darkhappy Posted February 17, 2008 Share Posted February 17, 2008 what do i put for action when posting form data back to the page i am in? <form id="form1" name="form1" method="post" action="?????"> many thanks! - bobby Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Just the page.. <form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']; ?>"> Quote Link to comment Share on other sites More sharing options...
trq Posted February 17, 2008 Share Posted February 17, 2008 Simply leave the action out all together. <form id="form1" name="form1" method="post"> Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Simply leave the action out all together. <form id="form1" name="form1" method="post"> Is that not invalid html? Quote Link to comment Share on other sites More sharing options...
darkhappy Posted February 17, 2008 Author Share Posted February 17, 2008 so if you put button a submit button at the end of the form with no action in the post, does it just reload the page? <form id="form1" name="form1" method="post"> <select name="company2"> <?php while ($s = mysql_fetch_array($result2)) { $cname_list = $s["cname"]; ?> <option value="<?php echo $cname_list; ?>"><?php echo $cname_list; ?></option> <?php } ?> <input type="submit" name="button" id="button" value="Go" /> </form> Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 Yes. It's easier to try then to ask. Quote Link to comment Share on other sites More sharing options...
trq Posted February 17, 2008 Share Posted February 17, 2008 Actually, you are correct. It is invalid, though it works it will not validate. Hadn't even looked at it before. Quote Link to comment Share on other sites More sharing options...
darkhappy Posted February 17, 2008 Author Share Posted February 17, 2008 Yes. It's easier to try then to ask. yeah i did try before i asked but having problems with my code so needed to confirm - thanks everyone for the help! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted February 17, 2008 Share Posted February 17, 2008 I am not sure if an empty string for the action="" validates but it is refers to the same page. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 17, 2008 Share Posted February 17, 2008 Yes the empty string for the action validates fine. I tried it. Ken Quote Link to comment Share on other sites More sharing options...
Chris92 Posted February 17, 2008 Share Posted February 17, 2008 I would still recomend filling it in. Maybe using REQUEST_URI would be better, it includes the querysting aswell. <form id="form1" name="form1" method="post" action="<?=$_SERVER['REQUEST_URI']; ?>"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.