jib Posted May 20, 2008 Share Posted May 20, 2008 I'm stumped, I am no PHP expert instead learning as I go. But I have a problem which I was unable to any answer for in all my net searching. Basically I have a browsing page with a bunch of entries that just shows the title of the entry. Now each title is also a link to a page with more information. To do this I passed the ID of the entry to the url of the next page. Ie moreinfo.php?100 (100 being the id) The on the moreinfo page i use the get command to...get the title and the search the database again for that entry so I can show all the information about that entry. NOW the problem is I decided to create like a favorites thing, similar to ebays watch this item. Now for this I created a new table to store the username and entry ID but when I click the button to submit that. I lose my url and it just reverts to moreinfo.php which as a result clears the other information on the page because there is no ID in the url. How can I submit the form but whilst doing so maintain the url? Any help would be awsome, I don't wanna ditch this function because I couldn't manage to make it. Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/ Share on other sites More sharing options...
MadTechie Posted May 20, 2008 Share Posted May 20, 2008 not sure i have read this correctly but i think you are saying you go to a form with some GET's and then submit that form thus lossing the GETs, now you could use sessions or just add some hidden fields into the form ie <input name='name' type="hidden" value="<?php echo $_GET['name']; ?>"> Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545552 Share on other sites More sharing options...
Xurion Posted May 20, 2008 Share Posted May 20, 2008 Wouldn't that need to be page.php?name=bob Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545558 Share on other sites More sharing options...
jib Posted May 20, 2008 Author Share Posted May 20, 2008 yeah i tried a few hidden values but none of them seemed to work basically to give you an idea on the browse page i use this print "<tr><td width=400><a href=\"moreinfo.php?title=$ID\">$Title</a></td><td align=right><a>$converteddate</a></td></tr>"; so it passes the id to the url of the next page so it will look like this http://localhost/site/moreinfo.php?title=2 but when you click the button to post the data the url reverts to http://localhost/site/moreinfo.php so what i need is for it to post but not change the url or a way to set it back also just fyi, I don't know how to use sessions. Just learning as I go. Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545565 Share on other sites More sharing options...
MadTechie Posted May 20, 2008 Share Posted May 20, 2008 in the form change the action to <?php echo "<form action=\"?title={$_GET['title']}\">"; //or ?> <form action=\"?title=<?php echo $_GET['title']; ?>\"> Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545584 Share on other sites More sharing options...
jib Posted May 20, 2008 Author Share Posted May 20, 2008 the first code gives a strange answer moreinfo.php?submit=Mark+as+Interested I really don't understand how it got that, (Mark as Interested is the name of the button) The second gave url not found Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545600 Share on other sites More sharing options...
MadTechie Posted May 20, 2008 Share Posted May 20, 2008 seams your using submit and not title, can you post the form (in # code tags) Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545613 Share on other sites More sharing options...
jib Posted May 20, 2008 Author Share Posted May 20, 2008 <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> <input type="submit" name="submit" value="Mark as Interested" /> </form> *code with default submit php did you want the php code that relates to the submission? Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545622 Share on other sites More sharing options...
jib Posted May 20, 2008 Author Share Posted May 20, 2008 I sort of tried to change things along the lines of what you gave, changed the name to title and set the value to the ID instead of mark as interested (well was trying, didn't quite get it) but I noticed after using the first solution that the information wasn't being entered into the table Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545634 Share on other sites More sharing options...
MadTechie Posted May 20, 2008 Share Posted May 20, 2008 try this <form action="<?php echo "{$_SERVER['PHP_SELF']}?title={$_GET['title']}"; ?>" method="post"> <input type="submit" name="submit" value="Mark as Interested" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-545653 Share on other sites More sharing options...
jib Posted May 20, 2008 Author Share Posted May 20, 2008 IT WORKS! please have my babies! thanks Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-546099 Share on other sites More sharing options...
MadTechie Posted May 20, 2008 Share Posted May 20, 2008 LOL , can you click solved please to close this Quote Link to comment https://forums.phpfreaks.com/topic/106437-solved-setting-a-title-in-a-form-post/#findComment-546104 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.