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 Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/ 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']; ?>"> Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468825 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"> Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468832 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? Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468837 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> Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468843 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. Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468844 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. Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468845 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! Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468850 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. Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468890 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 Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468901 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']; ?>"> Link to comment https://forums.phpfreaks.com/topic/91531-posting-form-data-to-self/#findComment-468919 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.