herghost Posted September 14, 2009 Share Posted September 14, 2009 Hi all, I am having a ponder on how you would go about this: Basically I have a page from where all the users in a database are shown, and you can access a page called userdetails.php by taking the id from the database ie userdetails.php?id=1 Once on this page I want to be able to add more details to various tables, so on this page I will have a various links for new forms eg. add services add prices eg. How would I make sure that in each form the id number matched the users id? would i have to do something like addservices.php?id=$id ? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/ Share on other sites More sharing options...
RussellReal Posted September 14, 2009 Share Posted September 14, 2009 in every form.. just do.. echo "<input type='hidden' name='id' value='{$_GET['id']}' />"; Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918113 Share on other sites More sharing options...
herghost Posted September 14, 2009 Author Share Posted September 14, 2009 Notice: Undefined index: id in addservices.php on line 3 ?? Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918115 Share on other sites More sharing options...
trq Posted September 14, 2009 Share Posted September 14, 2009 You need to check the index exists before trying to use it. if (isset($_GET['id'])) { echo "<input type='hidden' name='id' value='{$_GET['id']}' />"; } Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918119 Share on other sites More sharing options...
herghost Posted September 14, 2009 Author Share Posted September 14, 2009 Thanks, now getting Notice: Undefined index: idaddservicesdo.php on line 6 Might be easier if just show you what I have! addservices.php <form method="post" action="addservicesdo.php"> <?php if (isset($_GET['id'])) { echo "<input type='hidden' name='id' value='{$_GET['id']}' />"; } ?> <p>hosting package <select name="hosting"> <option value="">None</option> <option value="standard">Standard</option> <option value="professional">Professional</option> <option value="business">Business</option> </select> <br> domain: <input type="text" name="domain"> <br> Backup plan <select name="backup"> <option value="">none</option> <option value="500mb">500mb</option> <option value="1000mb">1000mb</option> <option value="5000mb">5000mb</option> <option value="1000mb">1000mb</option> </select> <input type="submit" value="Next"> </p> </form> addservicesdo.php <?php include('../include/dbconfig.php'); //let's start the session session_start(); $id = ($_POST['id']); $hosting = ($_POST['hosting']); $domains = ($_POST['domain']); $backup = ($_POST['backup']); mysql_select_db("jolly_accounts", $conn); $sql="INSERT INTO services (id,hosting,domains,backup) VALUES ('$id', '$hosting', '$domains', '$backup')"; if (!mysql_query($sql,$conn)) { die('Error: ' . mysql_error()); } echo "services successfully added to user."; mysql_close($conn); ?> So much for 'this will be easy!' Thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918123 Share on other sites More sharing options...
herghost Posted September 14, 2009 Author Share Posted September 14, 2009 been playing with this for a few hours now and still no luck! anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918227 Share on other sites More sharing options...
RussellReal Posted September 14, 2009 Share Posted September 14, 2009 in the second page the id isn't being passed to it. Quote Link to comment https://forums.phpfreaks.com/topic/174164-how-to-define-id/#findComment-918426 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.