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? Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/ 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? Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/#findComment-332135 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.'">"; Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/#findComment-332137 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? Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/#findComment-332147 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. Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/#findComment-332149 Share on other sites More sharing options...
avillanu Posted August 23, 2007 Author Share Posted August 23, 2007 Much appreciated. Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/#findComment-332174 Share on other sites More sharing options...
Jessica Posted August 23, 2007 Share Posted August 23, 2007 No problem Link to comment https://forums.phpfreaks.com/topic/66373-solved-rating-script-passing-id-issue/#findComment-332179 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.