Mundo Posted March 5, 2009 Share Posted March 5, 2009 I want my URL to resemble something like: http://localhost/clicker/diary.php?module=view&date=2009-03-05 My form is: <div id="text"> <h1>View Diary</h1> <p><b>Viewing the Diary</b> is easy. Use the drop down box to select a day (within the next 7 days (inclusive of today)) and the diary for that day will automatically be generated.</p> <form name="selectdayform" method="post" action="diary.php?module=view"> <label> <select name="selectday" id="selectday"> <option value="<? echo date("Y-m-d", $week1); ?>"><? echo date("F jS", $week1); ?></option> <option value="<? echo date("Y-m-d", $week2); ?>"><? echo date("F jS", $week2); ?></option> <option value="<? echo date("Y-m-d", $week3); ?>"><? echo date("F jS", $week3); ?></option> <option value="<? echo date("Y-m-d", $week4); ?>"><? echo date("F jS", $week4); ?></option> <option value="<? echo date("Y-m-d", $week5); ?>"><? echo date("F jS", $week5); ?></option> <option value="<? echo date("Y-m-d", $week6); ?>"><? echo date("F jS", $week6); ?></option> <option value="<? echo date("Y-m-d", $week7); ?>"><? echo date("F jS", $week7); ?></option> </select> <input name="submit" type="submit" value="submit"> </label> </form> </div> and my PHP is: <? mysql_connect("localhost","root",""); mysql_select_db("clicker"); include "tpl/header.tpl"; $week1 = mktime(0, 0, 0, date("m"), date("d"), date("y")); $week2 = mktime(0, 0, 0, date("m"), date("d")+1, date("y")); $week3 = mktime(0, 0, 0, date("m"), date("d")+2, date("y")); $week4 = mktime(0, 0, 0, date("m"), date("d")+3, date("y")); $week5 = mktime(0, 0, 0, date("m"), date("d")+4, date("y")); $week6 = mktime(0, 0, 0, date("m"), date("d")+5, date("y")); $week7 = mktime(0, 0, 0, date("m"), date("d")+6, date("y")); if($_GET['module'] == "view") { include "tpl/viewdiary.tpl"; if (isset($_POST['submit'])) { echo $_POST['selectdayform']; } } include "tpl/footer.tpl"; ?> What am I doing wrong? I don't understand... I know it must be pretty simple... Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/ Share on other sites More sharing options...
kickstart Posted March 5, 2009 Share Posted March 5, 2009 Hi Try changing the method on the form to "get". All the best Keith Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/#findComment-777387 Share on other sites More sharing options...
trq Posted March 5, 2009 Share Posted March 5, 2009 <form name="date" method="get" action="diary.php?module=view"> Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/#findComment-777389 Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2009 Share Posted March 5, 2009 If you use method="get" and you have a GET parameter on the end of the URL - "diary.php?module=view", the form fields will replace any GET parameters on the end of the URL. If you want to use GET, you would need to use a hidden field in the form for the module=view parameter. Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/#findComment-777423 Share on other sites More sharing options...
Mundo Posted March 5, 2009 Author Share Posted March 5, 2009 If you use method="get" and you have a GET parameter on the end of the URL - "diary.php?module=view", the form fields will replace any GET parameters on the end of the URL. If you want to use GET, you would need to use a hidden field in the form for the module=view parameter. So how would I make it diary.php?module=view&date=whatever ??? When I click my submit button, it goes to: http://localhost/clicker/diary.php?date=2009-03-10 But I need it to goto http://localhost/clicker/diary.php?module=view&date=2009-03-10 Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/#findComment-777451 Share on other sites More sharing options...
kickstart Posted March 5, 2009 Share Posted March 5, 2009 Hi Like this <div id="text"> <h1>View Diary</h1> <p><b>Viewing the Diary</b> is easy. Use the drop down box to select a day (within the next 7 days (inclusive of today)) and the diary for that day will automatically be generated.</p> <form name="selectdayform" method="get" action="diary.php"> <input type='hidden' name='module' value='view' /> <label> <select name="selectday" id="selectday"> <option value="<? echo date("Y-m-d", $week1); ?>"><? echo date("F jS", $week1); ?></option> <option value="<? echo date("Y-m-d", $week2); ?>"><? echo date("F jS", $week2); ?></option> <option value="<? echo date("Y-m-d", $week3); ?>"><? echo date("F jS", $week3); ?></option> <option value="<? echo date("Y-m-d", $week4); ?>"><? echo date("F jS", $week4); ?></option> <option value="<? echo date("Y-m-d", $week5); ?>"><? echo date("F jS", $week5); ?></option> <option value="<? echo date("Y-m-d", $week6); ?>"><? echo date("F jS", $week6); ?></option> <option value="<? echo date("Y-m-d", $week7); ?>"><? echo date("F jS", $week7); ?></option> </select> <input name="submit" type="submit" value="submit"> </label> </form> </div> All the best Keith Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/#findComment-777463 Share on other sites More sharing options...
Mundo Posted March 5, 2009 Author Share Posted March 5, 2009 Hi Like this <div id="text"> <h1>View Diary</h1> <p><b>Viewing the Diary</b> is easy. Use the drop down box to select a day (within the next 7 days (inclusive of today)) and the diary for that day will automatically be generated.</p> <form name="selectdayform" method="get" action="diary.php"> <input type='hidden' name='module' value='view' /> <label> <select name="selectday" id="selectday"> <option value="<? echo date("Y-m-d", $week1); ?>"><? echo date("F jS", $week1); ?></option> <option value="<? echo date("Y-m-d", $week2); ?>"><? echo date("F jS", $week2); ?></option> <option value="<? echo date("Y-m-d", $week3); ?>"><? echo date("F jS", $week3); ?></option> <option value="<? echo date("Y-m-d", $week4); ?>"><? echo date("F jS", $week4); ?></option> <option value="<? echo date("Y-m-d", $week5); ?>"><? echo date("F jS", $week5); ?></option> <option value="<? echo date("Y-m-d", $week6); ?>"><? echo date("F jS", $week6); ?></option> <option value="<? echo date("Y-m-d", $week7); ?>"><? echo date("F jS", $week7); ?></option> </select> <input name="submit" type="submit" value="submit"> </label> </form> </div> All the best Keith Brilliant, I knew it would be simpler then what I was trying. Thanks alot! Link to comment https://forums.phpfreaks.com/topic/148097-solved-post-and-get/#findComment-777465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.