avillanu Posted August 23, 2007 Share Posted August 23, 2007 I'd like to have a rating system for my CMS. I know how I'll set up the database. I'm just running into a very small problem regarding the form: <form method="post" action="rate.php"> <select name="rating"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> <input type="submit" name="submit" value="Rate" /> </form> The small problem is I don't know how to pass the content id (a number) to the form. How would I do this? Quote Link to comment Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 You need to elaberate. Where is this id comming from? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 You could store it in the session, but if you really want it in the form (and therefore, editable by users) try this: print '<input type="hidden" name="id" value="'.$id.'">"; Quote Link to comment Share on other sites More sharing options...
avillanu Posted August 23, 2007 Author Share Posted August 23, 2007 Well my script is set up like this: www.domain.com/page.php?id=25 would jesirose's solution work? Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 You need to add $id = $_GET['id'] for this instance. You'll want to "clean" it by making it $id = intval($_GET['id']); (if you're only ever expecting a number. Otherwise users can inject SQL (google: SQL injection) or XSS attacks. Quote Link to comment Share on other sites More sharing options...
avillanu Posted August 23, 2007 Author Share Posted August 23, 2007 Much appreciated. Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 No problem 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.